summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2002-06-24 20:34:40 (GMT)
committermdejong <mdejong>2002-06-24 20:34:40 (GMT)
commitb2d10e52b29a853f6617b873da1152ac86f25d98 (patch)
treec3ddfdff422760f0f504dc54ece65afb4b22f916
parent5301e3774409c2ecde99877add0448e84c972c93 (diff)
downloadtk-b2d10e52b29a853f6617b873da1152ac86f25d98.zip
tk-b2d10e52b29a853f6617b873da1152ac86f25d98.tar.gz
tk-b2d10e52b29a853f6617b873da1152ac86f25d98.tar.bz2
* tests/winWm.test: Verify that both an unmapped
and already mapped toplevel are raised and receive the focus when deiconified. * 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]
-rw-r--r--ChangeLog21
-rw-r--r--tests/winWm.test26
-rw-r--r--tests/wm.test58
-rw-r--r--win/tkWinWm.c16
4 files changed, 116 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e82f7e..b922471 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2002-06-24 Mo DeJong <mdejong@users.sourceforge.net>
+
+ * tests/winWm.test: Verify that both an unmapped
+ and already mapped toplevel are raised and receive
+ the focus when deiconified.
+ * 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]
+
2002-06-23 Jeff Hobbs <jeffh@ActiveState.com>
* win/tkWinWm.c (UpdateGeometryInfo): remove the check for a null
diff --git a/tests/winWm.test b/tests/winWm.test
index 72f5919..bc4a220 100644
--- a/tests/winWm.test
+++ b/tests/winWm.test
@@ -9,7 +9,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: winWm.test,v 1.5 2002/06/22 10:13:26 hobbs Exp $
+# RCS: @(#) $Id: winWm.test,v 1.6 2002/06/24 20:34:40 mdejong Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
@@ -248,6 +248,30 @@ test winWm-6.3 {wm attributes} {pcOnly} {
destroy .t
+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
diff --git a/tests/wm.test b/tests/wm.test
index d859fa6..bc1bd1a 100644
--- a/tests/wm.test
+++ b/tests/wm.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: wm.test,v 1.12 2002/06/24 02:17:57 mdejong Exp $
+# RCS: @(#) $Id: wm.test,v 1.13 2002/06/24 20:34:40 mdejong Exp $
# This file tests window manager interactions that work across
# platforms. Window manager tests that only work on a specific
@@ -744,6 +744,62 @@ test wm-minsize-1.6 {usage} {
} {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
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 58c4c3d..b9ae2bd 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.45 2002/06/24 05:31:35 hobbs Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.46 2002/06/24 20:34:40 mdejong Exp $
*/
#include "tkWinInt.h"
@@ -2436,11 +2436,12 @@ Tk_WmCmd(clientData, interp, argc, argv)
/*
* 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);
}
@@ -2456,6 +2457,15 @@ Tk_WmCmd(clientData, interp, argc, argv)
}
/*
+ * 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;
+ }
+
+ /*
* Follow Windows-like style here, raising the window to the top.
*/
TkWmRestackToplevel(winPtr, Above, NULL);