summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2002-05-27 19:49:32 (GMT)
committermdejong <mdejong>2002-05-27 19:49:32 (GMT)
commit6a4f24b098eed70f278a40916100f278bc7cf28a (patch)
treec8d844d5c5f3ed027f756101f23a272695a9befb
parentf2ec5d37bb3e769fe75dd9a0ebd90ed8e5799864 (diff)
downloadtk-6a4f24b098eed70f278a40916100f278bc7cf28a.zip
tk-6a4f24b098eed70f278a40916100f278bc7cf28a.tar.gz
tk-6a4f24b098eed70f278a40916100f278bc7cf28a.tar.bz2
* generic/tkInt.decls: Add unix decl for TkpWmSetState.
* generic/tkIntPlatDecls.h: Regen. * generic/tkStubInit.c: Regen. * tests/wm.test: Test state changes between iconic, normal, and withdrawn both before and after initial mapping. * unix/tkUnixWm.c (Tk_WmCmd, TkpWmSetState): Move state change code into TkpWmSetState to more closely match the Win32 implementation. No functional changes.
-rw-r--r--ChangeLog12
-rw-r--r--generic/tkInt.decls6
-rw-r--r--generic/tkIntPlatDecls.h10
-rw-r--r--generic/tkStubInit.c3
-rw-r--r--tests/wm.test146
-rw-r--r--unix/tkUnixWm.c144
6 files changed, 253 insertions, 68 deletions
diff --git a/ChangeLog b/ChangeLog
index f1c1e06..744562b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2002-05-27 Mo DeJong <mdejong@users.sourceforge.net>
+ * generic/tkInt.decls: Add unix decl for TkpWmSetState.
+ * generic/tkIntPlatDecls.h: Regen.
+ * generic/tkStubInit.c: Regen.
+ * tests/wm.test: Test state changes between iconic,
+ normal, and withdrawn both before and after initial
+ mapping.
+ * unix/tkUnixWm.c (Tk_WmCmd, TkpWmSetState): Move
+ state change code into TkpWmSetState to more closely
+ match the Win32 implementation.
+
+2002-05-27 Mo DeJong <mdejong@users.sourceforge.net>
+
* tests/embed.test: Added cross platform embed tests.
Check that window passed to -use has the -container
option set.
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index c874a26..64ea04b 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -9,7 +9,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tkInt.decls,v 1.25 2002/04/12 10:10:48 hobbs Exp $
+# RCS: @(#) $Id: tkInt.decls,v 1.26 2002/05/27 19:49:32 mdejong Exp $
library tk
@@ -715,6 +715,10 @@ declare 11 unix {
void TkFreeXId (TkDisplay *dispPtr)
}
+declare 12 unix {
+ int TkpWmSetState (TkWindow *winPtr, int state)
+}
+
############################
# Windows specific functions
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index 411fc0c..07e4e9b 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -9,7 +9,7 @@
* Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.11 2002/04/12 10:10:48 hobbs Exp $
+ * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.12 2002/05/27 19:49:32 mdejong Exp $
*/
#ifndef _TKINTPLATDECLS
@@ -61,6 +61,9 @@ EXTERN void TkWmCleanup _ANSI_ARGS_((TkDisplay * dispPtr));
EXTERN void TkSendCleanup _ANSI_ARGS_((TkDisplay * dispPtr));
/* 11 */
EXTERN void TkFreeXId _ANSI_ARGS_((TkDisplay * dispPtr));
+/* 12 */
+EXTERN int TkpWmSetState _ANSI_ARGS_((TkWindow * winPtr,
+ int state));
#endif /* UNIX */
#ifdef __WIN32__
/* 0 */
@@ -306,6 +309,7 @@ typedef struct TkIntPlatStubs {
void (*tkWmCleanup) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 9 */
void (*tkSendCleanup) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 10 */
void (*tkFreeXId) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 11 */
+ int (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 12 */
#endif /* UNIX */
#ifdef __WIN32__
char * (*tkAlignImageData) _ANSI_ARGS_((XImage * image, int alignment, int bitOrder)); /* 0 */
@@ -477,6 +481,10 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr;
#define TkFreeXId \
(tkIntPlatStubsPtr->tkFreeXId) /* 11 */
#endif
+#ifndef TkpWmSetState
+#define TkpWmSetState \
+ (tkIntPlatStubsPtr->tkpWmSetState) /* 12 */
+#endif
#endif /* UNIX */
#ifdef __WIN32__
#ifndef TkAlignImageData
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index 848fe96..cebe2ad 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkStubInit.c,v 1.32 2002/04/12 10:10:48 hobbs Exp $
+ * RCS: @(#) $Id: tkStubInit.c,v 1.33 2002/05/27 19:49:32 mdejong Exp $
*/
#include "tkInt.h"
@@ -290,6 +290,7 @@ TkIntPlatStubs tkIntPlatStubs = {
TkWmCleanup, /* 9 */
TkSendCleanup, /* 10 */
TkFreeXId, /* 11 */
+ TkpWmSetState, /* 12 */
#endif /* UNIX */
#ifdef __WIN32__
TkAlignImageData, /* 0 */
diff --git a/tests/wm.test b/tests/wm.test
index 2dea668..025dd24 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.6 2002/05/27 17:33:26 mdejong Exp $
+# RCS: @(#) $Id: wm.test,v 1.7 2002/05/27 19:49:33 mdejong Exp $
# This file tests window manager interactions that work across
# platforms. Window manager tests that only work on a specific
@@ -346,6 +346,150 @@ test wm-transient-1.6 {usage} {
} {1 {can't make ".icon" a master: it is an icon for .top}}
+
+test wm-state-1.1 {usage} {
+ list [catch {wm state} err] $err
+} {1 {wrong # args: should be "wm option window ?arg ...?"}}
+
+test wm-state-1.2 {usage} {
+ list [catch {wm state . _ _} err] $err
+} {1 {wrong # arguments: must be "wm state window ?state?"}}
+
+test wm-state-2.1 {initial state} {
+ deleteWindows
+ toplevel .t
+ wm state .t
+} {normal}
+
+test wm-state-2.2 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm state .t withdrawn
+ wm state .t
+} {withdrawn}
+
+test wm-state-2.3 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm withdraw .t
+ wm state .t
+} {withdrawn}
+
+test wm-state-2.4 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm state .t withdrawn
+ wm state .t
+} {withdrawn}
+
+test wm-state-2.5 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm withdraw .t
+ wm state .t
+} {withdrawn}
+
+test wm-state-2.6 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm state .t iconic
+ wm state .t
+} {iconic}
+
+test wm-state-2.7 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm iconify .t
+ wm state .t
+} {iconic}
+
+test wm-state-2.8 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm state .t iconic
+ wm state .t
+} {iconic}
+
+test wm-state-2.9 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm iconify .t
+ wm state .t
+} {iconic}
+
+test wm-state-2.10 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm withdraw .t
+ wm state .t normal
+ wm state .t
+} {normal}
+
+test wm-state-2.11 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm withdraw .t
+ wm deiconify .t
+ wm state .t
+} {normal}
+
+test wm-state-2.12 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm withdraw .t
+ wm state .t normal
+ wm state .t
+} {normal}
+
+test wm-state-2.13 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm withdraw .t
+ wm deiconify .t
+ wm state .t
+} {normal}
+
+test wm-state-2.14 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm iconify .t
+ wm state .t normal
+ wm state .t
+} {normal}
+
+test wm-state-2.15 {state change before map} {
+ deleteWindows
+ toplevel .t
+ wm iconify .t
+ wm deiconify .t
+ wm state .t
+} {normal}
+
+test wm-state-2.16 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm iconify .t
+ wm state .t normal
+ wm state .t
+} {normal}
+
+test wm-state-2.17 {state change after map} {
+ deleteWindows
+ toplevel .t
+ update
+ wm iconify .t
+ wm deiconify .t
+ wm state .t
+} {normal}
+
+
# FIXME:
# Test delivery of virtual events to the WM. We could check to see
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index e9caba6..47c1e87 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.17 2002/05/24 09:50:11 mdejong Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.18 2002/05/27 19:49:33 mdejong Exp $
*/
#include "tkPort.h"
@@ -1089,13 +1089,7 @@ Tk_WmCmd(clientData, interp, argc, argv)
(char *) NULL);
return TCL_ERROR;
}
- wmPtr->hints.initial_state = NormalState;
- wmPtr->withdrawn = 0;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- return TCL_OK;
- }
- UpdateHints(winPtr);
- Tk_MapWindow((Tk_Window) winPtr);
+ (void) TkpWmSetState(winPtr, NormalState);
} else if ((c == 'f') && (strncmp(argv[1], "focusmodel", length) == 0)
&& (length >= 2)) {
if ((argc != 3) && (argc != 4)) {
@@ -1343,23 +1337,11 @@ Tk_WmCmd(clientData, interp, argc, argv)
(char *) NULL);
return TCL_ERROR;
}
- wmPtr->hints.initial_state = IconicState;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- return TCL_OK;
- }
- if (wmPtr->withdrawn) {
- UpdateHints(winPtr);
- Tk_MapWindow((Tk_Window) winPtr);
- wmPtr->withdrawn = 0;
- } else {
- if (XIconifyWindow(winPtr->display, wmPtr->wrapperPtr->window,
- winPtr->screenNum) == 0) {
- Tcl_SetResult(interp,
- "couldn't send iconify message to window manager",
- TCL_STATIC);
- return TCL_ERROR;
- }
- WaitForMapNotify(winPtr, 0);
+ if (TkpWmSetState(winPtr, IconicState) == 0) {
+ Tcl_SetResult(interp,
+ "couldn't send iconify message to window manager",
+ TCL_STATIC);
+ return TCL_ERROR;
}
} else if ((c == 'i') && (strncmp(argv[1], "iconmask", length) == 0)
&& (length >= 5)) {
@@ -1909,13 +1891,7 @@ Tk_WmCmd(clientData, interp, argc, argv)
length = strlen(argv[3]);
if ((c == 'n') && (strncmp(argv[3], "normal", length) == 0)) {
- wmPtr->hints.initial_state = NormalState;
- wmPtr->withdrawn = 0;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- return TCL_OK;
- }
- UpdateHints(winPtr);
- Tk_MapWindow((Tk_Window) winPtr);
+ (void) TkpWmSetState(winPtr, NormalState);
} else if ((c == 'i')
&& (strncmp(argv[3], "iconic", length) == 0)) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
@@ -1931,38 +1907,20 @@ Tk_WmCmd(clientData, interp, argc, argv)
"\": it is a transient", (char *) NULL);
return TCL_ERROR;
}
- wmPtr->hints.initial_state = IconicState;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- return TCL_OK;
- }
- if (wmPtr->withdrawn) {
- UpdateHints(winPtr);
- Tk_MapWindow((Tk_Window) winPtr);
- wmPtr->withdrawn = 0;
- } else {
- if (XIconifyWindow(winPtr->display,
- wmPtr->wrapperPtr->window,
- winPtr->screenNum) == 0) {
- Tcl_SetResult(interp, "couldn't send iconify message to window manager", TCL_STATIC);
- return TCL_ERROR;
- }
- WaitForMapNotify(winPtr, 0);
+ if (TkpWmSetState(winPtr, IconicState) == 0) {
+ Tcl_SetResult(interp,
+ "couldn't send iconify message to window manager",
+ TCL_STATIC);
+ return TCL_ERROR;
}
} else if ((c == 'w')
&& (strncmp(argv[3], "withdrawn", length) == 0)) {
- wmPtr->hints.initial_state = WithdrawnState;
- wmPtr->withdrawn = 1;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- return TCL_OK;
- }
- if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window,
- winPtr->screenNum) == 0) {
+ if (TkpWmSetState(winPtr, WithdrawnState) == 0) {
Tcl_SetResult(interp,
"couldn't send withdraw message to window manager",
TCL_STATIC);
return TCL_ERROR;
}
- WaitForMapNotify(winPtr, 0);
} else {
Tcl_AppendResult(interp, "bad argument \"", argv[3],
"\": must be normal, iconic or withdrawn",
@@ -2095,19 +2053,12 @@ Tk_WmCmd(clientData, interp, argc, argv)
(char *) NULL);
return TCL_ERROR;
}
- wmPtr->hints.initial_state = WithdrawnState;
- wmPtr->withdrawn = 1;
- if (wmPtr->flags & WM_NEVER_MAPPED) {
- return TCL_OK;
- }
- if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window,
- winPtr->screenNum) == 0) {
+ if (TkpWmSetState(winPtr, WithdrawnState) == 0) {
Tcl_SetResult(interp,
"couldn't send withdraw message to window manager",
TCL_STATIC);
return TCL_ERROR;
}
- WaitForMapNotify(winPtr, 0);
} else {
Tcl_AppendResult(interp, "unknown or ambiguous option \"", argv[1],
"\": must be aspect, client, command, deiconify, ",
@@ -5329,3 +5280,68 @@ UpdateCommand(winPtr)
ckfree((char *) cmdArgv);
ckfree((char *) offsets);
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpWmSetState --
+ *
+ * Sets the window manager state for the wrapper window of a
+ * given toplevel window.
+ *
+ * Results:
+ * 0 on error, 1 otherwise
+ *
+ * Side effects:
+ * May minimize, restore, or withdraw a window.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkpWmSetState(winPtr, state)
+ TkWindow *winPtr; /* Toplevel window to operate on. */
+ int state; /* One of IconicState, NormalState,
+ * or WithdrawnState. */
+{
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+
+ if (state == WithdrawnState) {
+ wmPtr->hints.initial_state = WithdrawnState;
+ wmPtr->withdrawn = 1;
+ if (wmPtr->flags & WM_NEVER_MAPPED) {
+ return 1;
+ }
+ if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window,
+ winPtr->screenNum) == 0) {
+ return 0;
+ }
+ WaitForMapNotify(winPtr, 0);
+ } else if (state == NormalState) {
+ wmPtr->hints.initial_state = NormalState;
+ wmPtr->withdrawn = 0;
+ if (wmPtr->flags & WM_NEVER_MAPPED) {
+ return 1;
+ }
+ UpdateHints(winPtr);
+ Tk_MapWindow((Tk_Window) winPtr);
+ } else if (state == IconicState) {
+ wmPtr->hints.initial_state = IconicState;
+ if (wmPtr->flags & WM_NEVER_MAPPED) {
+ return 1;
+ }
+ if (wmPtr->withdrawn) {
+ UpdateHints(winPtr);
+ Tk_MapWindow((Tk_Window) winPtr);
+ wmPtr->withdrawn = 0;
+ } else {
+ if (XIconifyWindow(winPtr->display, wmPtr->wrapperPtr->window,
+ winPtr->screenNum) == 0) {
+ return 0;
+ }
+ WaitForMapNotify(winPtr, 0);
+ }
+ }
+
+ return 1;
+}