summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2002-05-27 22:54:42 (GMT)
committermdejong <mdejong>2002-05-27 22:54:42 (GMT)
commit972e97ee22e87ef707a976111cddbfe80b4737fc (patch)
tree4df8b5fe8d050ea301707b1a94f1f4fd55265556
parent1c823cfbaafe492b3bd9a506d782804f797bcc2e (diff)
downloadtk-972e97ee22e87ef707a976111cddbfe80b4737fc.zip
tk-972e97ee22e87ef707a976111cddbfe80b4737fc.tar.gz
tk-972e97ee22e87ef707a976111cddbfe80b4737fc.tar.bz2
* changes: Document [wm transient .t .t] error.
* tests/wm.test: Check that setting a window as a transient of itself raises an error. Check that passing a non-toplevel window to the wm transient command uses the enclosing toplevel. * unix/tkUnixWm.c (Tk_WmCmd): Raise an error if the user tries to make a toplevel a transient of itself. * win/tkWinWm.c (Tk_WmCmd): Raise an error if the user tries to make a toplevel a transient of itself. Test for other error before checking for the transient self error.
-rw-r--r--ChangeLog15
-rw-r--r--changes4
-rw-r--r--tests/wm.test38
-rw-r--r--unix/tkUnixWm.c11
-rw-r--r--win/tkWinWm.c56
5 files changed, 93 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index ae6852b..0893bf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2002-05-27 Mo DeJong <mdejong@users.sourceforge.net>
+ * changes: Document [wm transient .t .t] error.
+ * tests/wm.test: Check that setting a window
+ as a transient of itself raises an error. Check
+ that passing a non-toplevel window to the wm
+ transient command uses the enclosing toplevel.
+ * unix/tkUnixWm.c (Tk_WmCmd): Raise an error
+ if the user tries to make a toplevel a
+ transient of itself.
+ * win/tkWinWm.c (Tk_WmCmd): Raise an error
+ if the user tries to make a toplevel a
+ transient of itself. Test for other error
+ before checking for the transient self error.
+
+2002-05-27 Mo DeJong <mdejong@users.sourceforge.net>
+
* unix/tkUnixWm.c (WmInfo, TkWmCleanup, TkWmNewWindow,
TkWmMapWindow, TkWmDeadWindow, Tk_WmCmd): Replace
WmInfo's master and masterWindowName members with
diff --git a/changes b/changes
index cec42c5..28f17ba 100644
--- a/changes
+++ b/changes
@@ -2,7 +2,7 @@ This file summarizes all changes made to Tk since version 1.0 was
released on March 13, 1991. Changes that aren't backward compatible
are marked specially.
-RCS: @(#) $Id: changes,v 1.51 2002/03/04 23:34:09 hobbs Exp $
+RCS: @(#) $Id: changes,v 1.52 2002/05/27 22:54:42 mdejong Exp $
3/16/91 (bug fix) Modified tkWindow.c to remove Tk's Tcl commands from
the interpreter when the main window is deleted (otherwise there will
@@ -5183,3 +5183,5 @@ address TIP 72 changes (64-bit) in Tcl (fellows)
* (updated demos) many updates to show new features (fellows)
--- Released 8.4a4, March 5, 2002 --- See ChangeLog for details ---
+
+2002-05-27 (feature change) [wm transient .t .t] now raises an error
diff --git a/tests/wm.test b/tests/wm.test
index 025dd24..14cce6b 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.7 2002/05/27 19:49:33 mdejong Exp $
+# RCS: @(#) $Id: wm.test,v 1.8 2002/05/27 22:54:42 mdejong Exp $
# This file tests window manager interactions that work across
# platforms. Window manager tests that only work on a specific
@@ -345,6 +345,42 @@ test wm-transient-1.6 {usage} {
list [catch {wm transient .dummy .icon} msg] $msg
} {1 {can't make ".icon" a master: it is an icon for .top}}
+test wm-transient-1.7 {usage} {
+ deleteWindows
+ toplevel .master
+ list [catch {wm transient .master .master} err] $err
+} {1 {can't make ".master" its own master}}
+
+test wm-transient-1.8 {usage} {
+ deleteWindows
+ toplevel .master
+ frame .master.f
+ list [catch {wm transient .master .master.f} err] $err
+} {1 {can't make ".master" its own master}}
+
+test wm-transient-2.1 { basic get/set of master } {
+ deleteWindows
+ set results [list]
+ toplevel .master
+ toplevel .subject
+ lappend results [wm transient .subject]
+ wm transient .subject .master
+ lappend results [wm transient .subject]
+ wm transient .subject {}
+ lappend results [wm transient .subject]
+ set results
+} {{} .master {}}
+
+test wm-transient-2.2 { first toplevel parent of
+ non-toplevel master is used } {
+ deleteWindows
+ toplevel .master
+ frame .master.f
+ toplevel .subject
+ wm transient .subject .master.f
+ wm transient .subject
+} {.master}
+
test wm-state-1.1 {usage} {
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 458c80f..50bd41a 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.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: tkUnixWm.c,v 1.19 2002/05/27 20:34:32 mdejong Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.20 2002/05/27 22:54:42 mdejong Exp $
*/
#include "tkPort.h"
@@ -2014,7 +2014,14 @@ Tk_WmCmd(clientData, interp, argc, argv)
return TCL_ERROR;
}
- wmPtr->masterPtr = masterPtr;
+ if (masterPtr == winPtr) {
+ Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr),
+ "\" its own master",
+ (char *) NULL);
+ return TCL_ERROR;
+ } else if (masterPtr != wmPtr->masterPtr) {
+ wmPtr->masterPtr = masterPtr;
+ }
}
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
Window xwin = (wmPtr->masterPtr == NULL) ? None :
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 046a931..207dc4f 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.37 2002/05/24 09:50:11 mdejong Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.38 2002/05/27 22:54:42 mdejong Exp $
*/
#include "tkWinInt.h"
@@ -3291,37 +3291,39 @@ Tk_WmCmd(clientData, interp, argc, argv)
if (masterPtr == NULL) {
return TCL_ERROR;
}
- if (masterPtr == winPtr) {
- wmPtr->masterPtr = NULL;
- } else if (masterPtr != wmPtr->masterPtr) {
- Tk_MakeWindowExist((Tk_Window)masterPtr);
-
- /*
- * Ensure that the master window is actually a Tk toplevel.
- */
+ while (!(masterPtr->flags & TK_TOP_LEVEL)) {
+ /*
+ * Ensure that the master window is actually a Tk toplevel.
+ */
- while (!(masterPtr->flags & TK_TOP_LEVEL)) {
- masterPtr = masterPtr->parentPtr;
- }
+ masterPtr = masterPtr->parentPtr;
+ }
+ Tk_MakeWindowExist((Tk_Window)masterPtr);
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", argv[2],
- "\" a transient: it is an icon for ",
- Tk_PathName(wmPtr->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
+ if (wmPtr->iconFor != NULL) {
+ Tcl_AppendResult(interp, "can't make \"", argv[2],
+ "\" a transient: it is an icon for ",
+ Tk_PathName(wmPtr->iconFor),
+ (char *) NULL);
+ return TCL_ERROR;
+ }
- wmPtr2 = masterPtr->wmInfoPtr;
+ wmPtr2 = masterPtr->wmInfoPtr;
- if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", argv[3],
- "\" a master: it is an icon for ",
- Tk_PathName(wmPtr2->iconFor),
- (char *) NULL);
- return TCL_ERROR;
- }
+ if (wmPtr2->iconFor != NULL) {
+ Tcl_AppendResult(interp, "can't make \"", argv[3],
+ "\" a master: it is an icon for ",
+ Tk_PathName(wmPtr2->iconFor),
+ (char *) NULL);
+ return TCL_ERROR;
+ }
+ if (masterPtr == winPtr) {
+ Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr),
+ "\" its own master",
+ (char *) NULL);
+ return TCL_ERROR;
+ } else if (masterPtr != wmPtr->masterPtr) {
wmPtr->masterPtr = masterPtr;
masterPtr->wmInfoPtr->numTransients++;