mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
bug 794038 pt 2.2 - don't attempt to change HiDPI mode on-the-fly in response to prefs or configuration changes. r=smichaud
This commit is contained in:
parent
06ee8a3792
commit
5d9598eeab
@ -563,69 +563,13 @@ nsCocoaUtils::ConvertToCarbonModifier(NSUInteger aCocoaModifier)
|
||||
static bool sHiDPIEnabled = false;
|
||||
static bool sHiDPIPrefInitialized = false;
|
||||
|
||||
@interface ScreenParamChangeWatcher : NSObject
|
||||
- (id)init;
|
||||
@end
|
||||
|
||||
@implementation ScreenParamChangeWatcher
|
||||
- (id)init
|
||||
{
|
||||
[super init];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationDidChangeScreenParameters:)
|
||||
name:NSApplicationDidChangeScreenParametersNotification
|
||||
object:NSApp];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)applicationDidChangeScreenParameters:(NSNotification *)notification
|
||||
{
|
||||
// reset flags so that the next call to HiDPIEnabled() will re-evaluate
|
||||
sHiDPIEnabled = false;
|
||||
sHiDPIPrefInitialized = false;
|
||||
}
|
||||
@end
|
||||
|
||||
class HiDPIPrefObserver MOZ_FINAL : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(HiDPIPrefObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
HiDPIPrefObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const PRUnichar* aData)
|
||||
{
|
||||
// reset flags so that the next call to HiDPIEnabled() will re-evaluate
|
||||
sHiDPIEnabled = false;
|
||||
sHiDPIPrefInitialized = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsCocoaUtils::HiDPIEnabled()
|
||||
{
|
||||
static ScreenParamChangeWatcher* sChangeWatcher = nil;
|
||||
|
||||
if (!sHiDPIPrefInitialized) {
|
||||
sHiDPIPrefInitialized = true;
|
||||
|
||||
if (!sChangeWatcher) {
|
||||
// Create an object to watch for changes in screen configuration.
|
||||
// Note that we'll leak this object at shutdown;
|
||||
// this is all a temporary hack until we have multi-screen HiDPI working
|
||||
// properly and can dispense with this code.
|
||||
sChangeWatcher = [[ScreenParamChangeWatcher alloc] init];
|
||||
|
||||
// And create an observer for changes to the preference.
|
||||
nsCOMPtr<nsIObserver> obs(new HiDPIPrefObserver());
|
||||
Preferences::AddStrongObserver(obs, "gfx.hidpi.enabled");
|
||||
}
|
||||
|
||||
int prefSetting = Preferences::GetInt("gfx.hidpi.enabled", 1);
|
||||
if (prefSetting <= 0) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user