summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-11-25 09:57:45 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-11-25 15:45:14 +0100
commite10e5981ca020af11d25d5756964c95d51dd1535 (patch)
tree181b134db4baa88fac2c3433353f2c965cf8b384
parent9206895999f36a8199862912afe0ca91462e914a (diff)
tdf#152183 update settings when dark/light system mode toggled
Change-Id: I2273d79d2703ebd7a021bdca1737f5fb9fa9bc32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143284 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/inc/osx/vclnsapp.h3
-rw-r--r--vcl/osx/salframe.cxx3
-rw-r--r--vcl/osx/vclnsapp.mm12
3 files changed, 17 insertions, 1 deletions
diff --git a/vcl/inc/osx/vclnsapp.h b/vcl/inc/osx/vclnsapp.h
index 5cf8582c3771..e3329f554c7e 100644
--- a/vcl/inc/osx/vclnsapp.h
+++ b/vcl/inc/osx/vclnsapp.h
@@ -47,6 +47,9 @@ class AquaSalFrame;
-(NSApplicationPrintReply)application: (NSApplication *) app printFiles:(NSArray *)files withSettings: (NSDictionary *)printSettings showPrintPanels:(BOOL)bShowPrintPanels;
-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication *) app;
-(void)applicationWillTerminate: (NSNotification *) aNotification;
+-(void)observeValueForKeyPath: (NSString*) keyPath ofObject:(id)object
+ change: (NSDictionary<NSKeyValueChangeKey, id>*)change
+ context: (void*)context;
-(void)systemColorsChanged: (NSNotification*) pNotification;
-(void)screenParametersChanged: (NSNotification*) pNotification;
-(void)scrollbarVariantChanged: (NSNotification*) pNotification;
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 76635cf9f270..df6413a8fe65 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1260,8 +1260,9 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
return;
SAL_WNODEPRECATED_DECLARATIONS_POP
- StyleSettings aStyleSettings = rSettings.GetStyleSettings();
+ [NSAppearance setCurrentAppearance: mpNSView.effectiveAppearance];
+ StyleSettings aStyleSettings = rSettings.GetStyleSettings();
bool bUseDarkMode(false);
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index ee848375cedb..d31b41b5f1e6 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -79,6 +79,9 @@
{
[NSWindow setAllowsAutomaticWindowTabbing:NO];
}
+
+ // listen to dark mode change
+ [NSApp addObserver:self forKeyPath:@"effectiveAppearance" options: 0 context: nil];
}
-(void)sendEvent:(NSEvent*)pEvent
@@ -327,6 +330,15 @@
return aReply;
}
+-(void)observeValueForKeyPath: (NSString*) keyPath ofObject:(id)object
+ change: (NSDictionary<NSKeyValueChangeKey, id>*)change
+ context: (void*)context
+{
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ if ([keyPath isEqualToString:@"effectiveAppearance"])
+ [self systemColorsChanged: nil];
+}
+
-(void)systemColorsChanged: (NSNotification*) pNotification
{
(void)pNotification;