changeset 2460:5b401a5cfa90

Mac: Detect the current dark mode state and return DW_DARK_MODE_BASIC if in automatic mode with light active. Return DW_DARK_MODE_FULL in automatic mode with dark mode active. Previously it returned DW_FEATURE_ENABLED (DW_DARK_MODE_BASIC) regardless of the active mode.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 14 Apr 2021 01:58:32 +0000
parents ddc6d49d1110
children 7c716b48e5b5
files mac/dw.m
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Wed Apr 14 01:27:00 2021 +0000
+++ b/mac/dw.m	Wed Apr 14 01:58:32 2021 +0000
@@ -12567,7 +12567,7 @@
     DWThreadMutex2 = dw_mutex_new();
 #endif
     /* Use NSThread to start a dummy thread to initialize the threading subsystem */
-    NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil];
+    NSThread *thread = [[NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil];
     [thread start];
     [thread release];
     [NSTextField setCellClass:[DWTextFieldCell class]];
@@ -13168,17 +13168,24 @@
                 _dw_app_init();
                 /* Get the current appearance */
                 NSAppearance *appearance = [DWApp appearance];
-                
+                NSAppearanceName basicAppearance;
+
                 if(appearance)
                 {
-                    NSAppearanceName basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
-                    
+                    basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua,
+                                                                                      NSAppearanceNameDarkAqua]];
+
                     if([basicAppearance isEqualToString:NSAppearanceNameDarkAqua])
                         return DW_DARK_MODE_FORCED;
                     if([basicAppearance isEqualToString:NSAppearanceNameAqua])
                         return DW_FEATURE_DISABLED;
                 }
-                return DW_FEATURE_ENABLED;
+                appearance = [NSAppearance currentAppearance];
+                basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua,
+                                                                                  NSAppearanceNameDarkAqua]];
+                if([basicAppearance isEqualToString:NSAppearanceNameDarkAqua])
+                    return DW_DARK_MODE_FULL;
+                return DW_DARK_MODE_BASIC;
             }
             return DW_FEATURE_UNSUPPORTED;
         }