# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1618365512 0 # Node ID 5b401a5cfa9094844908885fc35abf8ea8e3b89a # Parent ddc6d49d11102b373ce83443af3b077c3742e9c8 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. diff -r ddc6d49d1110 -r 5b401a5cfa90 mac/dw.m --- 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; }