From 78fd58a9d168a501537ed45e4e29229b430a8846 Mon Sep 17 00:00:00 2001 From: hobbs Date: Wed, 12 Jan 2000 11:45:33 +0000 Subject: * tests/winWm.test: * tests/unixWm.test: * mac/tkMacWm.c: * unix/tkUnixWm.c: fixed possible X error being raised [Bug: 3377] * win/tkWinWm.c: wm deiconify in zoom state [Bug: 2077], fixed possible flashing of unmapped toplevel in deiconify [Bug: 3338] and fixed mapping of transient window [Bug: 572] Also, for all wm's, extended 'wm state' command to allow setting of the state, and added official support of 'zoomed' state on Win. --- mac/tkMacWm.c | 115 ++++++++++++++++++++++++++++++++++++++++-------------- tests/unixWm.test | 24 +++++++++++- tests/winWm.test | 22 +++++++++-- 3 files changed, 126 insertions(+), 35 deletions(-) diff --git a/mac/tkMacWm.c b/mac/tkMacWm.c index 77237d5..1a21c3e 100644 --- a/mac/tkMacWm.c +++ b/mac/tkMacWm.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: tkMacWm.c,v 1.7 1999/05/22 06:35:34 jingham Exp $ + * RCS: @(#) $Id: tkMacWm.c,v 1.8 2000/01/12 11:45:33 hobbs Exp $ */ #include @@ -1342,7 +1342,7 @@ Tk_WmCmd( goto updateGeom; } else if ((c == 'o') && (strncmp(argv[1], "overrideredirect", length) == 0)) { - int boolean; + int boolean, curValue; XSetWindowAttributes atts; if ((argc != 3) && (argc != 4)) { @@ -1351,21 +1351,23 @@ Tk_WmCmd( (char *) NULL); return TCL_ERROR; } + curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect; if (argc == 3) { - if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { - Tcl_SetResult(interp, "1", TCL_STATIC); - } else { - Tcl_SetResult(interp, "0", TCL_STATIC); - } + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), curValue); return TCL_OK; } if (Tcl_GetBoolean(interp, argv[3], &boolean) != TCL_OK) { return TCL_ERROR; } - atts.override_redirect = (boolean) ? True : False; - Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, - &atts); - wmPtr->style = (boolean) ? plainDBox : documentProc; + if (curValue != boolean) { + /* + * Only do this if we are really changing value + */ + atts.override_redirect = (boolean) ? True : False; + Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, + &atts); + wmPtr->style = (boolean) ? plainDBox : documentProc; + } } else if ((c == 'p') && (strncmp(argv[1], "positionfrom", length) == 0) && (length >= 2)) { if ((argc != 3) && (argc != 4)) { @@ -1543,27 +1545,80 @@ Tk_WmCmd( goto updateGeom; } else if ((c == 's') && (strncmp(argv[1], "state", length) == 0) && (length >= 2)) { - if (argc != 3) { + if ((argc < 3) || (argc > 4)) { Tcl_AppendResult(interp, "wrong # arguments: must be \"", - argv[0], " state window\"", (char *) NULL); + argv[0], " state window ?state?\"", (char *) NULL); return TCL_ERROR; } - if (wmPtr->iconFor != NULL) { - Tcl_SetResult(interp, "icon", TCL_STATIC); + if (argc == 4) { + if (wmPtr->iconFor != NULL) { + Tcl_AppendResult(interp, "can't change state of ", argv[2], + ": it is an icon for ", Tk_PathName(wmPtr->iconFor), + (char *) NULL); + return TCL_ERROR; + } + if (winPtr->flags & TK_EMBEDDED) { + Tcl_AppendResult(interp, "can't change state of ", + winPtr->pathName, ": it is an embedded window", + (char *) NULL); + return TCL_ERROR; + } + + c = argv[3][0]; + length = strlen(argv[3]); + + if ((c == 'n') && (strncmp(argv[3], "normal", length) == 0)) { + TkpWmSetState(winPtr, NormalState); + /* + * This varies from 'wm deiconify' because it does not + * force the window to be raised and receive focus + */ + } else if ((c == 'i') + && (strncmp(argv[3], "iconic", length) == 0)) { + if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { + Tcl_AppendResult(interp, "can't iconify \"", + winPtr->pathName, + "\": override-redirect flag is set", + (char *) NULL); + return TCL_ERROR; + } + if (wmPtr->masterPtr != NULL) { + Tcl_AppendResult(interp, "can't iconify \"", + winPtr->pathName, + "\": it is a transient", (char *) NULL); + return TCL_ERROR; + } + TkpWmSetState(winPtr, IconicState); + } else if ((c == 'w') + && (strncmp(argv[3], "withdrawn", length) == 0)) { + TkpWmSetState(winPtr, WithdrawnState); + } else if ((c == 'z') + && (strncmp(argv[3], "zoomed", length) == 0)) { + TkpWmSetState(winPtr, ZoomState); + } else { + Tcl_AppendResult(interp, "bad argument \"", argv[3], + "\": must be normal, iconic, withdrawn or zoomed", + (char *) NULL); + return TCL_ERROR; + } } else { - switch (wmPtr->hints.initial_state) { - case NormalState: - Tcl_SetResult(interp, "normal", TCL_STATIC); - break; - case IconicState: - Tcl_SetResult(interp, "iconic", TCL_STATIC); - break; - case WithdrawnState: - Tcl_SetResult(interp, "withdrawn", TCL_STATIC); - break; - case ZoomState: - Tcl_SetResult(interp, "zoomed", TCL_STATIC); - break; + if (wmPtr->iconFor != NULL) { + Tcl_SetResult(interp, "icon", TCL_STATIC); + } else { + switch (wmPtr->hints.initial_state) { + case NormalState: + Tcl_SetResult(interp, "normal", TCL_STATIC); + break; + case IconicState: + Tcl_SetResult(interp, "iconic", TCL_STATIC); + break; + case WithdrawnState: + Tcl_SetResult(interp, "withdrawn", TCL_STATIC); + break; + case ZoomState: + Tcl_SetResult(interp, "zoomed", TCL_STATIC); + break; + } } } } else if ((c == 't') && (strncmp(argv[1], "title", length) == 0) @@ -4209,8 +4264,8 @@ TkpWmSetState(winPtr, state) if (TkMacHaveAppearance()) { /* * The window always gets unmapped. However, if we can show the - * icon version of the window (collapsed) we make the window visable - * and then collapse it. + * icon version of the window (collapsed) we make the window + * visible and then collapse it. * * TODO: This approach causes flashing! */ diff --git a/tests/unixWm.test b/tests/unixWm.test index 967e3ff..b9af65a 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -7,7 +7,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: unixWm.test,v 1.10 1999/12/22 20:01:19 hobbs Exp $ +# RCS: @(#) $Id: unixWm.test,v 1.11 2000/01/12 11:45:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -1186,8 +1186,11 @@ test unixWm-34.3 {Tk_WmCmd procedure, "sizefrom" option} { test unixWm-35.1 {Tk_WmCmd procedure, "state" option} { list [catch {wm state .t 1} msg] $msg -} {1 {wrong # arguments: must be "wm state window"}} +} {1 {bad argument "1": must be normal, iconic or withdrawn}} test unixWm-35.2 {Tk_WmCmd procedure, "state" option} { + list [catch {wm state .t iconic 1} msg] $msg +} {1 {wrong # arguments: must be "wm state window ?state?"}} +test unixWm-35.3 {Tk_WmCmd procedure, "state" option} { set result {} catch {destroy .t2} toplevel .t2 -width 120 -height 300 @@ -1204,6 +1207,23 @@ test unixWm-35.2 {Tk_WmCmd procedure, "state" option} { destroy .t2 set result } {normal normal withdrawn iconic normal} +test unixWm-35.4 {Tk_WmCmd procedure, "state" option} { + set result {} + catch {destroy .t2} + toplevel .t2 -width 120 -height 300 + wm geometry .t2 +0+0 + lappend result [wm state .t2] + update + lappend result [wm state .t2] + wm state .t2 withdrawn + lappend result [wm state .t2] + wm state .t2 iconic + lappend result [wm state .t2] + wm state .t2 normal + lappend result [wm state .t2] + destroy .t2 + set result +} {normal normal withdrawn iconic normal} test unixWm-36.1 {Tk_WmCmd procedure, "title" option} { list [catch {wm title .t 1 2} msg] $msg diff --git a/tests/winWm.test b/tests/winWm.test index e4275fe..e9c86c1 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.3 1999/04/16 01:51:44 stanton Exp $ +# RCS: @(#) $Id: winWm.test,v 1.4 2000/01/12 11:45:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -117,7 +117,24 @@ test winWm-2.2 {TkpWmSetState} {pcOnly} { destroy .t set result } {normal withdrawn iconic normal} -test winWm-2.3 {TkpWmSetState} {pcOnly} { +test winWm-2.2 {TkpWmSetState} {pcOnly} { + toplevel .t + wm geometry .t 150x50+10+10 + update + set result [wm state .t] + wm state .t withdrawn + update + lappend result [wm state .t] + wm state .t iconic + update + lappend result [wm state .t] + wm state .t normal + update + lappend result [wm state .t] + destroy .t + set result +} {normal withdrawn iconic normal} +test winWm-2.4 {TkpWmSetState} {pcOnly} { set result {} toplevel .t wm geometry .t 150x50+10+10 @@ -136,7 +153,6 @@ test winWm-2.3 {TkpWmSetState} {pcOnly} { set result } {{normal 150x50+10+10} {iconic 150x50+10+10} {iconic 150x50+10+10} {normal 200x50+10+10}} - test winWm-3.1 {ConfigureTopLevel: window geometry propagation} {pcOnly} { toplevel .t wm geometry .t +0+0 -- cgit v0.12