Tk Source Code

Artifact [5376bf90]
Login

Artifact 5376bf9026721bd83aa045bcfb574aea3a8502bb:

Attachment "toplevel_map.patch2" to ticket [233150ff] added by mdejong 2002-06-14 15:27:56.
2002-06-13  Mo DeJong  <[email protected]>

	* tests/wm.test: Add wm deiconify tests. Check that
	a toplevel that has never been mapped is not mapped
	by the deiconify command since it should be done
	at idle by MapFrame.
	* win/tkWinWm.c (Tk_WmCmd): Check the WM_NEVER_MAPPED
	flag while processing the wm deiconify command.
	The WM_UPDATE_PENDING flag should never be set when
	WM_NEVER_MAPPED is set, but double check so that
	the implementation is more explicit and matches
	the comment just above.
	Return without invoking TkWmRestackToplevel or
	TkSetFocusWin on a toplevel that has never been
	mapped. This fixes a bug where a toplevel is mapped
	with the wrong size and is then resized by the
	idle call to MapFrame. [Tk bug 233150]

Index: tests/winWm.test
===================================================================
RCS file: /cvsroot/tktoolkit/tk/tests/winWm.test,v
retrieving revision 1.4
diff -u -r1.4 winWm.test
--- tests/winWm.test	12 Jan 2000 11:45:36 -0000	1.4
+++ tests/winWm.test	14 Jun 2002 07:28:08 -0000
@@ -229,6 +229,30 @@
     set result
 } {50 50 0}
 
+test winWm-6.1 {deiconify on an unmapped toplevel
+        will raise the window and set the focus} {pcOnly} {
+    destroy .t
+    toplevel .t
+    lower .t
+    focus -force .
+    wm deiconify .t
+    update
+    list [wm stackorder .t isabove .] [focus]
+} {1 .t}
+
+test winWm-6.2 {deiconify on an already mapped toplevel
+        will raise the window and set the focus} {pcOnly} {
+    destroy .t
+    toplevel .t
+    lower .t
+    update
+    focus -force .
+    wm deiconify .t
+    update
+    list [wm stackorder .t isabove .] [focus]
+} {1 .t}
+
+
 # cleanup
 ::tcltest::cleanupTests
 return
Index: tests/wm.test
===================================================================
RCS file: /cvsroot/tktoolkit/tk/tests/wm.test,v
retrieving revision 1.10
diff -u -r1.10 wm.test
--- tests/wm.test	13 Jun 2002 21:35:09 -0000	1.10
+++ tests/wm.test	14 Jun 2002 07:28:08 -0000
@@ -709,6 +709,62 @@
 } {200 150}
 
 
+test wm-deiconify-1.1 {usage} {
+    list [catch {wm deiconify} err] $err
+} {1 {wrong # args: should be "wm option window ?arg ...?"}}
+
+test wm-deiconify-1.2 {usage} {
+    list [catch {wm deiconify . _} err] $err
+} {1 {wrong # arguments: must be "wm deiconify window"}}
+
+test wm-deiconify-1.3 {usage} {
+    list [catch {wm deiconify _} err] $err
+} {1 {bad window path name "_"}}
+
+test wm-deiconify-2.1 {a window that has never been mapped
+        should not be mapped by a call to deiconify} {
+    deleteWindows
+    toplevel .t
+    wm deiconify .t
+    winfo ismapped .t
+} 0
+
+test wm-deiconify-2.2 {a window that has already been
+        mapped should be mapped by deiconify} {
+    deleteWindows
+    toplevel .t
+    update idletasks
+    wm withdraw .t
+    wm deiconify .t
+    winfo ismapped .t
+} 1
+
+test wm-deiconify-2.3 {geometry for an unmapped window
+        should not be calculated by a call to deiconify,
+        it should be done at idle time} {
+    deleteWindows
+    set results {}
+    toplevel .t -width 200 -height 200
+    lappend results [wm geometry .t]
+    wm deiconify .t
+    lappend results [wm geometry .t]
+    update idletasks
+    lappend results [lindex [split \
+        [wm geometry .t] +] 0]
+} {1x1+0+0 1x1+0+0 200x200}
+
+test wm-deiconify-2.4 {invoking destroy after a deiconify
+        should not result in a crash because of a callback
+        set on the toplevel} {
+    deleteWindows
+    toplevel .t
+    wm withdraw .t
+    wm deiconify .t
+    destroy .t
+    update
+} {}
+
+
 # FIXME:
 
 # Test delivery of virtual events to the WM. We could check to see
Index: win/tkWinWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinWm.c,v
retrieving revision 1.39
diff -u -r1.39 tkWinWm.c
--- win/tkWinWm.c	12 Jun 2002 19:02:50 -0000	1.39
+++ win/tkWinWm.c	14 Jun 2002 07:28:11 -0000
@@ -2349,11 +2349,12 @@
         }
 	/*
 	 * If WM_UPDATE_PENDING is true, a pending UpdateGeometryInfo may
-	 * need to be called first to update a withdrew toplevel's geometry
+	 * need to be called first to update a withdrawn toplevel's geometry
 	 * before it is deiconified by TkpWmSetState.
 	 * Don't bother if we've never been mapped.
 	 */
-	if ((wmPtr->flags & WM_UPDATE_PENDING)) {
+	if ((wmPtr->flags & WM_UPDATE_PENDING) &&
+	        !(wmPtr->flags & WM_NEVER_MAPPED)) {
 	    Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
 	    UpdateGeometryInfo((ClientData) winPtr);
 	}
@@ -2366,6 +2367,15 @@
 	    TkpWmSetState(winPtr, ZoomState);
 	} else {
 	    TkpWmSetState(winPtr, NormalState);
+	}
+
+	/*
+	 * An unmapped window will be mapped at idle time
+	 * by a call to MapFrame. That calls CreateWrapper
+	 * which sets the focus and raises the window.
+	 */
+	if (wmPtr->flags & WM_NEVER_MAPPED) {
+	    return TCL_OK;
 	}
 
 	/*