summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2023-08-30 17:30:47 (GMT)
committerKevin Walzer <kw@codebykevin.com>2023-08-30 17:30:47 (GMT)
commit3d4865351a5e9ec4af6a58463a3d7b02ab9cdab7 (patch)
treed6d05d86851afd343c299d56e1ae7c71ef59ab96 /macosx
parenteae2af7661e0455d2275e86afac7f8c9de564837 (diff)
downloadtk-3d4865351a5e9ec4af6a58463a3d7b02ab9cdab7.zip
tk-3d4865351a5e9ec4af6a58463a3d7b02ab9cdab7.tar.gz
tk-3d4865351a5e9ec4af6a58463a3d7b02ab9cdab7.tar.bz2
Fix for ef5d3e29a4
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXWindowEvent.c25
-rw-r--r--macosx/tkMacOSXWm.c20
2 files changed, 22 insertions, 23 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index d9075f7..09112ee 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -239,8 +239,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
if (winPtr) {
TKContentView *view = [window contentView];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
- if (@available(macOS 10.15, *)) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ if (@available(macOS 10.14, *)) {
[view viewDidChangeEffectiveAppearance];
}
#endif
@@ -1237,29 +1237,8 @@ static const char *const accentNames[] = {
} else if (effectiveAppearanceName == NSAppearanceNameDarkAqua) {
TkSendVirtualEvent(tkwin, "DarkAqua", NULL);
}
- if ([NSApp macOSVersion] < 101500) {
-
- /*
- * Mojave cannot handle the KVO shenanigans that we need for the
- * highlight and accent color notifications.
- */
-
- return;
- }
if (!defaultColor) {
defaultColor = [NSApp macOSVersion] < 110000 ? "Blue" : "Multicolor";
- preferences = [[NSUserDefaults standardUserDefaults] retain];
-
- /*
- * AppKit calls this method when the user changes the Accent Color
- * but not when the user changes the Highlight Color. So we register
- * to receive KVO notifications for Highlight Color as well.
- */
-
- [preferences addObserver:self
- forKeyPath:@"AppleHighlightColor"
- options:NSKeyValueObservingOptionNew
- context:NULL];
}
NSString *accent = [preferences stringForKey:@"AppleAccentColor"];
NSArray *words = [[preferences stringForKey:@"AppleHighlightColor"]
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index e078938..0adfe4b 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -1086,6 +1086,11 @@ TkWmDeadWindow(
[NSApp _setMainWindow:nil];
}
[deadNSWindow close];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
+ [preferences removeObserver:deadNSWindow.contentView
+ forKeyPath:@"AppleHighlightColor"];
+#endif
[deadNSWindow release];
#if DEBUG_ZOMBIES > 1
@@ -6217,6 +6222,21 @@ TkMacOSXMakeRealWindowExist(
}
TKContentView *contentView = [[TKContentView alloc]
initWithFrame:NSZeroRect];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
+
+ /*
+ * AppKit calls the viewDidChangeEffectiveAppearance method when the
+ * user changes the Accent Color but not when the user changes the
+ * Highlight Color. So we register to receive KVO notifications for
+ * Highlight Color as well.
+ */
+
+ [preferences addObserver:contentView
+ forKeyPath:@"AppleHighlightColor"
+ options:NSKeyValueObservingOptionNew
+ context:NULL];
+#endif
[window setContentView:contentView];
[contentView release];
[window setDelegate:NSApp];