Tk Source Code

Artifact [5864cd54]
Login

Artifact 5864cd54471d719eeeda0cdcd8ba31bef40a93c92c0522c6d1e180fc4eedb73d:

Attachment "fix-tooltip-warnings.patch" to ticket [8cb99d1d] added by nab 2026-03-22 15:32:36.
--- a/macosx/tkMacOSXSubwindows.c	2026-03-22 15:10:26
+++ b/macosx/tkMacOSXSubwindows.c	2026-03-22 16:25:30
@@ -186,9 +186,9 @@
 
 	    TkMacOSXApplyWindowAttributes(winPtr, win);
 	    [win setExcludedFromWindowsMenu:NO];
-	    [NSApp activateIgnoringOtherApps:initialized];
 	    if (initialized) {
 		if ([win canBecomeKeyWindow]) {
+		    [NSApp activateIgnoringOtherApps:YES];
 		    [win makeKeyAndOrderFront:NSApp];
 		    [NSApp setTkEventTarget:TkMacOSXGetTkWindow(win)];
 		} else {
@@ -335,8 +335,12 @@
     if (Tk_IsTopLevel(winPtr)) {
 	if (!Tk_IsEmbedded(winPtr) &&
 	    winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
+
+	    NSWindowAnimationBehavior savedBehavior = [win animationBehavior];
+	    [win setAnimationBehavior:NSWindowAnimationBehaviorNone];
 	    [win setExcludedFromWindowsMenu:YES];
 	    [win orderOut:NSApp];
+	    [win setAnimationBehavior:savedBehavior];
 	    [[win contentView] setOnScreen:NO];
 	    if ([win isKeyWindow]) {
 
@@ -361,7 +365,7 @@
 		    isOnScreen = (wmInfoPtr->hints.initial_state != IconicState &&
 				  wmInfoPtr->hints.initial_state != WithdrawnState);
 		    if (w != win && isOnScreen && [w canBecomeKeyWindow]) {
-			[w makeKeyAndOrderFront:NSApp];
+			[w makeKeyWindow];
 			[NSApp setTkEventTarget:TkMacOSXGetTkWindow(win)];
 			break;
 		    }
--- a/macosx/tkMacOSXWm.c	2026-03-22 15:10:26
+++ b/macosx/tkMacOSXWm.c	2026-03-22 16:14:27
@@ -866,7 +866,7 @@
 		      wmPtr->hints.initial_state != WithdrawnState);
 	if (w != ignore && isOnScreen && [w canBecomeKeyWindow]) {
 	    TKMenu *menu;
-	    [w makeKeyAndOrderFront:NSApp];
+	    [w makeKeyWindow];
 	    /* Set the menubar for the new front window. */
 	    if (winPtr->wmInfoPtr &&
 		winPtr->wmInfoPtr->menuPtr &&
@@ -1309,8 +1309,17 @@
 	 * key window which prevents it from being deallocated until it stops
 	 * being the key window.  On these systems the only option for
 	 * preventing zombies is to set the key window to nil.
+	 */
+
+	/*
+	 * Disable animations and hide the window before any key
+	 * window reassignment or close, to prevent opening a new
+	 * CGS transaction during an in-progress CA commit.
 	 */
 
+	[deadNSWindow setAnimationBehavior:NSWindowAnimationBehaviorNone];
+	[deadNSWindow orderOut:NSApp];
+
 	/*
 	 * Prevent zombies on systems with a TouchBar.
 	 */
@@ -2458,7 +2467,11 @@
     if (win) {
 	[win setExcludedFromWindowsMenu:NO];
 	TkMacOSXApplyWindowAttributes(winPtr, win);
-	[win orderFront:NSApp];
+	if ([win canBecomeKeyWindow]) {
+	    [win orderFront:NSApp];
+	} else {
+	    [win orderFrontRegardless];
+	}
     }
     if (wmPtr->icon) {
 	Tk_UnmapWindow((Tk_Window)wmPtr->icon);
@@ -6986,8 +6999,12 @@
 	TkWmUnmapWindow(winPtr);
     } else if (state == NormalState || state == ZoomState) {
 	TkWmMapWindow(winPtr);
-	[macWin deminiaturize:NSApp];
-	[macWin orderFront:NSApp];
+	if ([macWin canBecomeKeyWindow]) {
+	    [macWin deminiaturize:NSApp];
+	    [macWin orderFront:NSApp];
+	} else {
+	    [macWin orderFrontRegardless];
+	}
 	TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut);
     }