diff --git a/src/gui/macutils/AppKitImpl.mm b/src/gui/macutils/AppKitImpl.mm index 3727878e7..cd709df27 100644 --- a/src/gui/macutils/AppKitImpl.mm +++ b/src/gui/macutils/AppKitImpl.mm @@ -93,6 +93,17 @@ AppKit::~AppKit() return [app isHidden]; } +// +// Get state of macOS Dark Mode color scheme +// +- (bool) isDarkMode +{ + NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain]; + id style = [dict objectForKey:@"AppleInterfaceStyle"]; + return ( style && [style isKindOfClass:[NSString class]] + && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] ); +} + // // ------------------------- C++ Trampolines ------------------------- // @@ -129,10 +140,7 @@ bool AppKit::isHidden(pid_t pid) bool AppKit::isDarkMode() { - NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain]; - id style = [dict objectForKey:@"AppleInterfaceStyle"]; - return ( style && [style isKindOfClass:[NSString class]] - && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] ); + return [static_cast(self) isDarkMode]; } @end