4
4
* This module takes care of the interactions between a Tk-based
5
* application and the window manager. Among other things, it
6
* implements the "wm" command and passes geometry information
7
* to the window manager.
5
* application and the window manager. Among other things, it implements
6
* the "wm" command and passes geometry information to the window
9
9
* Copyright (c) 1991-1994 The Regents of the University of California.
10
10
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
12
* See the file "license.terms" for information on usage and redistribution
13
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
* See the file "license.terms" for information on usage and redistribution of
13
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
* RCS: @(#) $Id: tkUnixWm.c,v 1.36 2002/12/27 21:23:04 jenglish Exp $
15
* RCS: @(#) $Id: tkUnixWm.c,v 1.51 2006/05/29 22:21:40 hobbs Exp $
18
18
#include "tkPort.h"
20
20
#include "tkUnixInt.h"
24
* A data structure of the following type holds information for
25
* each window manager protocol (such as WM_DELETE_WINDOW) for
26
* which a handler (i.e. a Tcl command) has been defined for a
27
* particular top-level window.
23
* A data structure of the following type holds information for each window
24
* manager protocol (such as WM_DELETE_WINDOW) for which a handler (i.e. a Tcl
25
* command) has been defined for a particular top-level window.
30
28
typedef struct ProtocolHandler {
31
29
Atom protocol; /* Identifies the protocol. */
32
30
struct ProtocolHandler *nextPtr;
33
/* Next in list of protocol handlers for
34
* the same top-level window, or NULL for
31
/* Next in list of protocol handlers for the
32
* same top-level window, or NULL for end of
36
34
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
38
char command[4]; /* Tcl command to invoke when a client
39
* message for this protocol arrives.
40
* The actual size of the structure varies
41
* to accommodate the needs of the actual
42
* command. THIS MUST BE THE LAST FIELD OF
36
char command[4]; /* Tcl command to invoke when a client message
37
* for this protocol arrives. The actual size
38
* of the structure varies to accommodate the
39
* needs of the actual command. THIS MUST BE
40
* THE LAST FIELD OF THE STRUCTURE. */
45
42
LangCallback *command;
57
* Data for [wm attributes] command:
60
double alpha; /* Transparency; 0.0=transparent, 1.0=opaque */
61
int topmost; /* Flag: true=>stay-on-top */
62
int zoomed; /* Flag: true=>maximized */
63
int fullscreen; /* Flag: true=>fullscreen */
67
WMATT_ALPHA, WMATT_TOPMOST, WMATT_ZOOMED, WMATT_FULLSCREEN,
71
static const char *WmAttributeNames[] = {
72
"-alpha", "-topmost", "-zoomed", "-fullscreen",
60
77
* A data structure of the following type holds window-manager-related
61
78
* information for each top-level window in an application.
64
81
typedef struct TkWmInfo {
65
TkWindow *winPtr; /* Pointer to main Tk information for
82
TkWindow *winPtr; /* Pointer to main Tk information for this
67
84
Window reparent; /* If the window has been reparented, this
68
85
* gives the ID of the ancestor of the window
69
* that is a child of the root window (may
70
* not be window's immediate parent). If
71
* the window isn't reparented, this has the
73
char *title; /* Title to display in window caption. If
74
* NULL, use name of widget. Malloced. */
75
char *iconName; /* Name to display in icon. Malloced. */
76
XWMHints hints; /* Various pieces of information for
86
* that is a child of the root window (may not
87
* be window's immediate parent). If the
88
* window isn't reparented, this has the value
90
char *title; /* Title to display in window caption. If
91
* NULL, use name of widget. Malloced. */
92
char *iconName; /* Name to display in icon. Malloced. */
93
XWMHints hints; /* Various pieces of information for window
78
95
char *leaderName; /* Path name of leader of window group
79
96
* (corresponds to hints.window_group).
80
* Malloc-ed. Note: this field doesn't
81
* get updated if leader is destroyed. */
97
* Malloc-ed. Note: this field doesn't get
98
* updated if leader is destroyed. */
82
99
TkWindow *masterPtr; /* Master window for TRANSIENT_FOR property,
84
Tk_Window icon; /* Window to use as icon for this window,
101
Tk_Window icon; /* Window to use as icon for this window, or
86
103
Tk_Image iconImage; /* Image used to generate Icon - or NULL */
87
104
Tk_Window iconFor; /* Window for which this window is icon, or
88
105
* NULL if this isn't an icon for anyone. */
92
109
* In order to support menubars transparently under X, each toplevel
93
* window is encased in an additional window, called the wrapper,
94
* that holds the toplevel and the menubar, if any. The information
95
* below is used to keep track of the wrapper and the menubar.
110
* window is encased in an additional window, called the wrapper, that
111
* holds the toplevel and the menubar, if any. The information below is
112
* used to keep track of the wrapper and the menubar.
98
115
TkWindow *wrapperPtr; /* Pointer to information about the wrapper.
99
* This is the "real" toplevel window as
100
* seen by the window manager. Although
101
* this is an official Tk window, it
102
* doesn't appear in the application's
103
* window hierarchy. NULL means that
104
* the wrapper hasn't been created yet. */
105
Tk_Window menubar; /* Pointer to information about the
106
* menubar, or NULL if there is no
107
* menubar for this toplevel. */
116
* This is the "real" toplevel window as seen
117
* by the window manager. Although this is an
118
* official Tk window, it doesn't appear in
119
* the application's window hierarchy. NULL
120
* means that the wrapper hasn't been created
122
Tk_Window menubar; /* Pointer to information about the menubar,
123
* or NULL if there is no menubar for this
108
125
int menuHeight; /* Amount of vertical space needed for
109
* menubar, measured in pixels. If
110
* menubar is non-NULL, this is >= 1 (X
111
* servers don't like dimensions of 0). */
126
* menubar, measured in pixels. If menubar is
127
* non-NULL, this is >= 1 (X servers don't
128
* like dimensions of 0). */
114
* Information used to construct an XSizeHints structure for
115
* the window manager:
131
* Information used to construct an XSizeHints structure for the window
118
int sizeHintsFlags; /* Flags word for XSizeHints structure.
119
* If the PBaseSize flag is set then the
120
* window is gridded; otherwise it isn't
122
int minWidth, minHeight; /* Minimum dimensions of window, in
123
* grid units, not pixels. */
124
int maxWidth, maxHeight; /* Maximum dimensions of window, in
125
* grid units, not pixels. */
135
int sizeHintsFlags; /* Flags word for XSizeHints structure. If the
136
* PBaseSize flag is set then the window is
137
* gridded; otherwise it isn't gridded. */
138
int minWidth, minHeight; /* Minimum dimensions of window, in pixels or
140
int maxWidth, maxHeight; /* Maximum dimensions of window, in pixels or
141
* grid units. 0 to default.*/
126
142
Tk_Window gridWin; /* Identifies the window that controls
127
* gridding for this top-level, or NULL if
128
* the top-level isn't currently gridded. */
129
int widthInc, heightInc; /* Increments for size changes (# pixels
143
* gridding for this top-level, or NULL if the
144
* top-level isn't currently gridded. */
145
int widthInc, heightInc; /* Increments for size changes (# pixels per
132
int x; /* numerator */
133
int y; /* denominator */
148
int x; /* numerator */
149
int y; /* denominator */
134
150
} minAspect, maxAspect; /* Min/max aspect ratios for window. */
135
151
int reqGridWidth, reqGridHeight;
136
/* The dimensions of the window (in
137
* grid units) requested through
138
* the geometry manager. */
152
/* The dimensions of the window (in grid
153
* units) requested through the geometry
139
155
int gravity; /* Desired window gravity. */
142
158
* Information used to manage the size and location of a window.
145
int width, height; /* Desired dimensions of window, specified
146
* in grid units. These values are
147
* set by the "wm geometry" command and by
148
* ConfigureNotify events (for when wm
149
* resizes window). -1 means user hasn't
150
* requested dimensions. */
161
int width, height; /* Desired dimensions of window, specified in
162
* pixels or grid units. These values are set
163
* by the "wm geometry" command and by
164
* ConfigureNotify events (for when wm resizes
165
* window). -1 means user hasn't requested
151
167
int x, y; /* Desired X and Y coordinates for window.
152
* These values are set by "wm geometry",
153
* plus by ConfigureNotify events (when wm
154
* moves window). These numbers are
155
* different than the numbers stored in
156
* winPtr->changes because (a) they could be
157
* measured from the right or bottom edge
158
* of the screen (see WM_NEGATIVE_X and
159
* WM_NEGATIVE_Y flags) and (b) if the window
160
* has been reparented then they refer to the
161
* parent rather than the window itself. */
168
* These values are set by "wm geometry", plus
169
* by ConfigureNotify events (when wm moves
170
* window). These numbers are different than
171
* the numbers stored in winPtr->changes
172
* because (a) they could be measured from the
173
* right or bottom edge of the screen (see
174
* WM_NEGATIVE_X and WM_NEGATIVE_Y flags) and
175
* (b) if the window has been reparented then
176
* they refer to the parent rather than the
162
178
int parentWidth, parentHeight;
163
179
/* Width and height of reparent, in pixels
164
* *including border*. If window hasn't been
180
* *including border*. If window hasn't been
165
181
* reparented then these will be the outer
166
182
* dimensions of the window, including
168
184
int xInParent, yInParent; /* Offset of wrapperPtr within reparent,
169
185
* measured in pixels from upper-left outer
170
186
* corner of reparent's border to upper-left
171
* outer corner of wrapperPtr's border. If
172
* not reparented then these are zero. */
187
* outer corner of wrapperPtr's border. If not
188
* reparented then these are zero. */
173
189
int configWidth, configHeight;
174
190
/* Dimensions passed to last request that we
175
191
* issued to change geometry of the wrapper.
1048
1128
* Tk_WmObjCmd --
1051
* This procedure is invoked to process the "wm" Tcl command.
1052
* See the user documentation for details on what it does.
1055
* A standard Tcl result.
1058
* See the user documentation.
1131
* This function is invoked to process the "wm" Tcl command.
1060
1133
*----------------------------------------------------------------------
1064
Tk_WmObjCmd(clientData, interp, objc, objv)
1065
ClientData clientData; /* Main window associated with
1067
Tcl_Interp *interp; /* Current interpreter. */
1068
int objc; /* Number of arguments. */
1069
Tcl_Obj *CONST objv[]; /* Argument objects. */
1138
ClientData clientData, /* Main window associated with interpreter. */
1139
Tcl_Interp *interp, /* Current interpreter. */
1140
int objc, /* Number of arguments. */
1141
Tcl_Obj *CONST objv[]) /* Argument objects. */
1071
1143
Tk_Window tkwin = (Tk_Window) clientData;
1072
1144
static CONST char *optionStrings[] = {
1073
1145
"aspect", "attributes", "capture", "client", "colormapwindows",
1074
1146
"command", "deiconify", "focusmodel", "frame",
1075
1147
"geometry", "grid", "group", "iconbitmap",
1076
"iconify", "iconimage", "iconmask", "iconname", "iconposition",
1148
"iconify", "iconimage", "iconmask", "iconname",
1149
"iconphoto", "iconposition",
1077
1150
"iconwindow", "maxsize", "minsize", "overrideredirect",
1078
"positionfrom", "protocol", "release", "resizable", "sizefrom",
1079
"stackorder", "state", "title", "transient",
1080
"withdraw", "wrapper", (char *) NULL };
1151
"positionfrom", "protocol", "release", "resizable", "sizefrom",
1152
"stackorder", "state", "title", "transient",
1153
"withdraw", "wrapper", NULL };
1082
1155
WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CAPTURE, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
1083
1156
WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
1084
1157
WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
1085
WMOPT_ICONIFY, WMOPT_ICONIMAGE, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPOSITION,
1158
WMOPT_ICONIFY, WMOPT_ICONIMAGE, WMOPT_ICONMASK, WMOPT_ICONNAME,
1159
WMOPT_ICONPHOTO, WMOPT_ICONPOSITION,
1086
1160
WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
1087
1161
WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RELEASE, WMOPT_RESIZABLE, WMOPT_SIZEFROM,
1088
1162
WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT,
1148
1223
else if ((enum options) index != WMOPT_RELEASE) {
1149
1224
Tcl_AppendResult(interp, "window \"", winPtr->pathName,
1150
"\" isn't a top-level window", (char *) NULL);
1225
"\" isn't a top-level window", NULL);
1151
1226
return TCL_ERROR;
1154
1229
switch ((enum options) index) {
1156
1231
return WmAspectCmd(tkwin, winPtr, interp, objc, objv);
1157
case WMOPT_ATTRIBUTES:
1232
case WMOPT_ATTRIBUTES:
1158
1233
return WmAttributesCmd(tkwin, winPtr, interp, objc, objv);
1160
1235
return WmClientCmd(tkwin, winPtr, interp, objc, objv);
1162
1237
return WmCaptureCmd(tkwin, winPtr, interp, objc, objv);
1163
case WMOPT_COLORMAPWINDOWS:
1238
case WMOPT_COLORMAPWINDOWS:
1164
1239
return WmColormapwindowsCmd(tkwin, winPtr, interp, objc, objv);
1166
1241
return WmCommandCmd(tkwin, winPtr, interp, objc, objv);
1167
case WMOPT_DEICONIFY:
1242
case WMOPT_DEICONIFY:
1168
1243
return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
1169
case WMOPT_FOCUSMODEL:
1244
case WMOPT_FOCUSMODEL:
1170
1245
return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
1172
1247
return WmFrameCmd(tkwin, winPtr, interp, objc, objv);
1173
case WMOPT_GEOMETRY:
1248
case WMOPT_GEOMETRY:
1174
1249
return WmGeometryCmd(tkwin, winPtr, interp, objc, objv);
1176
1251
return WmGridCmd(tkwin, winPtr, interp, objc, objv);
1178
1253
return WmGroupCmd(tkwin, winPtr, interp, objc, objv);
1179
case WMOPT_ICONBITMAP:
1254
case WMOPT_ICONBITMAP:
1180
1255
return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv);
1182
1257
return WmIconifyCmd(tkwin, winPtr, interp, objc, objv);
1183
case WMOPT_ICONIMAGE:
1258
case WMOPT_ICONIMAGE:
1184
1259
return WmIconimageCmd(tkwin, winPtr, interp, objc, objv);
1185
case WMOPT_ICONMASK:
1260
case WMOPT_ICONMASK:
1186
1261
return WmIconmaskCmd(tkwin, winPtr, interp, objc, objv);
1187
case WMOPT_ICONNAME:
1262
case WMOPT_ICONNAME:
1188
1263
return WmIconnameCmd(tkwin, winPtr, interp, objc, objv);
1189
case WMOPT_ICONPOSITION:
1264
case WMOPT_ICONPHOTO:
1265
return WmIconphotoCmd(tkwin, winPtr, interp, objc, objv);
1266
case WMOPT_ICONPOSITION:
1190
1267
return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv);
1191
case WMOPT_ICONWINDOW:
1268
case WMOPT_ICONWINDOW:
1192
1269
return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv);
1194
1271
return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv);
1196
1273
return WmMinsizeCmd(tkwin, winPtr, interp, objc, objv);
1197
case WMOPT_OVERRIDEREDIRECT:
1274
case WMOPT_OVERRIDEREDIRECT:
1198
1275
return WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv);
1199
case WMOPT_POSITIONFROM:
1276
case WMOPT_POSITIONFROM:
1200
1277
return WmPositionfromCmd(tkwin, winPtr, interp, objc, objv);
1201
case WMOPT_PROTOCOL:
1278
case WMOPT_PROTOCOL:
1202
1279
return WmProtocolCmd(tkwin, winPtr, interp, objc, objv);
1203
case WMOPT_RESIZABLE:
1280
case WMOPT_RESIZABLE:
1204
1281
return WmResizableCmd(tkwin, winPtr, interp, objc, objv);
1206
1283
return WmReleaseCmd(tkwin, winPtr, interp, objc, objv);
1207
case WMOPT_SIZEFROM:
1284
case WMOPT_SIZEFROM:
1208
1285
return WmSizefromCmd(tkwin, winPtr, interp, objc, objv);
1209
case WMOPT_STACKORDER:
1286
case WMOPT_STACKORDER:
1210
1287
return WmStackorderCmd(tkwin, winPtr, interp, objc, objv);
1212
1289
return WmStateCmd(tkwin, winPtr, interp, objc, objv);
1214
1291
return WmTitleCmd(tkwin, winPtr, interp, objc, objv);
1215
case WMOPT_TRANSIENT:
1292
case WMOPT_TRANSIENT:
1216
1293
return WmTransientCmd(tkwin, winPtr, interp, objc, objv);
1217
case WMOPT_WITHDRAW:
1294
case WMOPT_WITHDRAW:
1218
1295
return WmWithdrawCmd(tkwin, winPtr, interp, objc, objv);
1220
1297
return WmWrapperCmd(tkwin, winPtr, interp, objc, objv);
1298
1372
*----------------------------------------------------------------------
1376
* Helper routine for WmAttributesCmd. Sets the value
1377
* of the specified attribute.
1381
* TCL_OK if successful, TCL_ERROR otherwise. In case of an
1382
* error, leaves a message in the interpreter's result.
1384
*----------------------------------------------------------------------
1386
static int WmSetAttribute(
1387
TkWindow *winPtr, /* Toplevel to work with */
1388
Tcl_Interp *interp, /* Current interpreter */
1389
WmAttribute attribute, /* Code of attribute to set */
1390
Tcl_Obj *value) /* New value */
1392
WmInfo *wmPtr = winPtr->wmInfoPtr;
1393
switch (attribute) {
1396
unsigned long opacity; /* 0=transparent, 0xFFFFFFFF=opaque */
1398
if (TCL_OK != Tcl_GetDoubleFromObj(
1399
interp, value, &wmPtr->reqState.alpha)) {
1402
if (wmPtr->reqState.alpha < 0.0) {
1403
wmPtr->reqState.alpha = 0.0;
1405
if (wmPtr->reqState.alpha > 1.0) {
1406
wmPtr->reqState.alpha = 1.0;
1409
if (!wmPtr->wrapperPtr) {
1413
opacity = 0xFFFFFFFFul * wmPtr->reqState.alpha;
1414
XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
1415
Tk_InternAtom((Tk_Window)winPtr, "_NET_WM_WINDOW_OPACITY"),
1416
XA_CARDINAL, 32, PropModeReplace,
1417
(unsigned char *)&opacity, 1L);
1418
wmPtr->attributes.alpha = wmPtr->reqState.alpha;
1423
if (TCL_OK != Tcl_GetBooleanFromObj(
1424
interp, value, &wmPtr->reqState.topmost)) {
1427
SetNetWmState(winPtr,
1428
"_NET_WM_STATE_ABOVE", wmPtr->reqState.topmost);
1431
if (TCL_OK != Tcl_GetBooleanFromObj(
1432
interp, value, &wmPtr->reqState.zoomed)) {
1435
SetNetWmState(winPtr,
1436
"_NET_WM_STATE_MAXIMIZED_VERT", wmPtr->reqState.zoomed);
1437
SetNetWmState(winPtr,
1438
"_NET_WM_STATE_MAXIMIZED_HORZ", wmPtr->reqState.zoomed);
1440
case WMATT_FULLSCREEN:
1441
if (TCL_OK != Tcl_GetBooleanFromObj(
1442
interp, value, &wmPtr->reqState.fullscreen)) {
1445
SetNetWmState(winPtr,
1446
"_NET_WM_STATE_FULLSCREEN", wmPtr->reqState.fullscreen);
1448
case _WMATT_LAST_ATTRIBUTE: /* NOTREACHED */
1455
*----------------------------------------------------------------------
1459
* Helper routine for WmAttributesCmd. Returns the current value
1460
* of the specified attribute.
1462
* See also: CheckNetWmState().
1464
*----------------------------------------------------------------------
1466
static Tcl_Obj *WmGetAttribute(
1467
TkWindow *winPtr, /* Toplevel to work with */
1468
WmAttribute attribute) /* Code of attribute to get */
1470
WmInfo *wmPtr = winPtr->wmInfoPtr;
1471
switch (attribute) {
1473
return Tcl_NewDoubleObj(wmPtr->attributes.alpha);
1475
return Tcl_NewBooleanObj(wmPtr->attributes.topmost);
1477
return Tcl_NewBooleanObj(wmPtr->attributes.zoomed);
1478
case WMATT_FULLSCREEN:
1479
return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen);
1480
case _WMATT_LAST_ATTRIBUTE: /*NOTREACHED*/
1488
*----------------------------------------------------------------------
1300
1490
* WmAttributesCmd --
1302
* This procedure is invoked to process the "wm attributes" Tcl command.
1303
* See the user documentation for details on what it does.
1306
* A standard Tcl result.
1309
* See the user documentation.
1492
* This function is invoked to process the "wm attributes" Tcl command.
1496
* wm attributes $win ?-attribute ?value attribute value...??
1500
* Attributes of mapped windows are set by sending a _NET_WM_STATE
1501
* ClientMessage to the root window (see SetNetWmState).
1502
* For withdrawn windows, we keep track of the requested attribute
1503
* state, and set the _NET_WM_STATE property ourselves immediately
1504
* prior to mapping the window.
1506
* See also: TIP#231, EWMH.
1311
1508
*----------------------------------------------------------------------
1315
WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
1316
Tk_Window tkwin; /* Main window of the application. */
1317
TkWindow *winPtr; /* Toplevel to work with */
1318
Tcl_Interp *interp; /* Current interpreter. */
1319
int objc; /* Number of arguments. */
1320
Tcl_Obj *CONST objv[]; /* Argument objects. */
1513
Tk_Window tkwin, /* Main window of the application. */
1514
TkWindow *winPtr, /* Toplevel to work with */
1515
Tcl_Interp *interp, /* Current interpreter. */
1516
int objc, /* Number of arguments. */
1517
Tcl_Obj *CONST objv[]) /* Argument objects. */
1323
Tcl_WrongNumArgs(interp, 2, objv, "window");
1520
if (objc == 3) { /* wm attributes $win */
1521
Tcl_Obj *result = Tcl_NewListObj(0,0);
1522
for (attribute = 0; attribute < _WMATT_LAST_ATTRIBUTE; ++attribute) {
1523
Tcl_ListObjAppendElement(interp, result,
1524
Tcl_NewStringObj(WmAttributeNames[attribute], -1));
1525
Tcl_ListObjAppendElement(interp, result,
1526
WmGetAttribute(winPtr, attribute));
1528
Tcl_SetObjResult(interp, result);
1530
} else if (objc == 4) { /* wm attributes $win -attribute */
1531
if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames,
1532
"attribute", 0, &attribute) != TCL_OK) {
1535
Tcl_SetObjResult(interp,
1536
WmGetAttribute(winPtr, attribute));
1538
} else if ((objc - 3) % 2 == 0) { /* wm attributes $win -att value... */
1540
for (i = 3; i < objc; i += 2) {
1541
if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames,
1542
"attribute", 0, &attribute) != TCL_OK) {
1545
if (WmSetAttribute(winPtr,interp,attribute,objv[i+1]) != TCL_OK) {
1551
Tcl_WrongNumArgs(interp, 2, objv, "window ?-attribute ?value ...??");
1324
1552
return TCL_ERROR;
2193
2413
wmPtr->iconName = ckalloc((unsigned) (length + 1));
2194
2414
strcpy(wmPtr->iconName, argv3);
2195
2415
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
2198
Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds);
2199
XSetIconName(winPtr->display, wmPtr->wrapperPtr->window,
2200
Tcl_DStringValue(&ds));
2201
Tcl_DStringFree(&ds);
2416
UpdateTitle(winPtr);
2423
*----------------------------------------------------------------------
2427
* This function is invoked to process the "wm iconphoto" Tcl command.
2428
* See the user documentation for details on what it does.
2431
* A standard Tcl result.
2434
* See the user documentation.
2436
*----------------------------------------------------------------------
2441
Tk_Window tkwin, /* Main window of the application. */
2442
TkWindow *winPtr, /* Toplevel to work with */
2443
Tcl_Interp *interp, /* Current interpreter. */
2444
int objc, /* Number of arguments. */
2445
Tcl_Obj *CONST objv[]) /* Argument objects. */
2447
register WmInfo *wmPtr = winPtr->wmInfoPtr;
2448
Tk_PhotoHandle photo;
2449
Tk_PhotoImageBlock block;
2450
int i, size = 0, width, height, index = 0, x, y, isDefault = 0;
2452
long *iconPropertyData;
2453
unsigned char *pixelByte;
2456
Tcl_WrongNumArgs(interp, 2, objv,
2457
"window ?-default? image1 ?image2 ...?");
2460
if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
2463
Tcl_WrongNumArgs(interp, 2, objv,
2464
"window ?-default? image1 ?image2 ...?");
2470
* Iterate over all images to retrieve their sizes, in order to allocate a
2471
* buffer large enough to hold all images.
2474
for (i = 3 + isDefault; i < objc; i++) {
2475
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
2476
if (photo == NULL) {
2477
Tcl_AppendResult(interp, "can't use \"", Tcl_GetString(objv[i]),
2478
"\" as iconphoto: not a photo image", NULL);
2481
Tk_PhotoGetSize(photo, &width, &height);
2484
* We need to cardinals for width & height and one cardinal for each
2488
size += 2 + width * height;
2492
* We have calculated the size of the data. Try to allocate the needed
2497
iconPropertyData = (long *) Tcl_AttemptAlloc(sizeof(long)*size);
2499
iconPropertyData = (long *) ckalloc(sizeof(long)*size);
2501
if (iconPropertyData == NULL) {
2504
memset(iconPropertyData, 0, sizeof(long)*size);
2506
for (i = 3 + isDefault; i < objc; i++) {
2507
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
2508
if (photo == NULL) {
2509
Tcl_Free((char *) iconPropertyData);
2512
Tk_PhotoGetSize(photo, &width, &height);
2513
Tk_PhotoGetImage(photo, &block);
2516
* Each image data will be placed as an array of 32bit packed
2517
* CARDINAL, in a window property named "_NET_WM_ICON": _NET_WM_ICON
2519
* _NET_WM_ICON CARDINAL[][2+n]/32
2521
* This is an array of possible icons for the client. This spec. does
2522
* not stipulate what size these icons should be, but individual
2523
* desktop environments or toolkits may do so. The Window Manager MAY
2524
* scale any of these icons to an appropriate size.
2526
* This is an array of 32bit packed CARDINAL ARGB with high byte being
2527
* A, low byte being B. The first two cardinals are width, height.
2528
* Data is in rows, left to right and top to bottom.
2532
* Encode the image data in the iconPropertyData array.
2535
iconPropertyData[index++] = width;
2536
iconPropertyData[index++] = height;
2537
for (y = 0; y < height; y++) {
2538
for (x = 0; x < width; x++) {
2539
R = *(block.pixelPtr + x*block.pixelSize +
2540
y*block.pitch + block.offset[0]);
2541
G = *(block.pixelPtr + x*block.pixelSize +
2542
y*block.pitch + block.offset[1]);
2543
B = *(block.pixelPtr + x*block.pixelSize +
2544
y*block.pitch + block.offset[2]);
2545
A = *(block.pixelPtr + x*block.pixelSize +
2546
y*block.pitch + block.offset[3]);
2547
pixelByte = (unsigned char *) &iconPropertyData[index];
2556
if (wmPtr->iconDataPtr != NULL) {
2557
ckfree((char *)wmPtr->iconDataPtr);
2558
wmPtr->iconDataPtr = NULL;
2561
if (winPtr->dispPtr->iconDataPtr != NULL) {
2562
ckfree((char *) winPtr->dispPtr->iconDataPtr);
2564
winPtr->dispPtr->iconDataPtr = (unsigned char *) iconPropertyData;
2565
winPtr->dispPtr->iconDataSize = size;
2567
wmPtr->iconDataPtr = (unsigned char *) iconPropertyData;
2568
wmPtr->iconDataSize = size;
2570
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
2571
UpdatePhotoIcon(winPtr);
3345
3693
* Tk_SetGrid --
3347
* This procedure is invoked by a widget when it wishes to set a grid
3348
* coordinate system that controls the size of a top-level window.
3349
* It provides a C interface equivalent to the "wm grid" command and
3350
* is usually asscoiated with the -setgrid option.
3695
* This function is invoked by a widget when it wishes to set a grid
3696
* coordinate system that controls the size of a top-level window. It
3697
* provides a C interface equivalent to the "wm grid" command and is
3698
* usually asscoiated with the -setgrid option.
3355
3703
* Side effects:
3356
* Grid-related information will be passed to the window manager, so
3357
* that the top-level window associated with tkwin will resize on
3358
* even grid units. If some other window already controls gridding
3359
* for the top-level window then this procedure call has no effect.
3704
* Grid-related information will be passed to the window manager, so that
3705
* the top-level window associated with tkwin will resize on even grid
3706
* units. If some other window already controls gridding for the
3707
* top-level window then this function call has no effect.
3361
3709
*----------------------------------------------------------------------
3365
Tk_SetGrid(tkwin, reqWidth, reqHeight, widthInc, heightInc)
3366
Tk_Window tkwin; /* Token for window. New window mgr info
3367
* will be posted for the top-level window
3714
Tk_Window tkwin, /* Token for window. New window mgr info will
3715
* be posted for the top-level window
3368
3716
* associated with this window. */
3369
int reqWidth; /* Width (in grid units) corresponding to
3370
* the requested geometry for tkwin. */
3371
int reqHeight; /* Height (in grid units) corresponding to
3372
* the requested geometry for tkwin. */
3373
int widthInc, heightInc; /* Pixel increments corresponding to a
3374
* change of one grid unit. */
3717
int reqWidth, /* Width (in grid units) corresponding to the
3718
* requested geometry for tkwin. */
3719
int reqHeight, /* Height (in grid units) corresponding to the
3720
* requested geometry for tkwin. */
3721
int widthInc, int heightInc)/* Pixel increments corresponding to a change
3722
* of one grid unit. */
3376
3724
TkWindow *winPtr = (TkWindow *) tkwin;
3377
3725
register WmInfo *wmPtr;
3728
* Ensure widthInc and heightInc are greater than 0
3731
if (widthInc <= 0) {
3734
if (heightInc <= 0) {
3380
3739
* Find the top-level window for tkwin, plus the window manager
3898
4250
* Some tricky issues in updating wmPtr->x and wmPtr->y:
3900
* 1. Don't update them if the event occurred because of something
3901
* we did (i.e. WM_SYNC_PENDING and WM_MOVE_PENDING are both set).
3902
* This is because window managers treat coords differently than Tk,
3903
* and no two window managers are alike. If the window manager moved
3904
* the window because we told it to, remember the coordinates we told
3905
* it, not the ones it actually moved it to. This allows us to move
3906
* the window back to the same coordinates later and get the same
3907
* result. Without this check, windows can "walk" across the screen
3908
* under some conditions.
3910
* 2. Don't update wmPtr->x and wmPtr->y unless wrapperPtr->changes.x
3911
* or wrapperPtr->changes.y has changed (otherwise a size change can
3912
* spoof us into thinking that the position changed too and defeat
3913
* the intent of (1) above.
3915
* (As of 9/96 the above 2 comments appear to be stale. They're
3916
* being left in place as a reminder of what was once true (and
3917
* perhaps should still be true?)).
3919
* 3. Ignore size changes coming from the window system if we're
3920
* about to change the size ourselves but haven't seen the event for
3921
* it yet: our size change is supposed to take priority.
4252
* 1. Don't update them if the event occurred because of something we did
4253
* (i.e. WM_SYNC_PENDING and WM_MOVE_PENDING are both set). This is
4254
* because window managers treat coords differently than Tk, and no two
4255
* window managers are alike. If the window manager moved the window
4256
* because we told it to, remember the coordinates we told it, not the
4257
* ones it actually moved it to. This allows us to move the window back to
4258
* the same coordinates later and get the same result. Without this check,
4259
* windows can "walk" across the screen under some conditions.
4261
* 2. Don't update wmPtr->x and wmPtr->y unless wrapperPtr->changes.x or
4262
* wrapperPtr->changes.y has changed (otherwise a size change can spoof us
4263
* into thinking that the position changed too and defeat the intent of
4266
* (As of 9/96 the above 2 comments appear to be stale. They're being left
4267
* in place as a reminder of what was once true (and perhaps should still
4270
* 3. Ignore size changes coming from the window system if we're about to
4271
* change the size ourselves but haven't seen the event for it yet: our
4272
* size change is supposed to take priority.
3924
4275
if (!(wmPtr->flags & WM_MOVE_PENDING)
4101
4497
* UpdateGeometryInfo --
4103
* This procedure is invoked when a top-level window is first
4104
* mapped, and also as a when-idle procedure, to bring the
4105
* geometry and/or position of a top-level window back into
4106
* line with what has been requested by the user and/or widgets.
4107
* This procedure doesn't return until the window manager has
4108
* responded to the geometry change.
4499
* This function is invoked when a top-level window is first mapped, and
4500
* also as a when-idle function, to bring the geometry and/or position of
4501
* a top-level window back into line with what has been requested by the
4502
* user and/or widgets. This function doesn't return until the window
4503
* manager has responded to the geometry change.
4113
4508
* Side effects:
4114
* The size and location of both the toplevel window and its wrapper
4115
* may change, unless the WM prevents that from happening.
4509
* The size and location of both the toplevel window and its wrapper may
4510
* change, unless the WM prevents that from happening.
4117
4512
*----------------------------------------------------------------------
4121
UpdateGeometryInfo(clientData)
4122
ClientData clientData; /* Pointer to the window's record. */
4517
ClientData clientData) /* Pointer to the window's record. */
4124
4519
register TkWindow *winPtr = (TkWindow *) clientData;
4125
4520
register WmInfo *wmPtr = winPtr->wmInfoPtr;
4126
int x, y, width, height;
4521
int x, y, width, height, min, max;
4127
4522
unsigned long serial;
4129
4524
wmPtr->flags &= ~WM_UPDATE_PENDING;
4132
* Compute the new size for the top-level window. See the
4133
* user documentation for details on this, but the size
4134
* requested depends on (a) the size requested internally
4135
* by the window's widgets, (b) the size requested by the
4136
* user in a "wm geometry" command or via wm-based interactive
4137
* resizing (if any), and (c) whether or not the window is
4138
* gridded. Don't permit sizes <= 0 because this upsets
4527
* Compute the new size for the top-level window. See the user
4528
* documentation for details on this, but the size requested depends on
4529
* (a) the size requested internally by the window's widgets, (b) the size
4530
* requested by the user in a "wm geometry" command or via wm-based
4531
* interactive resizing (if any), (c) whether or not the window is
4532
* gridded, and (d) the current min or max size for the toplevel. Don't
4533
* permit sizes <= 0 because this upsets the X server.
4142
4536
if (wmPtr->width == -1) {
4197
4638
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
4199
4640
if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) {
4200
UpdateSizeHints(winPtr);
4641
UpdateSizeHints(winPtr, width, height);
4204
* Reconfigure the wrapper if it isn't already configured correctly.
4205
* A few tricky points:
4645
* Reconfigure the wrapper if it isn't already configured correctly. A few
4207
* 1. If the window is embeddedand the container is also in this
4208
* process, don't actually reconfigure the window; just pass the
4209
* desired size on to the container. Also, zero out any position
4210
* information, since embedded windows are not allowed to move.
4211
* 2. Sometimes the window manager will give us a different size
4212
* than we asked for (e.g. mwm has a minimum size for windows), so
4213
* base the size check on what we *asked for* last time, not what we
4648
* 1. If the window is embeddedand the container is also in this process,
4649
* don't actually reconfigure the window; just pass the desired size on
4650
* to the container. Also, zero out any position information, since
4651
* embedded windows are not allowed to move.
4652
* 2. Sometimes the window manager will give us a different size than we
4653
* asked for (e.g. mwm has a minimum size for windows), so base the
4654
* size check on what we *asked for* last time, not what we got.
4215
4655
* 3. Can't just reconfigure always, because we may not get a
4216
4656
* ConfigureNotify event back if nothing changed, so
4217
4657
* WaitForConfigureNotify will hang a long time.
4218
* 4. Don't move window unless a new position has been requested for
4219
* it. This is because of "features" in some window managers (e.g.
4220
* twm, as of 4/24/91) where they don't interpret coordinates
4221
* according to ICCCM. Moving a window to its current location may
4222
* cause it to shift position on the screen.
4658
* 4. Don't move window unless a new position has been requested for it.
4659
* This is because of "features" in some window managers (e.g. twm, as
4660
* of 4/24/91) where they don't interpret coordinates according to
4661
* ICCCM. Moving a window to its current location may cause it to shift
4662
* position on the screen.
4225
4665
if ((winPtr->flags & (TK_EMBEDDED|TK_BOTH_HALVES))
4226
4666
== (TK_EMBEDDED|TK_BOTH_HALVES)) {
4667
TkWindow *childPtr = TkpGetOtherWindow(winPtr);
4228
* This window is embedded and the container is also in this
4229
* process, so we don't need to do anything special about the
4230
* geometry, except to make sure that the desired size is known
4231
* by the container. Also, zero out any position information,
4232
* since embedded windows are not allowed to move.
4670
* This window is embedded and the container is also in this process,
4671
* so we don't need to do anything special about the geometry, except
4672
* to make sure that the desired size is known by the container. Also,
4673
* zero out any position information, since embedded windows are not
4235
4677
wmPtr->x = wmPtr->y = 0;
4236
4678
wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y);
4237
4679
height += wmPtr->menuHeight;
4238
Tk_GeometryRequest((Tk_Window) TkpGetOtherWindow(winPtr),
4680
if (childPtr != NULL) {
4681
Tk_GeometryRequest((Tk_Window) childPtr, width, height);
4242
4685
serial = NextRequest(winPtr->display);
4389
4832
hintsPtr->flags = wmPtr->sizeHintsFlags | PMinSize;
4392
* If the window isn't supposed to be resizable, then set the
4393
* minimum and maximum dimensions to be the same.
4835
* If the window isn't supposed to be resizable, then set the minimum and
4836
* maximum dimensions to be the same.
4396
4839
if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) {
4397
if (wmPtr->width >= 0) {
4398
hintsPtr->min_width = wmPtr->width;
4400
hintsPtr->min_width = winPtr->reqWidth;
4402
hintsPtr->max_width = hintsPtr->min_width;
4840
hintsPtr->max_width = hintsPtr->min_width = newWidth;
4841
hintsPtr->flags |= PMaxSize;
4404
4843
if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) {
4405
if (wmPtr->height >= 0) {
4406
hintsPtr->min_height = wmPtr->height;
4408
hintsPtr->min_height = winPtr->reqHeight + wmPtr->menuHeight;
4410
hintsPtr->max_height = hintsPtr->min_height;
4844
hintsPtr->max_height = hintsPtr->min_height =
4845
newHeight + wmPtr->menuHeight;
4846
hintsPtr->flags |= PMaxSize;
4413
4849
XSetWMNormalHints(winPtr->display, wmPtr->wrapperPtr->window, hintsPtr);
4415
4851
XFree((char *) hintsPtr);
4854
*--------------------------------------------------------------
4858
* This function is called to update the window title and icon name. It
4859
* sets the ICCCM-defined properties WM_NAME and WM_ICON_NAME for older
4860
* window managers, and the freedesktop.org-defined _NET_WM_NAME and
4861
* _NET_WM_ICON_NAME properties for newer ones. The ICCCM properties are
4862
* stored in the system encoding, the newer properties are stored in
4865
* NOTE: the ICCCM specifies that WM_NAME and WM_ICON_NAME are stored in
4866
* ISO-Latin-1. Tk has historically used the default system encoding
4867
* (since 8.1). It's not clear whether this is correct or not.
4870
* Properties get changed for winPtr.
4872
*--------------------------------------------------------------
4879
WmInfo *wmPtr = winPtr->wmInfoPtr;
4880
Atom XA_UTF8_STRING = Tk_InternAtom((Tk_Window) winPtr, "UTF8_STRING");
4888
string = (wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid;
4889
Tcl_UtfToExternalDString(NULL, string, -1, &ds);
4890
XStoreName(winPtr->display, wmPtr->wrapperPtr->window,
4891
Tcl_DStringValue(&ds));
4892
Tcl_DStringFree(&ds);
4894
XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
4895
Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_NAME"),
4896
XA_UTF8_STRING, 8, PropModeReplace,
4897
(const unsigned char*)string, (signed int)strlen(string));
4903
if (wmPtr->iconName != NULL) {
4904
Tcl_UtfToExternalDString(NULL, wmPtr->iconName, -1, &ds);
4905
XSetIconName(winPtr->display, wmPtr->wrapperPtr->window,
4906
Tcl_DStringValue(&ds));
4907
Tcl_DStringFree(&ds);
4909
XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
4910
Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_ICON_NAME"),
4911
XA_UTF8_STRING, 8, PropModeReplace,
4912
(const unsigned char*)wmPtr->iconName,
4913
(signed int)strlen(wmPtr->iconName));
4918
*--------------------------------------------------------------
4920
* UpdatePhotoIcon --
4922
* This function is called to update the window photo icon. It sets the
4923
* EWMH-defined properties _NET_WM_ICON.
4926
* Properties get changed for winPtr.
4928
*--------------------------------------------------------------
4935
WmInfo *wmPtr = winPtr->wmInfoPtr;
4936
unsigned char *data = wmPtr->iconDataPtr;
4937
int size = wmPtr->iconDataSize;
4940
data = winPtr->dispPtr->iconDataPtr;
4941
size = winPtr->dispPtr->iconDataSize;
4948
XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
4949
Tk_InternAtom((Tk_Window) winPtr, "_NET_WM_ICON"),
4950
XA_CARDINAL, 32, PropModeReplace,
4951
(unsigned char *) data, size);
4956
*----------------------------------------------------------------------
4960
* Sets the specified state property by sending a _NET_WM_STATE
4961
* ClientMessage to the root window.
4965
* Wrapper window must be created.
4968
* UpdateNetWmState; EWMH spec, section _NET_WM_STATE.
4970
*----------------------------------------------------------------------
4973
#define _NET_WM_STATE_REMOVE 0l
4974
#define _NET_WM_STATE_ADD 1l
4975
#define _NET_WM_STATE_TOGGLE 2l
4977
static void SetNetWmState(TkWindow *winPtr, const char *atomName, int on)
4979
Tk_Window tkwin = (Tk_Window)winPtr;
4980
Atom messageType = Tk_InternAtom(tkwin, "_NET_WM_STATE");
4981
Atom action = on ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
4982
Atom property = Tk_InternAtom(tkwin, atomName);
4985
if (!winPtr->wmInfoPtr->wrapperPtr) {
4989
e.xany.type = ClientMessage;
4990
e.xany.window = winPtr->wmInfoPtr->wrapperPtr->window;
4991
e.xclient.message_type = messageType;
4992
e.xclient.format = 32;
4993
e.xclient.data.l[0] = action;
4994
e.xclient.data.l[1] = property;
4995
e.xclient.data.l[2] = e.xclient.data.l[3] = e.xclient.data.l[4] = 0l;
4997
XSendEvent(winPtr->display,
4998
RootWindow(winPtr->display, winPtr->screenNum), 0,
4999
SubstructureNotifyMask|SubstructureRedirectMask, &e);
5003
* CheckNetWmState --
5005
* Updates the window attributes whenever the _NET_WM_STATE
5010
* Tk uses a single -zoomed state, while the EWMH spec supports
5011
* separate vertical and horizontal maximization. We consider
5012
* the window to be "zoomed" if _NET_WM_STATE_MAXIMIZED_VERT
5013
* and _NET_WM_STATE_MAXIMIZED_HORZ are both set.
5015
static void CheckNetWmState(WmInfo *wmPtr, Atom *atoms, int numAtoms)
5017
Tk_Window tkwin = (Tk_Window)wmPtr->wrapperPtr;
5019
Atom _NET_WM_STATE_ABOVE
5020
= Tk_InternAtom(tkwin, "_NET_WM_STATE_ABOVE"),
5021
_NET_WM_STATE_MAXIMIZED_VERT
5022
= Tk_InternAtom(tkwin, "_NET_WM_STATE_MAXIMIZED_VERT"),
5023
_NET_WM_STATE_MAXIMIZED_HORZ
5024
= Tk_InternAtom(tkwin, "_NET_WM_STATE_MAXIMIZED_HORZ"),
5025
_NET_WM_STATE_FULLSCREEN
5026
= Tk_InternAtom(tkwin, "_NET_WM_STATE_FULLSCREEN");
5028
wmPtr->attributes.topmost = 0;
5029
wmPtr->attributes.zoomed = 0;
5030
wmPtr->attributes.fullscreen = 0;
5031
for (i = 0; i < numAtoms; ++i) {
5032
if (atoms[i] == _NET_WM_STATE_ABOVE) {
5033
wmPtr->attributes.topmost = 1;
5034
} else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
5035
wmPtr->attributes.zoomed |= 1;
5036
} else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
5037
wmPtr->attributes.zoomed |= 2;
5038
} else if (atoms[i] == _NET_WM_STATE_FULLSCREEN) {
5039
wmPtr->attributes.fullscreen = 1;
5043
wmPtr->attributes.zoomed = (wmPtr->attributes.zoomed == 3);
5049
* UpdateNetWmState --
5051
* Sets the _NET_WM_STATE property to match the requested attribute state
5052
* just prior to mapping a withdrawn window.
5054
#define NET_WM_STATE_MAX_ATOMS 4
5055
static void UpdateNetWmState(WmInfo *wmPtr)
5057
Tk_Window tkwin = (Tk_Window)wmPtr->wrapperPtr;
5058
Atom atoms[NET_WM_STATE_MAX_ATOMS];
5061
if (wmPtr->reqState.topmost) {
5062
atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_ABOVE");
5064
if (wmPtr->reqState.zoomed) {
5065
atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_MAXIMIZED_VERT");
5066
atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_MAXIMIZED_HORZ");
5068
if (wmPtr->reqState.fullscreen) {
5069
atoms[numAtoms++] = Tk_InternAtom(tkwin, "_NET_WM_STATE_FULLSCREEN");
5072
XChangeProperty(Tk_Display(tkwin), wmPtr->wrapperPtr->window,
5073
Tk_InternAtom(tkwin, "_NET_WM_STATE"), XA_ATOM, 32,
5074
PropModeReplace, (unsigned char *)atoms, numAtoms);
4419
5078
*----------------------------------------------------------------------
4421
5080
* WaitForConfigureNotify --
4423
* This procedure is invoked in order to synchronize with the
4424
* window manager. It waits for a ConfigureNotify event to
4425
* arrive, signalling that the window manager has seen an attempt
4426
* on our part to move or resize a top-level window.
5082
* This function is invoked in order to synchronize with the window
5083
* manager. It waits for a ConfigureNotify event to arrive, signalling
5084
* that the window manager has seen an attempt on our part to move or
5085
* resize a top-level window.
4431
5090
* Side effects:
4432
5091
* Delays the execution of the process until a ConfigureNotify event
4433
* arrives with serial number at least as great as serial. This
4434
* is useful for two reasons:
5092
* arrives with serial number at least as great as serial. This is useful
4436
5095
* 1. It's important to distinguish ConfigureNotify events that are
4437
5096
* coming in response to a request we've made from those generated
4438
* spontaneously by the user. The reason for this is that if the
4439
* user resizes the window we take that as an order to ignore
4440
* geometry requests coming from inside the window hierarchy. If
4441
* we accidentally interpret a response to our request as a
4442
* user-initiated action, the window will stop responding to
4443
* new geometry requests. To make this distinction, (a) this
4444
* procedure sets a flag for TopLevelEventProc to indicate that
4445
* we're waiting to sync with the wm, and (b) all changes to
4446
* the size of a top-level window are followed by calls to this
4448
* 2. Races and confusion can come about if there are multiple
4449
* operations outstanding at a time (e.g. two different resizes
4450
* of the top-level window: it's hard to tell which of the
4451
* ConfigureNotify events coming back is for which request).
5097
* spontaneously by the user. The reason for this is that if the user
5098
* resizes the window we take that as an order to ignore geometry
5099
* requests coming from inside the window hierarchy. If we
5100
* accidentally interpret a response to our request as a
5101
* user-initiated action, the window will stop responding to new
5102
* geometry requests. To make this distinction, (a) this function sets
5103
* a flag for TopLevelEventProc to indicate that we're waiting to sync
5104
* with the wm, and (b) all changes to the size of a top-level window
5105
* are followed by calls to this function.
5106
* 2. Races and confusion can come about if there are multiple operations
5107
* outstanding at a time (e.g. two different resizes of the top-level
5108
* window: it's hard to tell which of the ConfigureNotify events
5109
* coming back is for which request).
4452
5110
* While waiting, some events covered by StructureNotifyMask are
4453
* processed (ConfigureNotify, MapNotify, and UnmapNotify)
4454
* and all others are deferred.
5111
* processed (ConfigureNotify, MapNotify, and UnmapNotify) and all others
4456
5114
*----------------------------------------------------------------------
4460
WaitForConfigureNotify(winPtr, serial)
4461
TkWindow *winPtr; /* Top-level window for which we want
4462
* to see a ConfigureNotify. */
4463
unsigned long serial; /* Serial number of resize request. Want to
4464
* be sure wm has seen this. */
5118
WaitForConfigureNotify(
5119
TkWindow *winPtr, /* Top-level window for which we want to see a
5120
* ConfigureNotify. */
5121
unsigned long serial) /* Serial number of resize request. Want to be
5122
* sure wm has seen this. */
4466
5124
WmInfo *wmPtr = winPtr->wmInfoPtr;
5596
6239
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
5597
TkWmStackorderToplevelWrapperMap(parentPtr, &table);
6240
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
5599
window_ptr = windows = (TkWindow **) ckalloc((table.numEntries+1)
5600
* sizeof(TkWindow *));
6242
window_ptr = windows = (TkWindow **)
6243
ckalloc((table.numEntries+1) * sizeof(TkWindow *));
5603
* Special cases: If zero or one toplevels were mapped
5604
* there is no need to call XQueryTree.
6246
* Special cases: If zero or one toplevels were mapped there is no need to
5607
6250
switch (table.numEntries) {
5612
hPtr = Tcl_FirstHashEntry(&table, &search);
5613
windows[0] = (TkWindow *) Tcl_GetHashValue(hPtr);
6255
hPtr = Tcl_FirstHashEntry(&table, &search);
6256
windows[0] = (TkWindow *) Tcl_GetHashValue(hPtr);
5618
6261
vRoot = parentPtr->wmInfoPtr->vRoot;
5619
6262
if (vRoot == None) {
5620
vRoot = RootWindowOfScreen(Tk_Screen((Tk_Window) parentPtr));
6263
vRoot = RootWindowOfScreen(Tk_Screen((Tk_Window) parentPtr));
5623
6266
if (XQueryTree(parentPtr->display, vRoot, &dummy1, &dummy2,
5624
&children, &numChildren) == 0) {
5625
ckfree((char *) windows);
6267
&children, &numChildren) == 0) {
6268
ckfree((char *) windows);
5628
for (i = 0; i < numChildren; i++) {
5629
hPtr = Tcl_FindHashEntry(&table, (char *) children[i]);
5631
childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr);
5632
*window_ptr++ = childWinPtr;
5635
if ((window_ptr - windows) != table.numEntries)
5636
panic("num matched toplevel windows does not equal num children");
6271
for (i = 0; i < numChildren; i++) {
6272
hPtr = Tcl_FindHashEntry(&table, (char *) children[i]);
6274
childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr);
6275
*window_ptr++ = childWinPtr;
6278
if ((window_ptr - windows) != table.numEntries) {
6279
Tcl_Panic("num matched toplevel windows does not equal num children");
5638
6282
if (numChildren) {
5639
6283
XFree((char *) children);
5644
6288
Tcl_DeleteHashTable(&table);
5645
6289
return windows;
6655
TkpWmSetState(winPtr, state)
6656
TkWindow *winPtr; /* Toplevel window to operate on. */
6657
int state; /* One of IconicState, NormalState,
6658
* or WithdrawnState. */
7293
TkWindow *winPtr, /* Toplevel window to operate on. */
7294
int state) /* One of IconicState, NormalState, or
7295
* WithdrawnState. */
6660
7297
WmInfo *wmPtr = winPtr->wmInfoPtr;
6662
7299
if (state == WithdrawnState) {
6663
wmPtr->hints.initial_state = WithdrawnState;
6664
wmPtr->withdrawn = 1;
6665
if (wmPtr->flags & WM_NEVER_MAPPED) {
6668
if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window,
6669
winPtr->screenNum) == 0) {
6672
WaitForMapNotify(winPtr, 0);
7300
wmPtr->hints.initial_state = WithdrawnState;
7301
wmPtr->withdrawn = 1;
7302
if (wmPtr->flags & WM_NEVER_MAPPED) {
7305
if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window,
7306
winPtr->screenNum) == 0) {
7309
WaitForMapNotify(winPtr, 0);
6673
7310
} else if (state == NormalState) {
6674
wmPtr->hints.initial_state = NormalState;
6675
wmPtr->withdrawn = 0;
6676
if (wmPtr->flags & WM_NEVER_MAPPED) {
6679
UpdateHints(winPtr);
6680
Tk_MapWindow((Tk_Window) winPtr);
7311
wmPtr->hints.initial_state = NormalState;
7312
wmPtr->withdrawn = 0;
7313
if (wmPtr->flags & WM_NEVER_MAPPED) {
7316
UpdateHints(winPtr);
7317
Tk_MapWindow((Tk_Window) winPtr);
6681
7318
} else if (state == IconicState) {
6682
wmPtr->hints.initial_state = IconicState;
6683
if (wmPtr->flags & WM_NEVER_MAPPED) {
6686
if (wmPtr->withdrawn) {
6687
UpdateHints(winPtr);
6688
Tk_MapWindow((Tk_Window) winPtr);
6689
wmPtr->withdrawn = 0;
6691
if (XIconifyWindow(winPtr->display, wmPtr->wrapperPtr->window,
6692
winPtr->screenNum) == 0) {
6695
WaitForMapNotify(winPtr, 0);
7319
wmPtr->hints.initial_state = IconicState;
7320
if (wmPtr->flags & WM_NEVER_MAPPED) {
7323
if (wmPtr->withdrawn) {
7324
UpdateHints(winPtr);
7325
Tk_MapWindow((Tk_Window) winPtr);
7326
wmPtr->withdrawn = 0;
7328
if (XIconifyWindow(winPtr->display, wmPtr->wrapperPtr->window,
7329
winPtr->screenNum) == 0) {
7332
WaitForMapNotify(winPtr, 0);