summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2024-06-25 15:50:26 (GMT)
committerculler <culler>2024-06-25 15:50:26 (GMT)
commit468bf9b8df08c68927e81183d6ece4c3a91c2887 (patch)
tree2b47b97d14c480edb890f5bb66e19b22dd5342ac
parent478c22d47c125e789a22ef8cf05c3117288a0cdd (diff)
downloadtk-468bf9b8df08c68927e81183d6ece4c3a91c2887.zip
tk-468bf9b8df08c68927e81183d6ece4c3a91c2887.tar.gz
tk-468bf9b8df08c68927e81183d6ece4c3a91c2887.tar.bz2
Fix VisibilityNotify in XMapWindow.
-rw-r--r--macosx/tkMacOSXSubwindows.c25
-rw-r--r--tests/unixWm.test4
2 files changed, 19 insertions, 10 deletions
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 3da0492..2714de8 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -177,11 +177,11 @@ XMapWindow(
if (!Tk_IsEmbedded(winPtr)) {
/*
- * We want to activate Tk when a toplevel is mapped but we must not
- * supply YES here. This is because during Tk initialization the
- * root window is mapped before applicationDidFinishLaunching
- * returns. Forcing the app to activate too early can make the menu
- * bar unresponsive.
+ * We want to activate Tk when a toplevel is mapped but we can't
+ * always specify activateIgnoringOtherApps to be YES. This is
+ * because during Tk initialization the root window is mapped
+ * before applicationDidFinishLaunching returns. Forcing the app to
+ * activate too early can make the menu bar unresponsive.
*/
TkMacOSXApplyWindowAttributes(winPtr, win);
@@ -190,8 +190,19 @@ XMapWindow(
if (initialized) {
if ([win canBecomeKeyWindow]) {
[win makeKeyAndOrderFront:NSApp];
- } else {
- [win orderFrontRegardless];
+ }
+
+ /*
+ * Delay for up to 20 milliseconds until the toplevel has actually become the
+ * highest toplevel. This is to ensure that the Visibility event occurs after
+ * the toplevel is visible.
+ */
+
+ for (int count = 0; count < 20; count++) {
+ if ([[NSApp orderedWindows] firstObject] == win) {
+ break;
+ }
+ [NSThread sleepForTimeInterval:.001];
}
}
diff --git a/tests/unixWm.test b/tests/unixWm.test
index e3b5029..4a88fd1 100644
--- a/tests/unixWm.test
+++ b/tests/unixWm.test
@@ -1976,7 +1976,6 @@ test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} {unix failsOnUb
tkwait visibility .t2
wm geometry .t2 +20+20
update
- after 300;# needed for macOS
set result [list [winfo containing 120 120]]
destroy .t2
update
@@ -2069,7 +2068,6 @@ test unixWm-51.7 {TkWmRestackToplevel procedure, other window isn't mapped} {uni
update
toplevel $w -width 200 -height 200 -bg green
tkwait visibility $w
- after 300;# needed for macOS
wm geometry $w +100+100
update
}
@@ -2117,8 +2115,8 @@ test unixWm-51.9 {TkWmRestackToplevel procedure, other window overrideredirect}
update
toplevel $w -width 200 -height 200 -bg green
wm overrideredirect $w 1
- wm geometry $w +0+0
tkwait visibility $w
+ wm geometry $w +0+0
update
}
lower .t3 .t2