summaryrefslogtreecommitdiffstats
path: root/Mac/BuildScript/backport_gh92603_fix.patch
blob: 9a37b0296503409f81c66e6f72edd79e3d4ff9d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Accepted upstream for release in Tk 8.6.14:
https://core.tcl-lang.org/tk/info/cf3830280b

--- tk8.6.13/macosx/tkMacOSXWindowEvent.c.orig
+++ tk8.6.13-patched/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"]
--- tk8.6.13/macosx/tkMacOSXWm.c.orig
+++ tk8.6.13-patched/macosx/tkMacOSXWm.c
@@ -1289,6 +1289,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
@@ -6763,6 +6768,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];