summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatthoyts@users.sourceforge.net <patthoyts>2008-11-15 00:37:30 (GMT)
committerpatthoyts@users.sourceforge.net <patthoyts>2008-11-15 00:37:30 (GMT)
commitd39b78bac5cdef9af2bcb3f14b6ea23309df7500 (patch)
tree94a457439db11c45ad6ecdfc37d41d37f6d56919
parentc5677938ded79b8fd2d5a02a717ef16b9ec7ef9b (diff)
downloadtk-d39b78bac5cdef9af2bcb3f14b6ea23309df7500.zip
tk-d39b78bac5cdef9af2bcb3f14b6ea23309df7500.tar.gz
tk-d39b78bac5cdef9af2bcb3f14b6ea23309df7500.tar.bz2
[Bug 2239034] Only frame widgets are acceptable for [wm manage]
-rw-r--r--ChangeLog10
-rw-r--r--doc/wm.n8
-rw-r--r--generic/tk.h7
-rw-r--r--generic/tkFrame.c8
-rw-r--r--macosx/tkMacOSXWm.c8
-rw-r--r--tests/wm.test118
-rw-r--r--unix/tkUnixWm.c8
-rw-r--r--win/tkWinWm.c8
8 files changed, 153 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 2d3a317..7836bc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-11-15 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * generic/tk.h: The tip 125 implementation permits the
+ * generic/tkFrame.c: wm manage command to manage any widget but
+ * macosx/tkMacOSXWm.c: only those with Frame instance data should
+ * unix/tkUnixWm.c: be permitted. We now check for the suitability
+ * win/tkWinWm.c: and raise an error for non-frame widgets.
+ * test/wm.test: Updated the tests and documentation.
+ * doc/wm.n: See also [Bug 2239034]
+
2008-11-12 Pat Thoyts <patthoyts@users.sourceforge.net>
* tests/constraints.tcl: backported listbox test fix from head
diff --git a/doc/wm.n b/doc/wm.n
index f5ed460..db43309 100644
--- a/doc/wm.n
+++ b/doc/wm.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: wm.n,v 1.38 2007/12/13 15:23:44 dgp Exp $
+'\" RCS: @(#) $Id: wm.n,v 1.38.2.1 2008/11/15 00:37:30 patthoyts Exp $
'\"
.so man.macros
.TH wm n 8.5 Tk "Tk Built-In Commands"
@@ -417,7 +417,11 @@ Note: not all window managers support the notion of an icon window.
.TP
\fBwm manage \fIwidget\fR
The \fIwidget\fR specified will become a stand alone top-level window. The
-window will be decorated with the window managers title bar, etc.
+window will be decorated with the window managers title bar, etc. Only
+\fIframe\fR, \fIlabelframe\fR and \fItoplevel\fR widgets can be used
+with this command. Attempting to pass any other widget type will raise
+an error. Attempting to manage a \fItoplevel\fR widget is benign and
+achieves nothing. See also \fBGEOMETRY MANAGEMENT\fR.
.TP
\fBwm maxsize \fIwindow\fR ?\fIwidth height\fR?
If \fIwidth\fR and \fIheight\fR are specified, they give
diff --git a/generic/tk.h b/generic/tk.h
index 058e64b..37f3a35 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -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: tk.h,v 1.109.2.8 2008/10/23 16:30:57 dgp Exp $
+ * RCS: @(#) $Id: tk.h,v 1.109.2.9 2008/11/15 00:37:30 patthoyts Exp $
*/
#ifndef _TK
@@ -722,6 +722,8 @@ typedef XActivateDeactivateEvent XDeactivateEvent;
(((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED)
#define Tk_TopWinHierarchy(tkwin) \
(((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY)
+#define Tk_IsManageable(tkwin) \
+ (((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE)
#define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth)
#define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight)
/* Tk_InternalBorderWidth is deprecated */
@@ -857,6 +859,8 @@ typedef struct Tk_FakeWin {
* TK_PROP_PROPCHANGE 1 means that PropertyNotify events in the
* window's children should propagate up to this
* window.
+ * TK_WM_MANAGEABLE 1 marks a window as capable of being converted
+ * into a toplevel using [wm manage].
*/
#define TK_MAPPED 1
@@ -878,6 +882,7 @@ typedef struct Tk_FakeWin {
#define TK_WIN_MANAGED 0x10000
#define TK_TOP_HIERARCHY 0x20000
#define TK_PROP_PROPCHANGE 0x40000
+#define TK_WM_MANAGEABLE 0x80000
/*
*--------------------------------------------------------------
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index 372cbda..ddf0b5a 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkFrame.c,v 1.31 2007/12/13 15:24:14 dgp Exp $
+ * RCS: @(#) $Id: tkFrame.c,v 1.31.2.1 2008/11/15 00:37:30 patthoyts Exp $
*/
#include "default.h"
@@ -555,6 +555,12 @@ CreateFrame(
}
if (newWin == NULL) {
goto error;
+ } else {
+ /*
+ * Mark Tk frames as suitable candidates for [wm manage]
+ */
+ TkWindow *winPtr = (TkWindow *)newWin;
+ winPtr->flags |= TK_WM_MANAGEABLE;
}
if (className == NULL) {
className = Tk_GetOption(newWin, "class", "Class");
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 2a7d1a8..88e49fe 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXWm.c,v 1.63.2.1 2008/05/03 21:09:16 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.63.2.2 2008/11/15 00:37:30 patthoyts Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -2134,6 +2134,12 @@ WmManageCmd(
if (!Tk_IsTopLevel(frameWin)) {
MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ if (!Tk_IsManageable(frameWin)) {
+ Tcl_AppendResult(interp, "window \"",
+ Tk_PathName(frameWin), "\" is not manageable: must be "
+ "a frame, labelframe or toplevel", NULL);
+ return TCL_ERROR;
+ }
TkFocusSplit(winPtr);
Tk_UnmapWindow(frameWin);
if (wmPtr == NULL) {
diff --git a/tests/wm.test b/tests/wm.test
index 7e2e484..e6905ec 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.39.2.1 2008/08/01 20:24:48 patthoyts Exp $
+# RCS: @(#) $Id: wm.test,v 1.39.2.2 2008/11/15 00:37:30 patthoyts Exp $
# This file tests window manager interactions that work across platforms.
# Window manager tests that only work on a specific platform should be placed
@@ -2091,28 +2091,112 @@ test wm-deletion-epoch-1.1 {Deletion epoch on multiple displays} -constraints al
}
### Docking test (manage, forget) ###
-test wm-manage-1.1 {managing a button} -setup {
+test wm-manage-1.1 {managing a frame} -setup {
set result [list]
} -body {
toplevel .t
- button .t.b -text "Manage This"
- pack .t.b
+ frame .t.f
+ pack [label .t.f.l -text hello]
+ wm manage .t.f
+ raise .t.f
update
- lappend result [winfo manage .t.b]
- lappend result [winfo toplevel .t.b]
- wm manage .t.b
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+} -cleanup {
+ deleteWindows
+} -result {wm .t.f}
+test wm-manage-1.2 {managing a toplevel} -setup {
+ set result [list]
+} -body {
+ toplevel .t
+ pack [label .t.l -text hello]
+ wm manage .t
+ raise .t
update
- lappend result [winfo manage .t.b]
- lappend result [winfo toplevel .t.b]
- wm forget .t.b
- pack .t.b
+ lappend result [winfo manage .t]
+ lappend result [winfo toplevel .t]
+} -cleanup {
+ deleteWindows
+} -result {wm .t}
+test wm-manage-1.3 {managing a labelframe} -setup {
+ set result [list]
+} -body {
+ toplevel .t
+ labelframe .t.f -text Labelframe
+ pack [label .t.f.l -text hello]
+ wm manage .t.f
+ raise .t.f
+ update
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+} -cleanup {
+ deleteWindows
+} -result {wm .t.f}
+test wm-manage-1.4 {managing a ttk::frame} -setup {
+ set result [list]
+} -body {
+ toplevel .t
+ ttk::frame .t.f
+ pack [label .t.f.l -text hello]
+ wm manage .t.f
+ raise .t.f
+ update
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+} -cleanup {
+ deleteWindows
+} -returnCodes error -result "window \".t.f\" is not manageable: must be a frame, labelframe or toplevel"
+test wm-manage-1.5 {managing a text widget} -setup {
+ set result [list]
+} -body {
+ toplevel .t
+ text .t.f
+ .t.f insert end "Manage text\n" {}
+ wm manage .t.f
+ raise .t.f
+ update
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+} -cleanup {
+ deleteWindows
+} -returnCodes error -result "window \".t.f\" is not manageable: must be a frame, labelframe or toplevel"
+test wm-manage-1.6 {managing a button} -setup {
+ set result [list]
+} -body {
+ toplevel .t
+ button .t.f -text Button
+ wm manage .t.f
+ raise .t.f
+ update
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+} -cleanup {
+ deleteWindows
+} -returnCodes error -result "window \".t.f\" is not manageable: must be a frame, labelframe or toplevel"
+test wm-manage-1.7 {managing a frame} -setup {
+ set result [list]
+} -body {
+ toplevel .t
+ frame .t.f
+ pack [label .t.f.l -text Label]
+ pack .t.f
+ update
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+ wm manage .t.f
+ raise .t.f
update
- lappend result [winfo manage .t.b]
- lappend result [winfo toplevel .t.b]
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
+ wm forget .t.f
+ pack .t.f
+ update
+ lappend result [winfo manage .t.f]
+ lappend result [winfo toplevel .t.f]
} -cleanup {
deleteWindows
-} -result {pack .t wm .t.b pack .t}
-test wm-manage-1.2 {unmanaging a toplevel} -setup {
+} -result {pack .t wm .t.f pack .t}
+test wm-manage-1.8 {unmanaging a toplevel} -setup {
set result [list]
} -body {
toplevel .t
@@ -2188,3 +2272,7 @@ cleanupTests
catch {unset results}
catch {unset focusin}
return
+
+# Local variables:
+# mode: tcl
+# End:
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index d8082ff..ec90e5c 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.58 2007/12/13 15:28:51 dgp Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.58.2.1 2008/11/15 00:37:30 patthoyts Exp $
*/
#include "tkUnixInt.h"
@@ -2661,6 +2661,12 @@ WmManageCmd(tkwin, winPtr, interp, objc, objv)
register WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!Tk_IsTopLevel(frameWin)) {
+ if (!Tk_IsManageable(frameWin)) {
+ Tcl_AppendResult(interp, "window \"",
+ Tk_PathName(frameWin), "\" is not manageable: must be "
+ "a frame, labelframe or toplevel", NULL);
+ return TCL_ERROR;
+ }
TkFocusSplit(winPtr);
Tk_UnmapWindow(frameWin);
winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 4f891ee..007b35c 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.124.2.1 2008/08/01 20:24:50 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.124.2.2 2008/11/15 00:37:30 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -4602,6 +4602,12 @@ WmManageCmd(tkwin, winPtr, interp, objc, objv)
register WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!Tk_IsTopLevel(frameWin)) {
+ if (!Tk_IsManageable(frameWin)) {
+ Tcl_AppendResult(interp, "window \"",
+ Tk_PathName(frameWin), "\" is not manageable: must be "
+ "a frame, labelframe or toplevel", NULL);
+ return TCL_ERROR;
+ }
TkFocusSplit(winPtr);
Tk_UnmapWindow(frameWin);
winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED;