From 73d9c1d6f0dee5b391ec0484d62638c087f2adf7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Sun, 27 Sep 2020 13:33:54 +0300
Subject: [PATCH 1/1] macOS: Robust system appearance check
This API does not exist on 10.13, so prepare for an exception.
src/macos.m | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/macos.m b/src/macos.m
index b000fed9..975ba928 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -38,6 +38,16 @@ enum iTouchBarVariant {
default_TouchBarVariant,
};
+static NSString *currentSystemAppearance_(void) {
return [[NSApp effectiveAppearance] name];
return @"NSAppearanceNameAqua";
+}
/----------------------------------------------------------------------------------------------/
@interface CommandButton : NSCustomTouchBarItem {
@@ -447,7 +457,11 @@ void setupApplication_MacOS(void) {
NSApplication *app = [NSApplication sharedApplication];
/* Our delegate will override SDL's delegate. */
MyDelegate *myDel = [[MyDelegate alloc] initWithSDLDelegate:app.delegate];
forKeyPath:@"effectiveAppearance"
options:0
context:myDel];
app.delegate = myDel;
NSMenu *appMenu = [[[NSApp mainMenu] itemAtIndex:0] submenu];
NSMenuItem *prefsItem = [appMenu itemWithTitle:@"Preferences…"];
@@ -463,10 +477,6 @@ void setupApplication_MacOS(void) {
void insertMenuItems_MacOS(const char *menuLabel, int atIndex, const iMenuItem *items, size_t count) {
NSApplication *app = [NSApplication sharedApplication];
MyDelegate *myDel = (MyDelegate *) app.delegate;
forKeyPath:@"effectiveAppearance"
options:0
context:myDel];
NSMenu *appMenu = [app mainMenu];
NSMenuItem *mainItem = [appMenu insertItemWithTitle:[NSString stringWithUTF8String:menuLabel]
action:nil
@@ -525,7 +535,7 @@ void insertMenuItems_MacOS(const char *menuLabel, int atIndex, const iMenuItem *
void handleCommand_MacOS(const char *cmd) {
if (equal_Command(cmd, "prefs.ostheme.changed")) {
if (arg_Command(cmd)) {
appearanceChanged_MacOS_([[NSApp effectiveAppearance] name]);
appearanceChanged_MacOS_(currentSystemAppearance_());
}
}
#if 0
--
2.25.1
text/plain
This content has been proxied by September (3851b).