From 8355f067aeedc09f978725b0c5956924ac3542bc Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jul 2020 20:52:47 +0000 Subject: Fix issues with mapping and unmapping windows revealed by tests on Yosemite. --- macosx/tkMacOSXSubwindows.c | 2 ++ macosx/tkMacOSXWindowEvent.c | 3 +-- macosx/tkMacOSXWm.c | 14 +++----------- tests/pack.test | 19 +++++++++++-------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 8bae8fd..030830d 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -206,6 +206,7 @@ XMapWindow( event.xmap.event = window; event.xmap.override_redirect = winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} } else { /* @@ -316,6 +317,7 @@ XUnmapWindow( event.xunmap.event = window; event.xunmap.from_configure = false; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} } else { /* * Rebuild the visRgn clip region for the parent so it will be allowed diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5f52ea7..3f0e52f 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -117,8 +117,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * Process all Tk events generated by Tk_MapWindow(). */ - while (Tcl_ServiceEvent(0)) {} - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} /* * NSWindowDidDeminiaturizeNotification is received after diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index dca8686..abaf152 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1807,7 +1807,6 @@ WmDeiconifyCmd( Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an icon for %s", @@ -6422,16 +6421,9 @@ TkpWmSetState( Tk_UnmapWindow((Tk_Window) winPtr); } else if (state == NormalState || state == ZoomState) { Tk_MapWindow((Tk_Window) winPtr); - if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask)) { - if ([macWin isMiniaturized]) { - [macWin deminiaturize:NSApp]; - } - else { - [macWin orderFront:nil]; - } - } - TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : - inZoomOut); + [macWin deminiaturize:NSApp]; + [macWin orderFront:NSApp]; + TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut); } } diff --git a/tests/pack.test b/tests/pack.test index b1c22c7..04e84b9 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1554,6 +1554,7 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { tempNotPc } -setup { eval destroy [winfo child .pack] + update idletasks } -body { # adjust the position of .pack before test to avoid a screen switch @@ -1561,25 +1562,27 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { # as the screen (screen switch causes scale and other tests to fail). wm geometry .pack +100+100 + update idletasks # On the PC, when the width/height is configured while the window is # unmapped, the changes don't take effect until the window is remapped. # Who knows why? eval destroy [winfo child .pack] + update idletasks frame .pack.a -width 100 -height 50 -relief raised -bd 2 pack .pack.a - update + update idletasks set result [winfo ismapped .pack.a] wm iconify .pack - update + update idletasks lappend result [winfo ismapped .pack.a] .pack.a configure -width 200 -height 75 - update + update idletasks lappend result [winfo width .pack.a ] [winfo height .pack.a] \ [winfo ismapped .pack.a] wm deiconify .pack - update + update idletasks lappend result [winfo ismapped .pack.a] } -result {1 0 200 75 0 1} test pack-18.2 {unmap slaves when master unmapped} -setup { @@ -1595,17 +1598,17 @@ test pack-18.2 {unmap slaves when master unmapped} -setup { frame .pack.b -width 70 -height 30 -relief sunken -bd 2 pack .pack.a pack .pack.b -in .pack.a - update + update idletasks set result [winfo ismapped .pack.b] wm iconify .pack - update + update idletasks lappend result [winfo ismapped .pack.b] .pack.b configure -width 100 -height 30 - update + update idletasks lappend result [winfo width .pack.b ] [winfo height .pack.b] \ [winfo ismapped .pack.b] wm deiconify .pack - update + update idletasks lappend result [winfo ismapped .pack.b] } -result {1 0 100 30 0 1} -- cgit v0.12