| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "tkPort.h" |
| 19 |
#include "tkInt.h" |
| 20 |
#include "tkUnixInt.h" |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
typedef struct ProtocolHandler { |
| 29 |
Atom protocol; |
| 30 |
struct ProtocolHandler *nextPtr; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
Tcl_Interp *interp; |
| 35 |
#if 0 |
| 36 |
char command[4]; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#else |
| 42 |
LangCallback *command; |
| 43 |
#endif |
| 44 |
} ProtocolHandler; |
| 45 |
|
| 46 |
static void ProtocolFree _ANSI_ARGS_((char *clientData)); |
| 47 |
|
| 48 |
static void |
| 49 |
ProtocolFree(clientData) |
| 50 |
char *clientData; |
| 51 |
{ProtocolHandler *p = (ProtocolHandler *) clientData; |
| 52 |
LangFreeCallback(p->command); |
| 53 |
ckfree((char *) p); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
typedef struct { |
| 60 |
double alpha; |
| 61 |
int topmost; |
| 62 |
int zoomed; |
| 63 |
int fullscreen; |
| 64 |
} WmAttributes; |
| 65 |
|
| 66 |
typedef enum { |
| 67 |
WMATT_ALPHA, WMATT_TOPMOST, WMATT_ZOOMED, WMATT_FULLSCREEN, |
| 68 |
_WMATT_LAST_ATTRIBUTE |
| 69 |
} WmAttribute; |
| 70 |
|
| 71 |
static const char *WmAttributeNames[] = { |
| 72 |
"-alpha", "-topmost", "-zoomed", "-fullscreen", |
| 73 |
NULL |
| 74 |
}; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
typedef struct TkWmInfo { |
| 82 |
TkWindow *winPtr; |
| 83 |
|
| 84 |
Window reparent; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
char *title; |
| 91 |
|
| 92 |
char *iconName; |
| 93 |
XWMHints hints; |
| 94 |
|
| 95 |
char *leaderName; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
TkWindow *masterPtr; |
| 100 |
|
| 101 |
Tk_Window icon; |
| 102 |
|
| 103 |
Tk_Image iconImage; |
| 104 |
Tk_Window iconFor; |
| 105 |
|
| 106 |
int withdrawn; |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
TkWindow *wrapperPtr; |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
Tk_Window menubar; |
| 123 |
|
| 124 |
|
| 125 |
int menuHeight; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
int sizeHintsFlags; |
| 136 |
|
| 137 |
|
| 138 |
int minWidth, minHeight; |
| 139 |
|
| 140 |
int maxWidth, maxHeight; |
| 141 |
|
| 142 |
Tk_Window gridWin; |
| 143 |
|
| 144 |
|
| 145 |
int widthInc, heightInc; |
| 146 |
|
| 147 |
struct { |
| 148 |
int x; |
| 149 |
int y; |
| 150 |
} minAspect, maxAspect; |
| 151 |
int reqGridWidth, reqGridHeight; |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
int gravity; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
int width, height; |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
int x, y; |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
int parentWidth, parentHeight; |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
int xInParent, yInParent; |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
int configWidth, configHeight; |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
Window vRoot; |
| 201 |
|
| 202 |
|
| 203 |
int vRootX, vRootY; |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
int vRootWidth, vRootHeight; |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
WmAttributes attributes; |
| 220 |
WmAttributes reqState; |
| 221 |
ProtocolHandler *protPtr; |
| 222 |
|
| 223 |
#ifndef _LANG |
| 224 |
int cmdArgc; |
| 225 |
CONST char **cmdArgv; |
| 226 |
|
| 227 |
#else |
| 228 |
Tcl_Obj *cmdArg; |
| 229 |
#endif |
| 230 |
char *clientMachine; |
| 231 |
|
| 232 |
int flags; |
| 233 |
int numTransients; |
| 234 |
int iconDataSize; |
| 235 |
unsigned char *iconDataPtr; |
| 236 |
struct TkWmInfo *nextPtr; |
| 237 |
} WmInfo; |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
#define WM_NEVER_MAPPED 1 |
| 285 |
#define WM_UPDATE_PENDING 2 |
| 286 |
#define WM_NEGATIVE_X 4 |
| 287 |
#define WM_NEGATIVE_Y 8 |
| 288 |
#define WM_UPDATE_SIZE_HINTS 0x10 |
| 289 |
#define WM_SYNC_PENDING 0x20 |
| 290 |
#define WM_VROOT_OFFSET_STALE 0x40 |
| 291 |
#define WM_ABOUT_TO_MAP 0x100 |
| 292 |
#define WM_MOVE_PENDING 0x200 |
| 293 |
#define WM_COLORMAPS_EXPLICIT 0x400 |
| 294 |
#define WM_ADDED_TOPLEVEL_COLORMAP 0x800 |
| 295 |
#define WM_WIDTH_NOT_RESIZABLE 0x1000 |
| 296 |
#define WM_HEIGHT_NOT_RESIZABLE 0x2000 |
| 297 |
#define WM_WITHDRAWN 0x4000 |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin); |
| 311 |
static void TopLevelLostSlaveProc _ANSI_ARGS_((ClientData clientData, |
| 312 |
Tk_Window tkwin)); |
| 313 |
|
| 314 |
|
| 315 |
static Tk_GeomMgr wmMgrType = { |
| 316 |
"wm", |
| 317 |
TopLevelReqProc, |
| 318 |
TopLevelLostSlaveProc, |
| 319 |
}; |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
static void TkWmFreeCmd _ANSI_ARGS_((WmInfo *wmPtr)); |
| 325 |
|
| 326 |
static void ImageChangedProc _ANSI_ARGS_((ClientData clientData, |
| 327 |
int x, int y, int width, int height, int imageWidth, |
| 328 |
int imageHeight)); |
| 329 |
|
| 330 |
static void MenubarReqProc _ANSI_ARGS_((ClientData clientData, |
| 331 |
Tk_Window tkwin)); |
| 332 |
|
| 333 |
static Tk_GeomMgr menubarMgrType = { |
| 334 |
"menubar", |
| 335 |
MenubarReqProc, |
| 336 |
NULL, |
| 337 |
}; |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
typedef struct WaitRestrictInfo { |
| 345 |
Display *display; |
| 346 |
WmInfo *wmInfoPtr; |
| 347 |
int type; |
| 348 |
XEvent *eventPtr; |
| 349 |
int foundEvent; |
| 350 |
|
| 351 |
} WaitRestrictInfo; |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
static int ComputeReparentGeometry _ANSI_ARGS_((WmInfo *wmPtr)); |
| 358 |
static void ConfigureEvent _ANSI_ARGS_((WmInfo *wmPtr, |
| 359 |
XConfigureEvent *eventPtr)); |
| 360 |
static void CreateWrapper _ANSI_ARGS_((WmInfo *wmPtr)); |
| 361 |
static void GetMaxSize _ANSI_ARGS_((WmInfo *wmPtr, |
| 362 |
int *maxWidthPtr, int *maxHeightPtr)); |
| 363 |
static void MenubarDestroyProc _ANSI_ARGS_((ClientData clientData, |
| 364 |
XEvent *eventPtr)); |
| 365 |
static int ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp, |
| 366 |
char *string, TkWindow *winPtr)); |
| 367 |
static void ReparentEvent _ANSI_ARGS_((WmInfo *wmPtr, |
| 368 |
XReparentEvent *eventPtr)); |
| 369 |
static void TkWmStackorderToplevelWrapperMap _ANSI_ARGS_(( |
| 370 |
TkWindow *winPtr, |
| 371 |
Display *display, |
| 372 |
Tcl_HashTable *reparentTable)); |
| 373 |
static void TopLevelEventProc _ANSI_ARGS_((ClientData clientData, |
| 374 |
XEvent *eventPtr)); |
| 375 |
static void TopLevelReqProc _ANSI_ARGS_((ClientData dummy, |
| 376 |
Tk_Window tkwin)); |
| 377 |
static void UpdateCommand _ANSI_ARGS_((TkWindow *winPtr)); |
| 378 |
static void UpdateGeometryInfo _ANSI_ARGS_(( |
| 379 |
ClientData clientData)); |
| 380 |
static void UpdateHints _ANSI_ARGS_((TkWindow *winPtr)); |
| 381 |
static void UpdateSizeHints _ANSI_ARGS_((TkWindow *winPtr, |
| 382 |
int newWidth, |
| 383 |
int newHeight)); |
| 384 |
static void UpdateTitle(TkWindow *winPtr); |
| 385 |
static void UpdatePhotoIcon(TkWindow *winPtr); |
| 386 |
static void UpdateVRootGeometry _ANSI_ARGS_((WmInfo *wmPtr)); |
| 387 |
static void UpdateWmProtocols _ANSI_ARGS_((WmInfo *wmPtr)); |
| 388 |
static void SetNetWmState(TkWindow*, const char *atomName, int on); |
| 389 |
static void CheckNetWmState(WmInfo *, Atom *atoms, int numAtoms); |
| 390 |
static void UpdateNetWmState(WmInfo *); |
| 391 |
static void WaitForConfigureNotify _ANSI_ARGS_((TkWindow *winPtr, |
| 392 |
unsigned long serial)); |
| 393 |
static int WaitForEvent _ANSI_ARGS_((Display *display, |
| 394 |
WmInfo *wmInfoPtr, int type, XEvent *eventPtr)); |
| 395 |
static void WaitForMapNotify _ANSI_ARGS_((TkWindow *winPtr, |
| 396 |
int mapped)); |
| 397 |
|
| 398 |
static void UnmanageGeometry _ANSI_ARGS_((Tk_Window tkwin)); |
| 399 |
|
| 400 |
static int WmProtocolCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 401 |
Tcl_Interp *interp, int objc, |
| 402 |
Tcl_Obj *CONST objv[]); |
| 403 |
static int WmResizableCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 404 |
Tcl_Interp *interp, int objc, |
| 405 |
Tcl_Obj *CONST objv[]); |
| 406 |
static int WmSizefromCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 407 |
Tcl_Interp *interp, int objc, |
| 408 |
Tcl_Obj *CONST objv[]); |
| 409 |
static int WmStackorderCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 410 |
Tcl_Interp *interp, int objc, |
| 411 |
Tcl_Obj *CONST objv[]); |
| 412 |
static int WmStateCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 413 |
Tcl_Interp *interp, int objc, |
| 414 |
Tcl_Obj *CONST objv[]); |
| 415 |
static int WmTitleCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 416 |
Tcl_Interp *interp, int objc, |
| 417 |
Tcl_Obj *CONST objv[]); |
| 418 |
static int WmTransientCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 419 |
Tcl_Interp *interp, int objc, |
| 420 |
Tcl_Obj *CONST objv[]); |
| 421 |
static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 422 |
Tcl_Interp *interp, int objc, |
| 423 |
Tcl_Obj *CONST objv[]); |
| 424 |
static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); |
| 425 |
static Tk_RestrictAction |
| 426 |
WaitRestrictProc _ANSI_ARGS_((ClientData clientData, |
| 427 |
XEvent *eventPtr)); |
| 428 |
static void WrapperEventProc _ANSI_ARGS_((ClientData clientData, |
| 429 |
XEvent *eventPtr)); |
| 430 |
static void WmWaitMapProc _ANSI_ARGS_(( |
| 431 |
ClientData clientData, XEvent *eventPtr)); |
| 432 |
|
| 433 |
static int WmAspectCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 434 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 435 |
Tcl_Obj *CONST objv[])); |
| 436 |
static int WmAttributesCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 437 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 438 |
Tcl_Obj *CONST objv[])); |
| 439 |
static int WmCaptureCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 440 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 441 |
Tcl_Obj *CONST objv[])); |
| 442 |
static int WmClientCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 443 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 444 |
Tcl_Obj *CONST objv[])); |
| 445 |
static int WmColormapwindowsCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 446 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 447 |
Tcl_Obj *CONST objv[])); |
| 448 |
static int WmCommandCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 449 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 450 |
Tcl_Obj *CONST objv[])); |
| 451 |
static int WmDeiconifyCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 452 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 453 |
Tcl_Obj *CONST objv[])); |
| 454 |
static int WmFocusmodelCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 455 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 456 |
Tcl_Obj *CONST objv[])); |
| 457 |
static int WmFrameCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 458 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 459 |
Tcl_Obj *CONST objv[])); |
| 460 |
static int WmGeometryCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 461 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 462 |
Tcl_Obj *CONST objv[])); |
| 463 |
static int WmGridCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 464 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 465 |
Tcl_Obj *CONST objv[])); |
| 466 |
static int WmGroupCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 467 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 468 |
Tcl_Obj *CONST objv[])); |
| 469 |
static int WmIconbitmapCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 470 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 471 |
Tcl_Obj *CONST objv[])); |
| 472 |
static int WmIconifyCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 473 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 474 |
Tcl_Obj *CONST objv[])); |
| 475 |
static int WmIconimageCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 476 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 477 |
Tcl_Obj *CONST objv[])); |
| 478 |
static int WmIconmaskCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 479 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 480 |
Tcl_Obj *CONST objv[])); |
| 481 |
static int WmIconnameCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 482 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 483 |
Tcl_Obj *CONST objv[])); |
| 484 |
static int WmIconphotoCmd(Tk_Window tkwin, TkWindow *winPtr, |
| 485 |
Tcl_Interp *interp, int objc, |
| 486 |
Tcl_Obj *CONST objv[]); |
| 487 |
static int WmIconpositionCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 488 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 489 |
Tcl_Obj *CONST objv[])); |
| 490 |
static int WmIconwindowCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 491 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 492 |
Tcl_Obj *CONST objv[])); |
| 493 |
static int WmMaxsizeCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 494 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 495 |
Tcl_Obj *CONST objv[])); |
| 496 |
static int WmMinsizeCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 497 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 498 |
Tcl_Obj *CONST objv[])); |
| 499 |
static int WmOverrideredirectCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 500 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 501 |
Tcl_Obj *CONST objv[])); |
| 502 |
static int WmPositionfromCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 503 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 504 |
Tcl_Obj *CONST objv[])); |
| 505 |
static int WmProtocolCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 506 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 507 |
Tcl_Obj *CONST objv[])); |
| 508 |
static int WmReleaseCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 509 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 510 |
Tcl_Obj *CONST objv[])); |
| 511 |
static int WmResizableCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 512 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 513 |
Tcl_Obj *CONST objv[])); |
| 514 |
static int WmSizefromCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 515 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 516 |
Tcl_Obj *CONST objv[])); |
| 517 |
static int WmStackorderCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 518 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 519 |
Tcl_Obj *CONST objv[])); |
| 520 |
static int WmStateCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 521 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 522 |
Tcl_Obj *CONST objv[])); |
| 523 |
static int WmTitleCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 524 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 525 |
Tcl_Obj *CONST objv[])); |
| 526 |
static int WmTransientCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 527 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 528 |
Tcl_Obj *CONST objv[])); |
| 529 |
static int WmWithdrawCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 530 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 531 |
Tcl_Obj *CONST objv[])); |
| 532 |
static int WmWrapperCmd _ANSI_ARGS_((Tk_Window tkwin, |
| 533 |
TkWindow *winPtr, Tcl_Interp *interp, int objc, |
| 534 |
Tcl_Obj *CONST objv[])); |
| 535 |
static void WmUpdateGeom _ANSI_ARGS_((WmInfo *wmPtr, |
| 536 |
TkWindow *winPtr)); |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
static void |
| 556 |
TkWmFreeCmd(wmPtr) |
| 557 |
WmInfo *wmPtr; |
| 558 |
{ |
| 559 |
if (wmPtr->cmdArg) { |
| 560 |
Tcl_DecrRefCount(wmPtr->cmdArg); |
| 561 |
wmPtr->cmdArg = NULL; |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
void TkWmCleanup( |
| 566 |
TkDisplay *dispPtr) |
| 567 |
{ |
| 568 |
WmInfo *wmPtr, *nextPtr; |
| 569 |
|
| 570 |
for (wmPtr = dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = nextPtr) { |
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
nextPtr = wmPtr->nextPtr; |
| 577 |
if (wmPtr->title != NULL) { |
| 578 |
ckfree(wmPtr->title); |
| 579 |
} |
| 580 |
if (wmPtr->iconName != NULL) { |
| 581 |
ckfree(wmPtr->iconName); |
| 582 |
} |
| 583 |
if (wmPtr->iconDataPtr != NULL) { |
| 584 |
ckfree((char *)wmPtr->iconDataPtr); |
| 585 |
} |
| 586 |
if (wmPtr->leaderName != NULL) { |
| 587 |
ckfree(wmPtr->leaderName); |
| 588 |
} |
| 589 |
if (wmPtr->menubar != NULL) { |
| 590 |
Tk_DestroyWindow(wmPtr->menubar); |
| 591 |
} |
| 592 |
if (wmPtr->wrapperPtr != NULL) { |
| 593 |
Tk_DestroyWindow((Tk_Window) wmPtr->wrapperPtr); |
| 594 |
} |
| 595 |
while (wmPtr->protPtr != NULL) { |
| 596 |
ProtocolHandler *protPtr; |
| 597 |
|
| 598 |
protPtr = wmPtr->protPtr; |
| 599 |
wmPtr->protPtr = protPtr->nextPtr; |
| 600 |
Tcl_EventuallyFree((ClientData) protPtr, ProtocolFree); |
| 601 |
} |
| 602 |
#ifdef _LANG |
| 603 |
TkWmFreeCmd(wmPtr); |
| 604 |
#else |
| 605 |
if (wmPtr->cmdArgv != NULL) { |
| 606 |
ckfree((char *) wmPtr->cmdArgv); |
| 607 |
} |
| 608 |
#endif |
| 609 |
if (wmPtr->clientMachine != NULL) { |
| 610 |
ckfree((char *) wmPtr->clientMachine); |
| 611 |
} |
| 612 |
ckfree((char *) wmPtr); |
| 613 |
} |
| 614 |
if (dispPtr->iconDataPtr != NULL) { |
| 615 |
ckfree((char *)dispPtr->iconDataPtr); |
| 616 |
dispPtr->iconDataPtr = NULL; |
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
void |
| 638 |
TkWmNewWindow( |
| 639 |
TkWindow *winPtr) |
| 640 |
{ |
| 641 |
register WmInfo *wmPtr; |
| 642 |
TkDisplay *dispPtr = winPtr->dispPtr; |
| 643 |
|
| 644 |
wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo)); |
| 645 |
memset(wmPtr, 0, sizeof(WmInfo)); |
| 646 |
wmPtr->winPtr = winPtr; |
| 647 |
wmPtr->reparent = None; |
| 648 |
wmPtr->masterPtr = NULL; |
| 649 |
wmPtr->numTransients = 0; |
| 650 |
wmPtr->hints.flags = InputHint | StateHint; |
| 651 |
wmPtr->hints.input = True; |
| 652 |
wmPtr->hints.initial_state = NormalState; |
| 653 |
wmPtr->hints.icon_pixmap = None; |
| 654 |
wmPtr->hints.icon_window = None; |
| 655 |
wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; |
| 656 |
wmPtr->hints.icon_mask = None; |
| 657 |
wmPtr->hints.window_group = None; |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
wmPtr->attributes.alpha = 1.0; |
| 663 |
wmPtr->attributes.topmost = 0; |
| 664 |
wmPtr->attributes.zoomed = 0; |
| 665 |
wmPtr->attributes.fullscreen = 0; |
| 666 |
wmPtr->reqState = wmPtr->attributes; |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
wmPtr->gridWin = NULL; |
| 674 |
wmPtr->minWidth = wmPtr->minHeight = 1; |
| 675 |
wmPtr->maxWidth = wmPtr->maxHeight = 0; |
| 676 |
wmPtr->widthInc = wmPtr->heightInc = 1; |
| 677 |
wmPtr->minAspect.x = wmPtr->minAspect.y = 1; |
| 678 |
wmPtr->maxAspect.x = wmPtr->maxAspect.y = 1; |
| 679 |
wmPtr->reqGridWidth = wmPtr->reqGridHeight = -1; |
| 680 |
wmPtr->gravity = NorthWestGravity; |
| 681 |
wmPtr->width = -1; |
| 682 |
wmPtr->height = -1; |
| 683 |
wmPtr->x = winPtr->changes.x; |
| 684 |
wmPtr->y = winPtr->changes.y; |
| 685 |
wmPtr->parentWidth = winPtr->changes.width |
| 686 |
+ 2*winPtr->changes.border_width; |
| 687 |
wmPtr->parentHeight = winPtr->changes.height |
| 688 |
+ 2*winPtr->changes.border_width; |
| 689 |
wmPtr->configWidth = -1; |
| 690 |
wmPtr->configHeight = -1; |
| 691 |
wmPtr->vRoot = None; |
| 692 |
wmPtr->flags = WM_NEVER_MAPPED; |
| 693 |
wmPtr->nextPtr = (WmInfo *) dispPtr->firstWmPtr; |
| 694 |
dispPtr->firstWmPtr = wmPtr; |
| 695 |
winPtr->wmInfoPtr = wmPtr; |
| 696 |
|
| 697 |
UpdateVRootGeometry(wmPtr); |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0); |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
void |
| 731 |
TkWmMapWindow( |
| 732 |
TkWindow *winPtr) |
| 733 |
|
| 734 |
{ |
| 735 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 736 |
XTextProperty textProp; |
| 737 |
|
| 738 |
if (wmPtr->flags & WM_NEVER_MAPPED) { |
| 739 |
Tcl_DString ds; |
| 740 |
|
| 741 |
wmPtr->flags &= ~WM_NEVER_MAPPED; |
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
if (wmPtr->wrapperPtr == NULL) { |
| 749 |
CreateWrapper(wmPtr); |
| 750 |
} |
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
#if 0 |
| 757 |
REMOVED >>>> ORIGINAL tkUnixWm.c#1 |
| 758 |
if (XStringListToTextProperty(&(Tcl_DStringValue(&ds)), 1, |
| 759 |
&textProp) != 0) { |
| 760 |
XSetWMName(winPtr->display, wmPtr->wrapperPtr->window, &textProp); |
| 761 |
XFree((char *) textProp.value); |
| 762 |
} |
| 763 |
Tcl_DStringFree(&ds); |
| 764 |
|
| 765 |
REMOVED ==== THEIRS tkUnixWm.c#3 |
| 766 |
REMOVED ==== YOURS tkUnixWm.c |
| 767 |
if (XStringListToTextProperty((char **)&string, 1, |
| 768 |
&textProp) != 0) { |
| 769 |
XSetWMName(winPtr->display, wmPtr->wrapperPtr->window, &textProp); |
| 770 |
XFree((char *) textProp.value); |
| 771 |
} |
| 772 |
Tcl_DStringFree(&ds); |
| 773 |
|
| 774 |
REMOVED <<<< |
| 775 |
#endif |
| 776 |
TkWmSetClass(winPtr); |
| 777 |
UpdateTitle(winPtr); |
| 778 |
UpdatePhotoIcon(winPtr); |
| 779 |
|
| 780 |
if (wmPtr->masterPtr != NULL) { |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
if (!Tk_IsMapped(wmPtr->masterPtr)) { |
| 786 |
wmPtr->withdrawn = 1; |
| 787 |
wmPtr->hints.initial_state = WithdrawnState; |
| 788 |
} else { |
| 789 |
XSetTransientForHint(winPtr->display, |
| 790 |
wmPtr->wrapperPtr->window, |
| 791 |
wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window); |
| 792 |
} |
| 793 |
} |
| 794 |
|
| 795 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 796 |
UpdateHints(winPtr); |
| 797 |
UpdateWmProtocols(wmPtr); |
| 798 |
if (wmPtr->cmdArg != NULL) { |
| 799 |
UpdateCommand(winPtr); |
| 800 |
} |
| 801 |
if (wmPtr->clientMachine != NULL) { |
| 802 |
char *temp; |
| 803 |
Tcl_UtfToExternalDString(NULL, wmPtr->clientMachine, -1, &ds); |
| 804 |
temp = Tcl_DStringValue(&ds); |
| 805 |
if (XStringListToTextProperty(&temp, 1, |
| 806 |
&textProp) != 0) { |
| 807 |
XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window, |
| 808 |
&textProp); |
| 809 |
XFree((char *) textProp.value); |
| 810 |
} |
| 811 |
Tcl_DStringFree(&ds); |
| 812 |
} |
| 813 |
} |
| 814 |
if (wmPtr->hints.initial_state == WithdrawnState) { |
| 815 |
return; |
| 816 |
} |
| 817 |
if (wmPtr->iconFor != NULL) { |
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
if (wmPtr->flags & WM_UPDATE_PENDING) { |
| 824 |
Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); |
| 825 |
} |
| 826 |
UpdateGeometryInfo((ClientData) winPtr); |
| 827 |
return; |
| 828 |
} |
| 829 |
wmPtr->flags |= WM_ABOUT_TO_MAP; |
| 830 |
if (wmPtr->flags & WM_UPDATE_PENDING) { |
| 831 |
Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); |
| 832 |
} |
| 833 |
UpdateGeometryInfo((ClientData) winPtr); |
| 834 |
wmPtr->flags &= ~WM_ABOUT_TO_MAP; |
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
UpdateNetWmState(wmPtr); |
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
XMapWindow(winPtr->display, wmPtr->wrapperPtr->window); |
| 847 |
if (wmPtr->hints.initial_state == NormalState) { |
| 848 |
WaitForMapNotify(winPtr, 1); |
| 849 |
} |
| 850 |
} |
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
void |
| 870 |
TkWmUnmapWindow( |
| 871 |
TkWindow *winPtr) |
| 872 |
|
| 873 |
{ |
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
XUnmapWindow(winPtr->display, winPtr->wmInfoPtr->wrapperPtr->window); |
| 885 |
WaitForMapNotify(winPtr, 0); |
| 886 |
} |
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
void |
| 908 |
TkWmDeadWindow( |
| 909 |
TkWindow *winPtr) |
| 910 |
{ |
| 911 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 912 |
WmInfo *wmPtr2; |
| 913 |
|
| 914 |
if (wmPtr == NULL) { |
| 915 |
return; |
| 916 |
} |
| 917 |
if ((WmInfo *) winPtr->dispPtr->firstWmPtr == wmPtr) { |
| 918 |
winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr; |
| 919 |
} else { |
| 920 |
register WmInfo *prevPtr; |
| 921 |
|
| 922 |
for (prevPtr = (WmInfo *) winPtr->dispPtr->firstWmPtr; ; |
| 923 |
prevPtr = prevPtr->nextPtr) { |
| 924 |
if (prevPtr == NULL) { |
| 925 |
Tcl_Panic("couldn't unlink window in TkWmDeadWindow"); |
| 926 |
} |
| 927 |
if (prevPtr->nextPtr == wmPtr) { |
| 928 |
prevPtr->nextPtr = wmPtr->nextPtr; |
| 929 |
break; |
| 930 |
} |
| 931 |
} |
| 932 |
} |
| 933 |
if (wmPtr->title != NULL) { |
| 934 |
ckfree(wmPtr->title); |
| 935 |
} |
| 936 |
if (wmPtr->iconName != NULL) { |
| 937 |
ckfree(wmPtr->iconName); |
| 938 |
} |
| 939 |
if (wmPtr->iconDataPtr != NULL) { |
| 940 |
ckfree((char *)wmPtr->iconDataPtr); |
| 941 |
} |
| 942 |
|
| 943 |
if (wmPtr->hints.icon_pixmap) { |
| 944 |
if (wmPtr->iconImage) { |
| 945 |
Tk_FreePixmap(winPtr->display, wmPtr->hints.icon_pixmap); |
| 946 |
} else { |
| 947 |
Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
if (wmPtr->iconImage) { |
| 952 |
Tk_FreeImage(wmPtr->iconImage); |
| 953 |
} |
| 954 |
|
| 955 |
if (wmPtr->hints.flags & IconMaskHint) { |
| 956 |
Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); |
| 957 |
} |
| 958 |
if (wmPtr->leaderName != NULL) { |
| 959 |
ckfree(wmPtr->leaderName); |
| 960 |
} |
| 961 |
if (wmPtr->icon != NULL) { |
| 962 |
wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; |
| 963 |
wmPtr2->iconFor = NULL; |
| 964 |
wmPtr2->withdrawn = 1; |
| 965 |
} |
| 966 |
if (wmPtr->iconFor != NULL) { |
| 967 |
wmPtr2 = ((TkWindow *) wmPtr->iconFor)->wmInfoPtr; |
| 968 |
wmPtr2->icon = NULL; |
| 969 |
wmPtr2->hints.flags &= ~IconWindowHint; |
| 970 |
UpdateHints((TkWindow *) wmPtr->iconFor); |
| 971 |
} |
| 972 |
if (wmPtr->menubar != NULL) { |
| 973 |
Tk_DestroyWindow(wmPtr->menubar); |
| 974 |
} |
| 975 |
if (wmPtr->wrapperPtr != NULL) { |
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
XUnmapWindow(winPtr->display, winPtr->window); |
| 984 |
XReparentWindow(winPtr->display, winPtr->window, |
| 985 |
XRootWindow(winPtr->display, winPtr->screenNum), 0, 0); |
| 986 |
Tk_DestroyWindow((Tk_Window) wmPtr->wrapperPtr); |
| 987 |
} |
| 988 |
while (wmPtr->protPtr != NULL) { |
| 989 |
ProtocolHandler *protPtr; |
| 990 |
|
| 991 |
protPtr = wmPtr->protPtr; |
| 992 |
wmPtr->protPtr = protPtr->nextPtr; |
| 993 |
Tcl_EventuallyFree((ClientData) protPtr, ProtocolFree); |
| 994 |
} |
| 995 |
#ifdef _LANG |
| 996 |
TkWmFreeCmd(wmPtr); |
| 997 |
#else |
| 998 |
if (wmPtr->cmdArgv != NULL) { |
| 999 |
ckfree((char *) wmPtr->cmdArgv); |
| 1000 |
} |
| 1001 |
#endif |
| 1002 |
if (wmPtr->clientMachine != NULL) { |
| 1003 |
ckfree((char *) wmPtr->clientMachine); |
| 1004 |
} |
| 1005 |
if (wmPtr->flags & WM_UPDATE_PENDING) { |
| 1006 |
Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL; |
| 1014 |
wmPtr2 = wmPtr2->nextPtr) { |
| 1015 |
if (wmPtr2->masterPtr == winPtr) { |
| 1016 |
wmPtr->numTransients--; |
| 1017 |
Tk_DeleteEventHandler((Tk_Window) wmPtr2->masterPtr, |
| 1018 |
StructureNotifyMask, |
| 1019 |
WmWaitMapProc, (ClientData) wmPtr2->winPtr); |
| 1020 |
wmPtr2->masterPtr = NULL; |
| 1021 |
if (!(wmPtr2->flags & WM_NEVER_MAPPED)) { |
| 1022 |
XDeleteProperty(winPtr->display, wmPtr2->wrapperPtr->window, |
| 1023 |
Tk_InternAtom((Tk_Window) winPtr, "WM_TRANSIENT_FOR")); |
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
} |
| 1031 |
} |
| 1032 |
} |
| 1033 |
if (wmPtr->numTransients != 0) { |
| 1034 |
Tcl_Panic("numTransients should be 0"); |
| 1035 |
} |
| 1036 |
|
| 1037 |
if (wmPtr->masterPtr != NULL) { |
| 1038 |
wmPtr2 = wmPtr->masterPtr->wmInfoPtr; |
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
if (wmPtr2 != NULL) { |
| 1045 |
wmPtr2->numTransients--; |
| 1046 |
} |
| 1047 |
Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr, |
| 1048 |
StructureNotifyMask, WmWaitMapProc, (ClientData) winPtr); |
| 1049 |
wmPtr->masterPtr = NULL; |
| 1050 |
} |
| 1051 |
ckfree((char *) wmPtr); |
| 1052 |
winPtr->wmInfoPtr = NULL; |
| 1053 |
} |
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
void |
| 1075 |
TkWmSetClass( |
| 1076 |
TkWindow *winPtr) |
| 1077 |
{ |
| 1078 |
if (winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { |
| 1079 |
return; |
| 1080 |
} |
| 1081 |
|
| 1082 |
if (winPtr->classUid != NULL) { |
| 1083 |
XClassHint *classPtr; |
| 1084 |
Tcl_DString name, class; |
| 1085 |
|
| 1086 |
Tcl_UtfToExternalDString(NULL, winPtr->nameUid, -1, &name); |
| 1087 |
Tcl_UtfToExternalDString(NULL, winPtr->classUid, -1, &class); |
| 1088 |
classPtr = XAllocClassHint(); |
| 1089 |
classPtr->res_name = Tcl_DStringValue(&name); |
| 1090 |
classPtr->res_class = Tcl_DStringValue(&class); |
| 1091 |
XSetClassHint(winPtr->display, winPtr->wmInfoPtr->wrapperPtr->window, |
| 1092 |
classPtr); |
| 1093 |
XFree((char *) classPtr); |
| 1094 |
Tcl_DStringFree(&name); |
| 1095 |
Tcl_DStringFree(&class); |
| 1096 |
} |
| 1097 |
} |
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
static |
| 1117 |
void |
| 1118 |
TopLevelLostSlaveProc(clientData, tkwin) |
| 1119 |
ClientData clientData; |
| 1120 |
Tk_Window tkwin; |
| 1121 |
{ |
| 1122 |
|
| 1123 |
} |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
int |
| 1137 |
Tk_WmObjCmd( |
| 1138 |
ClientData clientData, |
| 1139 |
Tcl_Interp *interp, |
| 1140 |
int objc, |
| 1141 |
Tcl_Obj *CONST objv[]) |
| 1142 |
{ |
| 1143 |
Tk_Window tkwin = (Tk_Window) clientData; |
| 1144 |
static CONST char *optionStrings[] = { |
| 1145 |
"aspect", "attributes", "capture", "client", "colormapwindows", |
| 1146 |
"command", "deiconify", "focusmodel", "frame", |
| 1147 |
"geometry", "grid", "group", "iconbitmap", |
| 1148 |
"iconify", "iconimage", "iconmask", "iconname", |
| 1149 |
"iconphoto", "iconposition", |
| 1150 |
"iconwindow", "maxsize", "minsize", "overrideredirect", |
| 1151 |
"positionfrom", "protocol", "release", "resizable", "sizefrom", |
| 1152 |
"stackorder", "state", "title", "transient", |
| 1153 |
"withdraw", "wrapper", NULL }; |
| 1154 |
enum options { |
| 1155 |
WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CAPTURE, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS, |
| 1156 |
WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME, |
| 1157 |
WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP, |
| 1158 |
WMOPT_ICONIFY, WMOPT_ICONIMAGE, WMOPT_ICONMASK, WMOPT_ICONNAME, |
| 1159 |
WMOPT_ICONPHOTO, WMOPT_ICONPOSITION, |
| 1160 |
WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, |
| 1161 |
WMOPT_POSITIONFROM, WMOPT_PROTOCOL, WMOPT_RELEASE, WMOPT_RESIZABLE, WMOPT_SIZEFROM, |
| 1162 |
WMOPT_STACKORDER, WMOPT_STATE, WMOPT_TITLE, WMOPT_TRANSIENT, |
| 1163 |
WMOPT_WITHDRAW, WMOPT_WRAPPER }; |
| 1164 |
int index; |
| 1165 |
int length; |
| 1166 |
char *argv1; |
| 1167 |
TkWindow *winPtr; |
| 1168 |
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; |
| 1169 |
|
| 1170 |
if (objc < 2) { |
| 1171 |
wrongNumArgs: |
| 1172 |
Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?"); |
| 1173 |
return TCL_ERROR; |
| 1174 |
} |
| 1175 |
|
| 1176 |
argv1 = Tcl_GetStringFromObj(objv[1], &length); |
| 1177 |
if ((argv1[0] == 't') && (strncmp(argv1, "tracing", (size_t) length) == 0) |
| 1178 |
&& (length >= 3)) { |
| 1179 |
int wmTracing; |
| 1180 |
|
| 1181 |
if ((objc != 3) && (objc != 4)) { |
| 1182 |
Tcl_WrongNumArgs(interp, 2, objv, "?boolean?"); |
| 1183 |
return TCL_ERROR; |
| 1184 |
} |
| 1185 |
if (objc == 3) { |
| 1186 |
Tcl_SetResult(interp, |
| 1187 |
((dispPtr->flags & TK_DISPLAY_WM_TRACING) ? "1" : ""), |
| 1188 |
TCL_STATIC); |
| 1189 |
return TCL_OK; |
| 1190 |
} |
| 1191 |
if (Tcl_GetBooleanFromObj(interp, objv[3], &wmTracing) != TCL_OK) { |
| 1192 |
return TCL_ERROR; |
| 1193 |
} |
| 1194 |
if (wmTracing) { |
| 1195 |
dispPtr->flags |= TK_DISPLAY_WM_TRACING; |
| 1196 |
} else { |
| 1197 |
dispPtr->flags &= ~TK_DISPLAY_WM_TRACING; |
| 1198 |
} |
| 1199 |
return TCL_OK; |
| 1200 |
} |
| 1201 |
|
| 1202 |
if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, |
| 1203 |
&index) != TCL_OK) { |
| 1204 |
return TCL_ERROR; |
| 1205 |
} |
| 1206 |
|
| 1207 |
if (objc < 3) { |
| 1208 |
goto wrongNumArgs; |
| 1209 |
} |
| 1210 |
|
| 1211 |
if (TkGetWindowFromObj(interp, tkwin, objv[2], (Tk_Window *) &winPtr) |
| 1212 |
!= TCL_OK) { |
| 1213 |
return TCL_ERROR; |
| 1214 |
} |
| 1215 |
|
| 1216 |
if (Tk_IsTopLevel(winPtr)) { |
| 1217 |
if ((enum options) index == WMOPT_RELEASE) { |
| 1218 |
Tcl_AppendResult(interp, "window \"", winPtr->pathName, |
| 1219 |
"\" is already top-level window", (char *) NULL); |
| 1220 |
return TCL_ERROR; |
| 1221 |
} |
| 1222 |
} |
| 1223 |
else if ((enum options) index != WMOPT_RELEASE) { |
| 1224 |
Tcl_AppendResult(interp, "window \"", winPtr->pathName, |
| 1225 |
"\" isn't a top-level window", NULL); |
| 1226 |
return TCL_ERROR; |
| 1227 |
} |
| 1228 |
|
| 1229 |
switch ((enum options) index) { |
| 1230 |
case WMOPT_ASPECT: |
| 1231 |
return WmAspectCmd(tkwin, winPtr, interp, objc, objv); |
| 1232 |
case WMOPT_ATTRIBUTES: |
| 1233 |
return WmAttributesCmd(tkwin, winPtr, interp, objc, objv); |
| 1234 |
case WMOPT_CLIENT: |
| 1235 |
return WmClientCmd(tkwin, winPtr, interp, objc, objv); |
| 1236 |
case WMOPT_CAPTURE: |
| 1237 |
return WmCaptureCmd(tkwin, winPtr, interp, objc, objv); |
| 1238 |
case WMOPT_COLORMAPWINDOWS: |
| 1239 |
return WmColormapwindowsCmd(tkwin, winPtr, interp, objc, objv); |
| 1240 |
case WMOPT_COMMAND: |
| 1241 |
return WmCommandCmd(tkwin, winPtr, interp, objc, objv); |
| 1242 |
case WMOPT_DEICONIFY: |
| 1243 |
return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv); |
| 1244 |
case WMOPT_FOCUSMODEL: |
| 1245 |
return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv); |
| 1246 |
case WMOPT_FRAME: |
| 1247 |
return WmFrameCmd(tkwin, winPtr, interp, objc, objv); |
| 1248 |
case WMOPT_GEOMETRY: |
| 1249 |
return WmGeometryCmd(tkwin, winPtr, interp, objc, objv); |
| 1250 |
case WMOPT_GRID: |
| 1251 |
return WmGridCmd(tkwin, winPtr, interp, objc, objv); |
| 1252 |
case WMOPT_GROUP: |
| 1253 |
return WmGroupCmd(tkwin, winPtr, interp, objc, objv); |
| 1254 |
case WMOPT_ICONBITMAP: |
| 1255 |
return WmIconbitmapCmd(tkwin, winPtr, interp, objc, objv); |
| 1256 |
case WMOPT_ICONIFY: |
| 1257 |
return WmIconifyCmd(tkwin, winPtr, interp, objc, objv); |
| 1258 |
case WMOPT_ICONIMAGE: |
| 1259 |
return WmIconimageCmd(tkwin, winPtr, interp, objc, objv); |
| 1260 |
case WMOPT_ICONMASK: |
| 1261 |
return WmIconmaskCmd(tkwin, winPtr, interp, objc, objv); |
| 1262 |
case WMOPT_ICONNAME: |
| 1263 |
return WmIconnameCmd(tkwin, winPtr, interp, objc, objv); |
| 1264 |
case WMOPT_ICONPHOTO: |
| 1265 |
return WmIconphotoCmd(tkwin, winPtr, interp, objc, objv); |
| 1266 |
case WMOPT_ICONPOSITION: |
| 1267 |
return WmIconpositionCmd(tkwin, winPtr, interp, objc, objv); |
| 1268 |
case WMOPT_ICONWINDOW: |
| 1269 |
return WmIconwindowCmd(tkwin, winPtr, interp, objc, objv); |
| 1270 |
case WMOPT_MAXSIZE: |
| 1271 |
return WmMaxsizeCmd(tkwin, winPtr, interp, objc, objv); |
| 1272 |
case WMOPT_MINSIZE: |
| 1273 |
return WmMinsizeCmd(tkwin, winPtr, interp, objc, objv); |
| 1274 |
case WMOPT_OVERRIDEREDIRECT: |
| 1275 |
return WmOverrideredirectCmd(tkwin, winPtr, interp, objc, objv); |
| 1276 |
case WMOPT_POSITIONFROM: |
| 1277 |
return WmPositionfromCmd(tkwin, winPtr, interp, objc, objv); |
| 1278 |
case WMOPT_PROTOCOL: |
| 1279 |
return WmProtocolCmd(tkwin, winPtr, interp, objc, objv); |
| 1280 |
case WMOPT_RESIZABLE: |
| 1281 |
return WmResizableCmd(tkwin, winPtr, interp, objc, objv); |
| 1282 |
case WMOPT_RELEASE: |
| 1283 |
return WmReleaseCmd(tkwin, winPtr, interp, objc, objv); |
| 1284 |
case WMOPT_SIZEFROM: |
| 1285 |
return WmSizefromCmd(tkwin, winPtr, interp, objc, objv); |
| 1286 |
case WMOPT_STACKORDER: |
| 1287 |
return WmStackorderCmd(tkwin, winPtr, interp, objc, objv); |
| 1288 |
case WMOPT_STATE: |
| 1289 |
return WmStateCmd(tkwin, winPtr, interp, objc, objv); |
| 1290 |
case WMOPT_TITLE: |
| 1291 |
return WmTitleCmd(tkwin, winPtr, interp, objc, objv); |
| 1292 |
case WMOPT_TRANSIENT: |
| 1293 |
return WmTransientCmd(tkwin, winPtr, interp, objc, objv); |
| 1294 |
case WMOPT_WITHDRAW: |
| 1295 |
return WmWithdrawCmd(tkwin, winPtr, interp, objc, objv); |
| 1296 |
case WMOPT_WRAPPER: |
| 1297 |
return WmWrapperCmd(tkwin, winPtr, interp, objc, objv); |
| 1298 |
} |
| 1299 |
|
| 1300 |
|
| 1301 |
return TCL_ERROR; |
| 1302 |
} |
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
static int |
| 1322 |
WmAspectCmd( |
| 1323 |
Tk_Window tkwin, |
| 1324 |
TkWindow *winPtr, |
| 1325 |
Tcl_Interp *interp, |
| 1326 |
int objc, |
| 1327 |
Tcl_Obj *CONST objv[]) |
| 1328 |
{ |
| 1329 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1330 |
int numer1, denom1, numer2, denom2; |
| 1331 |
|
| 1332 |
if ((objc != 3) && (objc != 7)) { |
| 1333 |
Tcl_WrongNumArgs(interp, 2, objv, |
| 1334 |
"window ?minNumer minDenom maxNumer maxDenom?"); |
| 1335 |
return TCL_ERROR; |
| 1336 |
} |
| 1337 |
if (objc == 3) { |
| 1338 |
if (wmPtr->sizeHintsFlags & PAspect) { |
| 1339 |
Tcl_IntResults(interp, 4, 0, wmPtr->minAspect.x, |
| 1340 |
wmPtr->minAspect.y, wmPtr->maxAspect.x, |
| 1341 |
wmPtr->maxAspect.y); |
| 1342 |
} |
| 1343 |
return TCL_OK; |
| 1344 |
} |
| 1345 |
if (*Tcl_GetString(objv[3]) == '\0') { |
| 1346 |
wmPtr->sizeHintsFlags &= ~PAspect; |
| 1347 |
} else { |
| 1348 |
if ((Tcl_GetIntFromObj(interp, objv[3], &numer1) != TCL_OK) |
| 1349 |
|| (Tcl_GetIntFromObj(interp, objv[4], &denom1) != TCL_OK) |
| 1350 |
|| (Tcl_GetIntFromObj(interp, objv[5], &numer2) != TCL_OK) |
| 1351 |
|| (Tcl_GetIntFromObj(interp, objv[6], &denom2) != TCL_OK)) { |
| 1352 |
return TCL_ERROR; |
| 1353 |
} |
| 1354 |
if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || |
| 1355 |
(denom2 <= 0)) { |
| 1356 |
Tcl_SetResult(interp, "aspect number can't be <= 0", |
| 1357 |
TCL_STATIC); |
| 1358 |
return TCL_ERROR; |
| 1359 |
} |
| 1360 |
wmPtr->minAspect.x = numer1; |
| 1361 |
wmPtr->minAspect.y = denom1; |
| 1362 |
wmPtr->maxAspect.x = numer2; |
| 1363 |
wmPtr->maxAspect.y = denom2; |
| 1364 |
wmPtr->sizeHintsFlags |= PAspect; |
| 1365 |
} |
| 1366 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 1367 |
WmUpdateGeom(wmPtr, winPtr); |
| 1368 |
return TCL_OK; |
| 1369 |
} |
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
static int WmSetAttribute( |
| 1387 |
TkWindow *winPtr, |
| 1388 |
Tcl_Interp *interp, |
| 1389 |
WmAttribute attribute, |
| 1390 |
Tcl_Obj *value) |
| 1391 |
{ |
| 1392 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1393 |
switch (attribute) { |
| 1394 |
case WMATT_ALPHA: |
| 1395 |
{ |
| 1396 |
unsigned long opacity; |
| 1397 |
|
| 1398 |
if (TCL_OK != Tcl_GetDoubleFromObj( |
| 1399 |
interp, value, &wmPtr->reqState.alpha)) { |
| 1400 |
return TCL_ERROR; |
| 1401 |
} |
| 1402 |
if (wmPtr->reqState.alpha < 0.0) { |
| 1403 |
wmPtr->reqState.alpha = 0.0; |
| 1404 |
} |
| 1405 |
if (wmPtr->reqState.alpha > 1.0) { |
| 1406 |
wmPtr->reqState.alpha = 1.0; |
| 1407 |
} |
| 1408 |
|
| 1409 |
if (!wmPtr->wrapperPtr) { |
| 1410 |
break; |
| 1411 |
} |
| 1412 |
|
| 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; |
| 1419 |
|
| 1420 |
break; |
| 1421 |
} |
| 1422 |
case WMATT_TOPMOST: |
| 1423 |
if (TCL_OK != Tcl_GetBooleanFromObj( |
| 1424 |
interp, value, &wmPtr->reqState.topmost)) { |
| 1425 |
return TCL_ERROR; |
| 1426 |
} |
| 1427 |
SetNetWmState(winPtr, |
| 1428 |
"_NET_WM_STATE_ABOVE", wmPtr->reqState.topmost); |
| 1429 |
break; |
| 1430 |
case WMATT_ZOOMED: |
| 1431 |
if (TCL_OK != Tcl_GetBooleanFromObj( |
| 1432 |
interp, value, &wmPtr->reqState.zoomed)) { |
| 1433 |
return TCL_ERROR; |
| 1434 |
} |
| 1435 |
SetNetWmState(winPtr, |
| 1436 |
"_NET_WM_STATE_MAXIMIZED_VERT", wmPtr->reqState.zoomed); |
| 1437 |
SetNetWmState(winPtr, |
| 1438 |
"_NET_WM_STATE_MAXIMIZED_HORZ", wmPtr->reqState.zoomed); |
| 1439 |
break; |
| 1440 |
case WMATT_FULLSCREEN: |
| 1441 |
if (TCL_OK != Tcl_GetBooleanFromObj( |
| 1442 |
interp, value, &wmPtr->reqState.fullscreen)) { |
| 1443 |
return TCL_ERROR; |
| 1444 |
} |
| 1445 |
SetNetWmState(winPtr, |
| 1446 |
"_NET_WM_STATE_FULLSCREEN", wmPtr->reqState.fullscreen); |
| 1447 |
break; |
| 1448 |
case _WMATT_LAST_ATTRIBUTE: |
| 1449 |
return TCL_ERROR; |
| 1450 |
} |
| 1451 |
return TCL_OK; |
| 1452 |
} |
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
static Tcl_Obj *WmGetAttribute( |
| 1467 |
TkWindow *winPtr, |
| 1468 |
WmAttribute attribute) |
| 1469 |
{ |
| 1470 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1471 |
switch (attribute) { |
| 1472 |
case WMATT_ALPHA: |
| 1473 |
return Tcl_NewDoubleObj(wmPtr->attributes.alpha); |
| 1474 |
case WMATT_TOPMOST: |
| 1475 |
return Tcl_NewBooleanObj(wmPtr->attributes.topmost); |
| 1476 |
case WMATT_ZOOMED: |
| 1477 |
return Tcl_NewBooleanObj(wmPtr->attributes.zoomed); |
| 1478 |
case WMATT_FULLSCREEN: |
| 1479 |
return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen); |
| 1480 |
case _WMATT_LAST_ATTRIBUTE: |
| 1481 |
break; |
| 1482 |
} |
| 1483 |
|
| 1484 |
return NULL; |
| 1485 |
} |
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
static int |
| 1512 |
WmAttributesCmd( |
| 1513 |
Tk_Window tkwin, |
| 1514 |
TkWindow *winPtr, |
| 1515 |
Tcl_Interp *interp, |
| 1516 |
int objc, |
| 1517 |
Tcl_Obj *CONST objv[]) |
| 1518 |
{ |
| 1519 |
int attribute = 0; |
| 1520 |
if (objc == 3) { |
| 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)); |
| 1527 |
} |
| 1528 |
Tcl_SetObjResult(interp, result); |
| 1529 |
return TCL_OK; |
| 1530 |
} else if (objc == 4) { |
| 1531 |
if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames, |
| 1532 |
"attribute", 0, &attribute) != TCL_OK) { |
| 1533 |
return TCL_ERROR; |
| 1534 |
} |
| 1535 |
Tcl_SetObjResult(interp, |
| 1536 |
WmGetAttribute(winPtr, attribute)); |
| 1537 |
return TCL_OK; |
| 1538 |
} else if ((objc - 3) % 2 == 0) { |
| 1539 |
int i; |
| 1540 |
for (i = 3; i < objc; i += 2) { |
| 1541 |
if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames, |
| 1542 |
"attribute", 0, &attribute) != TCL_OK) { |
| 1543 |
return TCL_ERROR; |
| 1544 |
} |
| 1545 |
if (WmSetAttribute(winPtr,interp,attribute,objv[i+1]) != TCL_OK) { |
| 1546 |
return TCL_ERROR; |
| 1547 |
} |
| 1548 |
} |
| 1549 |
return TCL_OK; |
| 1550 |
} else { |
| 1551 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?-attribute ?value ...??"); |
| 1552 |
return TCL_ERROR; |
| 1553 |
} |
| 1554 |
return TCL_OK; |
| 1555 |
} |
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
static int |
| 1575 |
WmClientCmd( |
| 1576 |
Tk_Window tkwin, |
| 1577 |
TkWindow *winPtr, |
| 1578 |
Tcl_Interp *interp, |
| 1579 |
int objc, |
| 1580 |
Tcl_Obj *CONST objv[]) |
| 1581 |
{ |
| 1582 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1583 |
char *argv3; |
| 1584 |
int length; |
| 1585 |
|
| 1586 |
if ((objc != 3) && (objc != 4)) { |
| 1587 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?name?"); |
| 1588 |
return TCL_ERROR; |
| 1589 |
} |
| 1590 |
if (objc == 3) { |
| 1591 |
if (wmPtr->clientMachine != NULL) { |
| 1592 |
Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC); |
| 1593 |
} |
| 1594 |
return TCL_OK; |
| 1595 |
} |
| 1596 |
argv3 = Tcl_GetStringFromObj(objv[3], &length); |
| 1597 |
if (argv3[0] == 0) { |
| 1598 |
if (wmPtr->clientMachine != NULL) { |
| 1599 |
ckfree((char *) wmPtr->clientMachine); |
| 1600 |
wmPtr->clientMachine = NULL; |
| 1601 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 1602 |
XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window, |
| 1603 |
Tk_InternAtom((Tk_Window)winPtr, "WM_CLIENT_MACHINE")); |
| 1604 |
} |
| 1605 |
} |
| 1606 |
return TCL_OK; |
| 1607 |
} |
| 1608 |
if (wmPtr->clientMachine != NULL) { |
| 1609 |
ckfree((char *) wmPtr->clientMachine); |
| 1610 |
} |
| 1611 |
wmPtr->clientMachine = (char *) |
| 1612 |
ckalloc((unsigned) (length + 1)); |
| 1613 |
strcpy(wmPtr->clientMachine, argv3); |
| 1614 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 1615 |
XTextProperty textProp; |
| 1616 |
Tcl_DString ds; |
| 1617 |
char *string; |
| 1618 |
|
| 1619 |
Tcl_UtfToExternalDString(NULL, wmPtr->clientMachine, -1, &ds); |
| 1620 |
string = Tcl_DStringValue(&ds); |
| 1621 |
if (XStringListToTextProperty(&string, 1, |
| 1622 |
&textProp) != 0) { |
| 1623 |
XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window, |
| 1624 |
&textProp); |
| 1625 |
XFree((char *) textProp.value); |
| 1626 |
} |
| 1627 |
Tcl_DStringFree(&ds); |
| 1628 |
} |
| 1629 |
return TCL_OK; |
| 1630 |
} |
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
static int |
| 1650 |
WmColormapwindowsCmd( |
| 1651 |
Tk_Window tkwin, |
| 1652 |
TkWindow *winPtr, |
| 1653 |
Tcl_Interp *interp, |
| 1654 |
int objc, |
| 1655 |
Tcl_Obj *CONST objv[]) |
| 1656 |
{ |
| 1657 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1658 |
Window *cmapList; |
| 1659 |
TkWindow *winPtr2; |
| 1660 |
int count, i, windowObjc, gotToplevel; |
| 1661 |
Tcl_Obj **windowObjv; |
| 1662 |
char buffer[20]; |
| 1663 |
|
| 1664 |
if ((objc != 3) && (objc != 4)) { |
| 1665 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?"); |
| 1666 |
return TCL_ERROR; |
| 1667 |
} |
| 1668 |
Tk_MakeWindowExist((Tk_Window) winPtr); |
| 1669 |
if (wmPtr->wrapperPtr == NULL) { |
| 1670 |
CreateWrapper(wmPtr); |
| 1671 |
} |
| 1672 |
if (objc == 3) { |
| 1673 |
if (XGetWMColormapWindows(winPtr->display, |
| 1674 |
wmPtr->wrapperPtr->window, &cmapList, &count) == 0) { |
| 1675 |
return TCL_OK; |
| 1676 |
} |
| 1677 |
for (i = 0; i < count; i++) { |
| 1678 |
if ((i == (count-1)) |
| 1679 |
&& (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) { |
| 1680 |
break; |
| 1681 |
} |
| 1682 |
winPtr2 = (TkWindow *) Tk_IdToWindow(winPtr->display, |
| 1683 |
cmapList[i]); |
| 1684 |
if (winPtr2 == NULL) { |
| 1685 |
sprintf(buffer, "0x%lx", cmapList[i]); |
| 1686 |
Tcl_AppendElement(interp, buffer); |
| 1687 |
} else { |
| 1688 |
Tcl_AppendElement(interp, winPtr2->pathName); |
| 1689 |
} |
| 1690 |
} |
| 1691 |
XFree((char *) cmapList); |
| 1692 |
return TCL_OK; |
| 1693 |
} |
| 1694 |
if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv) |
| 1695 |
!= TCL_OK) { |
| 1696 |
return TCL_ERROR; |
| 1697 |
} |
| 1698 |
cmapList = (Window *) ckalloc((unsigned) |
| 1699 |
((windowObjc+1)*sizeof(Window))); |
| 1700 |
gotToplevel = 0; |
| 1701 |
for (i = 0; i < windowObjc; i++) { |
| 1702 |
if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], |
| 1703 |
(Tk_Window *) &winPtr2) != TCL_OK) { |
| 1704 |
ckfree((char *) cmapList); |
| 1705 |
return TCL_ERROR; |
| 1706 |
} |
| 1707 |
if (winPtr2 == winPtr) { |
| 1708 |
gotToplevel = 1; |
| 1709 |
} |
| 1710 |
if (winPtr2->window == None) { |
| 1711 |
Tk_MakeWindowExist((Tk_Window) winPtr2); |
| 1712 |
} |
| 1713 |
cmapList[i] = winPtr2->window; |
| 1714 |
} |
| 1715 |
if (!gotToplevel) { |
| 1716 |
wmPtr->flags |= WM_ADDED_TOPLEVEL_COLORMAP; |
| 1717 |
cmapList[windowObjc] = wmPtr->wrapperPtr->window; |
| 1718 |
windowObjc++; |
| 1719 |
} else { |
| 1720 |
wmPtr->flags &= ~WM_ADDED_TOPLEVEL_COLORMAP; |
| 1721 |
} |
| 1722 |
wmPtr->flags |= WM_COLORMAPS_EXPLICIT; |
| 1723 |
XSetWMColormapWindows(winPtr->display, wmPtr->wrapperPtr->window, |
| 1724 |
cmapList, windowObjc); |
| 1725 |
ckfree((char *) cmapList); |
| 1726 |
return TCL_OK; |
| 1727 |
} |
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
static int |
| 1747 |
WmCommandCmd( |
| 1748 |
Tk_Window tkwin, |
| 1749 |
TkWindow *winPtr, |
| 1750 |
Tcl_Interp *interp, |
| 1751 |
int objc, |
| 1752 |
Tcl_Obj *CONST objv[]) |
| 1753 |
{ |
| 1754 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1755 |
char *argv3; |
| 1756 |
int i; |
| 1757 |
int cmdArgc; |
| 1758 |
Tcl_Obj **cmdArgv; |
| 1759 |
|
| 1760 |
if ((objc != 3) && (objc != 4)) { |
| 1761 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?value?"); |
| 1762 |
return TCL_ERROR; |
| 1763 |
} |
| 1764 |
if (objc == 3) { |
| 1765 |
#ifdef _LANG |
| 1766 |
Tcl_IncrRefCount(wmPtr->cmdArg); |
| 1767 |
Tcl_SetObjResult(interp,wmPtr->cmdArg); |
| 1768 |
#else |
| 1769 |
Tcl_ResetResult(interp); |
| 1770 |
if (wmPtr->cmdArgv != NULL) { |
| 1771 |
for (i=0; i < wmPtr->cmdArgc; i++) { |
| 1772 |
Tcl_ListObjAppendElement(interp, |
| 1773 |
Tcl_GetObjResult(interp), |
| 1774 |
Tcl_NewStringObj(wmPtr->cmdArgv[i],-1)); |
| 1775 |
} |
| 1776 |
} |
| 1777 |
#endif |
| 1778 |
return TCL_OK; |
| 1779 |
} |
| 1780 |
|
| 1781 |
if (LangNull(objv[3])) { |
| 1782 |
#ifdef _LANG |
| 1783 |
if (wmPtr->cmdArg != NULL) { |
| 1784 |
TkWmFreeCmd(wmPtr); |
| 1785 |
#else |
| 1786 |
if (wmPtr->cmdArgv != NULL) { |
| 1787 |
ckfree((char *) wmPtr->cmdArgv); |
| 1788 |
wmPtr->cmdArgv = NULL; |
| 1789 |
#endif |
| 1790 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 1791 |
XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window, |
| 1792 |
Tk_InternAtom((Tk_Window) winPtr, "WM_COMMAND")); |
| 1793 |
} |
| 1794 |
} |
| 1795 |
return TCL_OK; |
| 1796 |
} |
| 1797 |
if (Tcl_ListObjGetElements(interp, objv[3], &cmdArgc, &cmdArgv) != TCL_OK) { |
| 1798 |
return TCL_ERROR; |
| 1799 |
} |
| 1800 |
#ifdef _LANG |
| 1801 |
Tcl_IncrRefCount(objv[3]); |
| 1802 |
|
| 1803 |
TkWmFreeCmd(wmPtr); |
| 1804 |
|
| 1805 |
wmPtr->cmdArg = objv[3]; |
| 1806 |
#else |
| 1807 |
if (wmPtr->cmdArgv != NULL) { |
| 1808 |
ckfree((char *) wmPtr->cmdArgv); |
| 1809 |
} |
| 1810 |
wmPtr->cmdArgc = cmdArgc; |
| 1811 |
wmPtr->cmdArgv = (CONST char **) ckalloc(cmdArgc*sizeof(char *)); |
| 1812 |
for (i=0; i < cmdArgc; i++) |
| 1813 |
{ |
| 1814 |
wmPtr->cmdArgv[i] = Tcl_GetString(cmdArgv[i]); |
| 1815 |
} |
| 1816 |
#endif |
| 1817 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 1818 |
UpdateCommand(winPtr); |
| 1819 |
} |
| 1820 |
return TCL_OK; |
| 1821 |
} |
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
static int |
| 1841 |
WmDeiconifyCmd( |
| 1842 |
Tk_Window tkwin, |
| 1843 |
TkWindow *winPtr, |
| 1844 |
Tcl_Interp *interp, |
| 1845 |
int objc, |
| 1846 |
Tcl_Obj *CONST objv[]) |
| 1847 |
{ |
| 1848 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1849 |
|
| 1850 |
if (objc != 3) { |
| 1851 |
Tcl_WrongNumArgs(interp, 2, objv, "window"); |
| 1852 |
return TCL_ERROR; |
| 1853 |
} |
| 1854 |
if (wmPtr->iconFor != NULL) { |
| 1855 |
Tcl_AppendResult(interp, "can't deiconify ", Tcl_GetString(objv[2]), |
| 1856 |
": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL); |
| 1857 |
return TCL_ERROR; |
| 1858 |
} |
| 1859 |
if (winPtr->flags & TK_EMBEDDED) { |
| 1860 |
Tcl_AppendResult(interp, "can't deiconify ", winPtr->pathName, |
| 1861 |
": it is an embedded window", NULL); |
| 1862 |
return TCL_ERROR; |
| 1863 |
} |
| 1864 |
wmPtr->flags &= ~WM_WITHDRAWN; |
| 1865 |
TkpWmSetState(winPtr, NormalState); |
| 1866 |
return TCL_OK; |
| 1867 |
} |
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
|
| 1886 |
static int |
| 1887 |
WmFocusmodelCmd( |
| 1888 |
Tk_Window tkwin, |
| 1889 |
TkWindow *winPtr, |
| 1890 |
Tcl_Interp *interp, |
| 1891 |
int objc, |
| 1892 |
Tcl_Obj *CONST objv[]) |
| 1893 |
{ |
| 1894 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1895 |
static CONST char *optionStrings[] = { |
| 1896 |
"active", "passive", NULL }; |
| 1897 |
enum options { |
| 1898 |
OPT_ACTIVE, OPT_PASSIVE }; |
| 1899 |
int index; |
| 1900 |
|
| 1901 |
if ((objc != 3) && (objc != 4)) { |
| 1902 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?"); |
| 1903 |
return TCL_ERROR; |
| 1904 |
} |
| 1905 |
if (objc == 3) { |
| 1906 |
Tcl_SetResult(interp, (wmPtr->hints.input ? "passive" : "active"), |
| 1907 |
TCL_STATIC); |
| 1908 |
return TCL_OK; |
| 1909 |
} |
| 1910 |
|
| 1911 |
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
| 1912 |
&index) != TCL_OK) { |
| 1913 |
return TCL_ERROR; |
| 1914 |
} |
| 1915 |
if (index == OPT_ACTIVE) { |
| 1916 |
wmPtr->hints.input = False; |
| 1917 |
} else { |
| 1918 |
wmPtr->hints.input = True; |
| 1919 |
} |
| 1920 |
UpdateHints(winPtr); |
| 1921 |
return TCL_OK; |
| 1922 |
} |
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
static int |
| 1942 |
WmFrameCmd( |
| 1943 |
Tk_Window tkwin, |
| 1944 |
TkWindow *winPtr, |
| 1945 |
Tcl_Interp *interp, |
| 1946 |
int objc, |
| 1947 |
Tcl_Obj *CONST objv[]) |
| 1948 |
{ |
| 1949 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1950 |
Window window; |
| 1951 |
char buf[TCL_INTEGER_SPACE]; |
| 1952 |
|
| 1953 |
if (objc != 3) { |
| 1954 |
Tcl_WrongNumArgs(interp, 2, objv, "window"); |
| 1955 |
return TCL_ERROR; |
| 1956 |
} |
| 1957 |
window = wmPtr->reparent; |
| 1958 |
if (window == None) { |
| 1959 |
window = Tk_WindowId((Tk_Window) winPtr); |
| 1960 |
} |
| 1961 |
sprintf(buf, "0x%x", (unsigned int) window); |
| 1962 |
Tcl_SetResult(interp, buf, TCL_VOLATILE); |
| 1963 |
return TCL_OK; |
| 1964 |
} |
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
|
| 1983 |
static int |
| 1984 |
WmGeometryCmd( |
| 1985 |
Tk_Window tkwin, |
| 1986 |
TkWindow *winPtr, |
| 1987 |
Tcl_Interp *interp, |
| 1988 |
int objc, |
| 1989 |
Tcl_Obj *CONST objv[]) |
| 1990 |
{ |
| 1991 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 1992 |
char xSign, ySign; |
| 1993 |
int width, height; |
| 1994 |
char *argv3; |
| 1995 |
|
| 1996 |
if ((objc != 3) && (objc != 4)) { |
| 1997 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); |
| 1998 |
return TCL_ERROR; |
| 1999 |
} |
| 2000 |
if (objc == 3) { |
| 2001 |
char buf[16 + TCL_INTEGER_SPACE * 4]; |
| 2002 |
|
| 2003 |
xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+'; |
| 2004 |
ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+'; |
| 2005 |
if (wmPtr->gridWin != NULL) { |
| 2006 |
width = wmPtr->reqGridWidth + (winPtr->changes.width |
| 2007 |
- winPtr->reqWidth)/wmPtr->widthInc; |
| 2008 |
height = wmPtr->reqGridHeight + (winPtr->changes.height |
| 2009 |
- winPtr->reqHeight)/wmPtr->heightInc; |
| 2010 |
} else { |
| 2011 |
width = winPtr->changes.width; |
| 2012 |
height = winPtr->changes.height; |
| 2013 |
} |
| 2014 |
sprintf(buf, "%dx%d%c%d%c%d", width, height, xSign, wmPtr->x, |
| 2015 |
ySign, wmPtr->y); |
| 2016 |
Tcl_SetResult(interp, buf, TCL_VOLATILE); |
| 2017 |
return TCL_OK; |
| 2018 |
} |
| 2019 |
argv3 = Tcl_GetString(objv[3]); |
| 2020 |
if (*argv3 == '\0') { |
| 2021 |
wmPtr->width = -1; |
| 2022 |
wmPtr->height = -1; |
| 2023 |
WmUpdateGeom(wmPtr, winPtr); |
| 2024 |
return TCL_OK; |
| 2025 |
} |
| 2026 |
return ParseGeometry(interp, argv3, winPtr); |
| 2027 |
} |
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
|
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
|
| 2042 |
|
| 2043 |
|
| 2044 |
|
| 2045 |
|
| 2046 |
static int |
| 2047 |
WmGridCmd( |
| 2048 |
Tk_Window tkwin, |
| 2049 |
TkWindow *winPtr, |
| 2050 |
Tcl_Interp *interp, |
| 2051 |
int objc, |
| 2052 |
Tcl_Obj *CONST objv[]) |
| 2053 |
{ |
| 2054 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2055 |
int reqWidth, reqHeight, widthInc, heightInc; |
| 2056 |
|
| 2057 |
if ((objc != 3) && (objc != 7)) { |
| 2058 |
Tcl_WrongNumArgs(interp, 2, objv, |
| 2059 |
"window ?baseWidth baseHeight widthInc heightInc?"); |
| 2060 |
return TCL_ERROR; |
| 2061 |
} |
| 2062 |
if (objc == 3) { |
| 2063 |
if (wmPtr->sizeHintsFlags & PBaseSize) { |
| 2064 |
Tcl_IntResults(interp, 4, 0, wmPtr->reqGridWidth, |
| 2065 |
wmPtr->reqGridHeight, wmPtr->widthInc, |
| 2066 |
wmPtr->heightInc); |
| 2067 |
} |
| 2068 |
return TCL_OK; |
| 2069 |
} |
| 2070 |
if (*Tcl_GetString(objv[3]) == '\0') { |
| 2071 |
|
| 2072 |
|
| 2073 |
|
| 2074 |
|
| 2075 |
|
| 2076 |
wmPtr->sizeHintsFlags &= ~(PBaseSize|PResizeInc); |
| 2077 |
if (wmPtr->width != -1) { |
| 2078 |
wmPtr->width = winPtr->reqWidth + (wmPtr->width |
| 2079 |
- wmPtr->reqGridWidth)*wmPtr->widthInc; |
| 2080 |
wmPtr->height = winPtr->reqHeight + (wmPtr->height |
| 2081 |
- wmPtr->reqGridHeight)*wmPtr->heightInc; |
| 2082 |
} |
| 2083 |
wmPtr->widthInc = 1; |
| 2084 |
wmPtr->heightInc = 1; |
| 2085 |
} else { |
| 2086 |
if ((Tcl_GetIntFromObj(interp, objv[3], &reqWidth) != TCL_OK) |
| 2087 |
|| (Tcl_GetIntFromObj(interp, objv[4], &reqHeight) != TCL_OK) |
| 2088 |
|| (Tcl_GetIntFromObj(interp, objv[5], &widthInc) != TCL_OK) |
| 2089 |
|| (Tcl_GetIntFromObj(interp, objv[6], &heightInc) !=TCL_OK)) { |
| 2090 |
return TCL_ERROR; |
| 2091 |
} |
| 2092 |
if (reqWidth < 0) { |
| 2093 |
Tcl_SetResult(interp, "baseWidth can't be < 0", TCL_STATIC); |
| 2094 |
return TCL_ERROR; |
| 2095 |
} |
| 2096 |
if (reqHeight < 0) { |
| 2097 |
Tcl_SetResult(interp, "baseHeight can't be < 0", TCL_STATIC); |
| 2098 |
return TCL_ERROR; |
| 2099 |
} |
| 2100 |
if (widthInc <= 0) { |
| 2101 |
Tcl_SetResult(interp, "widthInc can't be <= 0", TCL_STATIC); |
| 2102 |
return TCL_ERROR; |
| 2103 |
} |
| 2104 |
if (heightInc <= 0) { |
| 2105 |
Tcl_SetResult(interp, "heightInc can't be <= 0", TCL_STATIC); |
| 2106 |
return TCL_ERROR; |
| 2107 |
} |
| 2108 |
Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc, |
| 2109 |
heightInc); |
| 2110 |
} |
| 2111 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 2112 |
WmUpdateGeom(wmPtr, winPtr); |
| 2113 |
return TCL_OK; |
| 2114 |
} |
| 2115 |
|
| 2116 |
|
| 2117 |
|
| 2118 |
|
| 2119 |
|
| 2120 |
|
| 2121 |
|
| 2122 |
|
| 2123 |
|
| 2124 |
|
| 2125 |
|
| 2126 |
|
| 2127 |
|
| 2128 |
|
| 2129 |
|
| 2130 |
|
| 2131 |
|
| 2132 |
|
| 2133 |
static int |
| 2134 |
WmGroupCmd( |
| 2135 |
Tk_Window tkwin, |
| 2136 |
TkWindow *winPtr, |
| 2137 |
Tcl_Interp *interp, |
| 2138 |
int objc, |
| 2139 |
Tcl_Obj *CONST objv[]) |
| 2140 |
{ |
| 2141 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2142 |
Tk_Window tkwin2; |
| 2143 |
WmInfo *wmPtr2; |
| 2144 |
char *argv3; |
| 2145 |
int length; |
| 2146 |
|
| 2147 |
if ((objc != 3) && (objc != 4)) { |
| 2148 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); |
| 2149 |
return TCL_ERROR; |
| 2150 |
} |
| 2151 |
if (objc == 3) { |
| 2152 |
if (wmPtr->hints.flags & WindowGroupHint) { |
| 2153 |
Tcl_SetResult(interp, wmPtr->leaderName, TCL_STATIC); |
| 2154 |
} |
| 2155 |
return TCL_OK; |
| 2156 |
} |
| 2157 |
argv3 = Tcl_GetStringFromObj(objv[3], &length); |
| 2158 |
if (*argv3 == '\0') { |
| 2159 |
wmPtr->hints.flags &= ~WindowGroupHint; |
| 2160 |
if (wmPtr->leaderName != NULL) { |
| 2161 |
ckfree(wmPtr->leaderName); |
| 2162 |
} |
| 2163 |
wmPtr->leaderName = NULL; |
| 2164 |
} else { |
| 2165 |
if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { |
| 2166 |
return TCL_ERROR; |
| 2167 |
} |
| 2168 |
while (!Tk_TopWinHierarchy(tkwin2)) { |
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
tkwin2 = Tk_Parent(tkwin2); |
| 2174 |
} |
| 2175 |
Tk_MakeWindowExist(tkwin2); |
| 2176 |
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr; |
| 2177 |
if (wmPtr2->wrapperPtr == NULL) { |
| 2178 |
CreateWrapper(wmPtr2); |
| 2179 |
} |
| 2180 |
if (wmPtr->leaderName != NULL) { |
| 2181 |
ckfree(wmPtr->leaderName); |
| 2182 |
} |
| 2183 |
wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr); |
| 2184 |
wmPtr->hints.flags |= WindowGroupHint; |
| 2185 |
wmPtr->leaderName = ckalloc((unsigned) (length + 1)); |
| 2186 |
strcpy(wmPtr->leaderName, argv3); |
| 2187 |
} |
| 2188 |
UpdateHints(winPtr); |
| 2189 |
return TCL_OK; |
| 2190 |
} |
| 2191 |
|
| 2192 |
|
| 2193 |
|
| 2194 |
|
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
|
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
|
| 2208 |
|
| 2209 |
static int |
| 2210 |
WmIconbitmapCmd( |
| 2211 |
Tk_Window tkwin, |
| 2212 |
TkWindow *winPtr, |
| 2213 |
Tcl_Interp *interp, |
| 2214 |
int objc, |
| 2215 |
Tcl_Obj *CONST objv[]) |
| 2216 |
{ |
| 2217 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2218 |
Pixmap pixmap; |
| 2219 |
char *argv3; |
| 2220 |
|
| 2221 |
if ((objc < 3) || (objc > 4)) { |
| 2222 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); |
| 2223 |
return TCL_ERROR; |
| 2224 |
} |
| 2225 |
if (objc == 3) { |
| 2226 |
if (wmPtr->hints.flags & IconPixmapHint) { |
| 2227 |
Tcl_SetResult(interp, (char *) |
| 2228 |
Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap), |
| 2229 |
TCL_STATIC); |
| 2230 |
} |
| 2231 |
return TCL_OK; |
| 2232 |
} |
| 2233 |
argv3 = Tcl_GetString(objv[3]); |
| 2234 |
if (*argv3 == '\0') { |
| 2235 |
if (wmPtr->hints.icon_pixmap != None) { |
| 2236 |
Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); |
| 2237 |
wmPtr->hints.icon_pixmap = None; |
| 2238 |
} |
| 2239 |
wmPtr->hints.flags &= ~IconPixmapHint; |
| 2240 |
} else { |
| 2241 |
pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, argv3); |
| 2242 |
if (pixmap == None) { |
| 2243 |
return TCL_ERROR; |
| 2244 |
} |
| 2245 |
wmPtr->hints.icon_pixmap = pixmap; |
| 2246 |
wmPtr->hints.flags |= IconPixmapHint; |
| 2247 |
} |
| 2248 |
UpdateHints(winPtr); |
| 2249 |
return TCL_OK; |
| 2250 |
} |
| 2251 |
|
| 2252 |
|
| 2253 |
|
| 2254 |
|
| 2255 |
|
| 2256 |
|
| 2257 |
|
| 2258 |
|
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
|
| 2263 |
|
| 2264 |
|
| 2265 |
|
| 2266 |
|
| 2267 |
|
| 2268 |
|
| 2269 |
static int |
| 2270 |
WmIconifyCmd( |
| 2271 |
Tk_Window tkwin, |
| 2272 |
TkWindow *winPtr, |
| 2273 |
Tcl_Interp *interp, |
| 2274 |
int objc, |
| 2275 |
Tcl_Obj *CONST objv[]) |
| 2276 |
{ |
| 2277 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2278 |
if (objc != 3) { |
| 2279 |
Tcl_WrongNumArgs(interp, 2, objv, "window"); |
| 2280 |
return TCL_ERROR; |
| 2281 |
} |
| 2282 |
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { |
| 2283 |
Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, |
| 2284 |
"\": override-redirect flag is set", NULL); |
| 2285 |
return TCL_ERROR; |
| 2286 |
} |
| 2287 |
if (wmPtr->masterPtr != NULL) { |
| 2288 |
Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, |
| 2289 |
"\": it is a transient", NULL); |
| 2290 |
return TCL_ERROR; |
| 2291 |
} |
| 2292 |
if (wmPtr->iconFor != NULL) { |
| 2293 |
Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName, |
| 2294 |
": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL); |
| 2295 |
return TCL_ERROR; |
| 2296 |
} |
| 2297 |
if (winPtr->flags & TK_EMBEDDED) { |
| 2298 |
Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName, |
| 2299 |
": it is an embedded window", NULL); |
| 2300 |
return TCL_ERROR; |
| 2301 |
} |
| 2302 |
if (TkpWmSetState(winPtr, IconicState) == 0) { |
| 2303 |
Tcl_SetResult(interp, |
| 2304 |
"couldn't send iconify message to window manager", |
| 2305 |
TCL_STATIC); |
| 2306 |
return TCL_ERROR; |
| 2307 |
} |
| 2308 |
return TCL_OK; |
| 2309 |
} |
| 2310 |
|
| 2311 |
|
| 2312 |
|
| 2313 |
|
| 2314 |
|
| 2315 |
|
| 2316 |
|
| 2317 |
|
| 2318 |
|
| 2319 |
|
| 2320 |
|
| 2321 |
|
| 2322 |
|
| 2323 |
|
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
static int |
| 2329 |
WmIconmaskCmd( |
| 2330 |
Tk_Window tkwin, |
| 2331 |
TkWindow *winPtr, |
| 2332 |
Tcl_Interp *interp, |
| 2333 |
int objc, |
| 2334 |
Tcl_Obj *CONST objv[]) |
| 2335 |
{ |
| 2336 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2337 |
Pixmap pixmap; |
| 2338 |
char *argv3; |
| 2339 |
|
| 2340 |
if ((objc != 3) && (objc != 4)) { |
| 2341 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?"); |
| 2342 |
return TCL_ERROR; |
| 2343 |
} |
| 2344 |
if (objc == 3) { |
| 2345 |
if (wmPtr->hints.flags & IconMaskHint) { |
| 2346 |
Tcl_SetResult(interp, (char *) |
| 2347 |
Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask), |
| 2348 |
TCL_STATIC); |
| 2349 |
} |
| 2350 |
return TCL_OK; |
| 2351 |
} |
| 2352 |
argv3 = Tcl_GetString(objv[3]); |
| 2353 |
if (*argv3 == '\0') { |
| 2354 |
if (wmPtr->hints.icon_mask != None) { |
| 2355 |
Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); |
| 2356 |
} |
| 2357 |
wmPtr->hints.flags &= ~IconMaskHint; |
| 2358 |
} else { |
| 2359 |
pixmap = Tk_GetBitmap(interp, tkwin, argv3); |
| 2360 |
if (pixmap == None) { |
| 2361 |
return TCL_ERROR; |
| 2362 |
} |
| 2363 |
wmPtr->hints.icon_mask = pixmap; |
| 2364 |
wmPtr->hints.flags |= IconMaskHint; |
| 2365 |
} |
| 2366 |
UpdateHints(winPtr); |
| 2367 |
return TCL_OK; |
| 2368 |
} |
| 2369 |
|
| 2370 |
|
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
|
| 2377 |
|
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
static int |
| 2388 |
WmIconnameCmd( |
| 2389 |
Tk_Window tkwin, |
| 2390 |
TkWindow *winPtr, |
| 2391 |
Tcl_Interp *interp, |
| 2392 |
int objc, |
| 2393 |
Tcl_Obj *CONST objv[]) |
| 2394 |
{ |
| 2395 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2396 |
char *argv3; |
| 2397 |
int length; |
| 2398 |
|
| 2399 |
if (objc > 4) { |
| 2400 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?"); |
| 2401 |
return TCL_ERROR; |
| 2402 |
} |
| 2403 |
if (objc == 3) { |
| 2404 |
Tcl_SetResult(interp, |
| 2405 |
((wmPtr->iconName != NULL) ? wmPtr->iconName : ""), |
| 2406 |
TCL_STATIC); |
| 2407 |
return TCL_OK; |
| 2408 |
} else { |
| 2409 |
if (wmPtr->iconName != NULL) { |
| 2410 |
ckfree((char *) wmPtr->iconName); |
| 2411 |
} |
| 2412 |
argv3 = Tcl_GetStringFromObj(objv[3], &length); |
| 2413 |
wmPtr->iconName = ckalloc((unsigned) (length + 1)); |
| 2414 |
strcpy(wmPtr->iconName, argv3); |
| 2415 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 2416 |
UpdateTitle(winPtr); |
| 2417 |
} |
| 2418 |
} |
| 2419 |
return TCL_OK; |
| 2420 |
} |
| 2421 |
|
| 2422 |
|
| 2423 |
|
| 2424 |
|
| 2425 |
|
| 2426 |
|
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
|
| 2431 |
|
| 2432 |
|
| 2433 |
|
| 2434 |
|
| 2435 |
|
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
static int |
| 2440 |
WmIconphotoCmd( |
| 2441 |
Tk_Window tkwin, |
| 2442 |
TkWindow *winPtr, |
| 2443 |
Tcl_Interp *interp, |
| 2444 |
int objc, |
| 2445 |
Tcl_Obj *CONST objv[]) |
| 2446 |
{ |
| 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; |
| 2451 |
long R, G, B, A; |
| 2452 |
long *iconPropertyData; |
| 2453 |
unsigned char *pixelByte; |
| 2454 |
|
| 2455 |
if (objc < 4) { |
| 2456 |
Tcl_WrongNumArgs(interp, 2, objv, |
| 2457 |
"window ?-default? image1 ?image2 ...?"); |
| 2458 |
return TCL_ERROR; |
| 2459 |
} |
| 2460 |
if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) { |
| 2461 |
isDefault = 1; |
| 2462 |
if (objc == 4) { |
| 2463 |
Tcl_WrongNumArgs(interp, 2, objv, |
| 2464 |
"window ?-default? image1 ?image2 ...?"); |
| 2465 |
return TCL_ERROR; |
| 2466 |
} |
| 2467 |
} |
| 2468 |
|
| 2469 |
|
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 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); |
| 2479 |
return TCL_ERROR; |
| 2480 |
} |
| 2481 |
Tk_PhotoGetSize(photo, &width, &height); |
| 2482 |
|
| 2483 |
|
| 2484 |
|
| 2485 |
|
| 2486 |
|
| 2487 |
|
| 2488 |
size += 2 + width * height; |
| 2489 |
} |
| 2490 |
|
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
#ifdef NOTYET_XXX |
| 2497 |
iconPropertyData = (long *) Tcl_AttemptAlloc(sizeof(long)*size); |
| 2498 |
#else |
| 2499 |
iconPropertyData = (long *) ckalloc(sizeof(long)*size); |
| 2500 |
#endif |
| 2501 |
if (iconPropertyData == NULL) { |
| 2502 |
return TCL_ERROR; |
| 2503 |
} |
| 2504 |
memset(iconPropertyData, 0, sizeof(long)*size); |
| 2505 |
|
| 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); |
| 2510 |
return TCL_ERROR; |
| 2511 |
} |
| 2512 |
Tk_PhotoGetSize(photo, &width, &height); |
| 2513 |
Tk_PhotoGetImage(photo, &block); |
| 2514 |
|
| 2515 |
|
| 2516 |
|
| 2517 |
|
| 2518 |
|
| 2519 |
|
| 2520 |
|
| 2521 |
|
| 2522 |
|
| 2523 |
|
| 2524 |
|
| 2525 |
|
| 2526 |
|
| 2527 |
|
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 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]; |
| 2548 |
pixelByte[3] = A; |
| 2549 |
pixelByte[2] = R; |
| 2550 |
pixelByte[1] = G; |
| 2551 |
pixelByte[0] = B; |
| 2552 |
index++; |
| 2553 |
} |
| 2554 |
} |
| 2555 |
} |
| 2556 |
if (wmPtr->iconDataPtr != NULL) { |
| 2557 |
ckfree((char *)wmPtr->iconDataPtr); |
| 2558 |
wmPtr->iconDataPtr = NULL; |
| 2559 |
} |
| 2560 |
if (isDefault) { |
| 2561 |
if (winPtr->dispPtr->iconDataPtr != NULL) { |
| 2562 |
ckfree((char *) winPtr->dispPtr->iconDataPtr); |
| 2563 |
} |
| 2564 |
winPtr->dispPtr->iconDataPtr = (unsigned char *) iconPropertyData; |
| 2565 |
winPtr->dispPtr->iconDataSize = size; |
| 2566 |
} else { |
| 2567 |
wmPtr->iconDataPtr = (unsigned char *) iconPropertyData; |
| 2568 |
wmPtr->iconDataSize = size; |
| 2569 |
} |
| 2570 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 2571 |
UpdatePhotoIcon(winPtr); |
| 2572 |
} |
| 2573 |
return TCL_OK; |
| 2574 |
} |
| 2575 |
|
| 2576 |
|
| 2577 |
|
| 2578 |
|
| 2579 |
|
| 2580 |
|
| 2581 |
|
| 2582 |
|
| 2583 |
|
| 2584 |
|
| 2585 |
|
| 2586 |
|
| 2587 |
|
| 2588 |
|
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
static int |
| 2594 |
WmIconpositionCmd( |
| 2595 |
Tk_Window tkwin, |
| 2596 |
TkWindow *winPtr, |
| 2597 |
Tcl_Interp *interp, |
| 2598 |
int objc, |
| 2599 |
Tcl_Obj *CONST objv[]) |
| 2600 |
{ |
| 2601 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2602 |
int x, y; |
| 2603 |
|
| 2604 |
if ((objc != 3) && (objc != 5)) { |
| 2605 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?"); |
| 2606 |
return TCL_ERROR; |
| 2607 |
} |
| 2608 |
if (objc == 3) { |
| 2609 |
if (wmPtr->hints.flags & IconPositionHint) { |
| 2610 |
Tcl_IntResults(interp, 2, 0, wmPtr->hints.icon_x, |
| 2611 |
wmPtr->hints.icon_y); |
| 2612 |
} |
| 2613 |
return TCL_OK; |
| 2614 |
} |
| 2615 |
if (*Tcl_GetString(objv[3]) == '\0') { |
| 2616 |
wmPtr->hints.flags &= ~IconPositionHint; |
| 2617 |
} else { |
| 2618 |
if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) |
| 2619 |
|| (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){ |
| 2620 |
return TCL_ERROR; |
| 2621 |
} |
| 2622 |
wmPtr->hints.icon_x = x; |
| 2623 |
wmPtr->hints.icon_y = y; |
| 2624 |
wmPtr->hints.flags |= IconPositionHint; |
| 2625 |
} |
| 2626 |
UpdateHints(winPtr); |
| 2627 |
return TCL_OK; |
| 2628 |
} |
| 2629 |
|
| 2630 |
|
| 2631 |
|
| 2632 |
|
| 2633 |
|
| 2634 |
|
| 2635 |
|
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
|
| 2641 |
|
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
|
| 2647 |
static int |
| 2648 |
WmIconwindowCmd( |
| 2649 |
Tk_Window tkwin, |
| 2650 |
TkWindow *winPtr, |
| 2651 |
Tcl_Interp *interp, |
| 2652 |
int objc, |
| 2653 |
Tcl_Obj *CONST objv[]) |
| 2654 |
{ |
| 2655 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2656 |
Tk_Window tkwin2; |
| 2657 |
WmInfo *wmPtr2; |
| 2658 |
XSetWindowAttributes atts; |
| 2659 |
|
| 2660 |
if ((objc != 3) && (objc != 4)) { |
| 2661 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?"); |
| 2662 |
return TCL_ERROR; |
| 2663 |
} |
| 2664 |
if (objc == 3) { |
| 2665 |
if (wmPtr->icon != NULL) { |
| 2666 |
Tcl_SetResult(interp, Tk_PathName(wmPtr->icon), TCL_STATIC); |
| 2667 |
} |
| 2668 |
return TCL_OK; |
| 2669 |
} |
| 2670 |
if (*Tcl_GetString(objv[3]) == '\0') { |
| 2671 |
wmPtr->hints.flags &= ~IconWindowHint; |
| 2672 |
if (wmPtr->icon != NULL) { |
| 2673 |
|
| 2674 |
|
| 2675 |
|
| 2676 |
|
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
|
| 2682 |
wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; |
| 2683 |
wmPtr2->iconFor = NULL; |
| 2684 |
wmPtr2->withdrawn = 1; |
| 2685 |
wmPtr2->hints.initial_state = WithdrawnState; |
| 2686 |
} |
| 2687 |
wmPtr->icon = NULL; |
| 2688 |
} else { |
| 2689 |
if (TkGetWindowFromObj(interp, tkwin, objv[3], &tkwin2) != TCL_OK) { |
| 2690 |
return TCL_ERROR; |
| 2691 |
} |
| 2692 |
if (!Tk_IsTopLevel(tkwin2)) { |
| 2693 |
Tcl_AppendResult(interp, "can't use ", Tcl_GetString(objv[3]), |
| 2694 |
" as icon window: not at top level", NULL); |
| 2695 |
return TCL_ERROR; |
| 2696 |
} |
| 2697 |
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr; |
| 2698 |
if (wmPtr2->iconFor != NULL) { |
| 2699 |
Tcl_AppendResult(interp, Tcl_GetString(objv[3]), |
| 2700 |
" is already an icon for ", Tk_PathName(wmPtr2->iconFor), |
| 2701 |
NULL); |
| 2702 |
return TCL_ERROR; |
| 2703 |
} |
| 2704 |
if (wmPtr->icon != NULL) { |
| 2705 |
WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; |
| 2706 |
wmPtr3->iconFor = NULL; |
| 2707 |
wmPtr3->withdrawn = 1; |
| 2708 |
wmPtr3->hints.initial_state = WithdrawnState; |
| 2709 |
} |
| 2710 |
|
| 2711 |
|
| 2712 |
|
| 2713 |
|
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
atts.event_mask = Tk_Attributes(tkwin2)->event_mask |
| 2718 |
& ~ButtonPressMask; |
| 2719 |
Tk_ChangeWindowAttributes(tkwin2, CWEventMask, &atts); |
| 2720 |
Tk_MakeWindowExist(tkwin2); |
| 2721 |
if (wmPtr2->wrapperPtr == NULL) { |
| 2722 |
CreateWrapper(wmPtr2); |
| 2723 |
} |
| 2724 |
wmPtr->hints.icon_window = Tk_WindowId(wmPtr2->wrapperPtr); |
| 2725 |
wmPtr->hints.flags |= IconWindowHint; |
| 2726 |
wmPtr->icon = tkwin2; |
| 2727 |
wmPtr2->iconFor = (Tk_Window) winPtr; |
| 2728 |
if (!wmPtr2->withdrawn && !(wmPtr2->flags & WM_NEVER_MAPPED)) { |
| 2729 |
wmPtr2->withdrawn = 0; |
| 2730 |
if (XWithdrawWindow(Tk_Display(tkwin2), |
| 2731 |
Tk_WindowId(wmPtr2->wrapperPtr), |
| 2732 |
Tk_ScreenNumber(tkwin2)) == 0) { |
| 2733 |
Tcl_SetResult(interp, |
| 2734 |
"couldn't send withdraw message to window manager", |
| 2735 |
TCL_STATIC); |
| 2736 |
return TCL_ERROR; |
| 2737 |
} |
| 2738 |
WaitForMapNotify((TkWindow *) tkwin2, 0); |
| 2739 |
} |
| 2740 |
} |
| 2741 |
UpdateHints(winPtr); |
| 2742 |
return TCL_OK; |
| 2743 |
} |
| 2744 |
|
| 2745 |
|
| 2746 |
|
| 2747 |
|
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
|
| 2752 |
|
| 2753 |
|
| 2754 |
|
| 2755 |
|
| 2756 |
|
| 2757 |
|
| 2758 |
|
| 2759 |
|
| 2760 |
|
| 2761 |
|
| 2762 |
static int |
| 2763 |
WmMaxsizeCmd( |
| 2764 |
Tk_Window tkwin, |
| 2765 |
TkWindow *winPtr, |
| 2766 |
Tcl_Interp *interp, |
| 2767 |
int objc, |
| 2768 |
Tcl_Obj *CONST objv[]) |
| 2769 |
{ |
| 2770 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2771 |
int width, height; |
| 2772 |
|
| 2773 |
if ((objc != 3) && (objc != 5)) { |
| 2774 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); |
| 2775 |
return TCL_ERROR; |
| 2776 |
} |
| 2777 |
if (objc == 3) { |
| 2778 |
|
| 2779 |
GetMaxSize(wmPtr, &width, &height); |
| 2780 |
Tcl_IntResults(interp, 2, 0, width, height); |
| 2781 |
return TCL_OK; |
| 2782 |
} |
| 2783 |
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) |
| 2784 |
|| (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { |
| 2785 |
return TCL_ERROR; |
| 2786 |
} |
| 2787 |
wmPtr->maxWidth = width; |
| 2788 |
wmPtr->maxHeight = height; |
| 2789 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 2790 |
|
| 2791 |
if (width <= 0 && height <= 0) { |
| 2792 |
wmPtr->sizeHintsFlags &= ~PMaxSize; |
| 2793 |
} else { |
| 2794 |
wmPtr->sizeHintsFlags |= PMaxSize; |
| 2795 |
} |
| 2796 |
|
| 2797 |
WmUpdateGeom(wmPtr, winPtr); |
| 2798 |
return TCL_OK; |
| 2799 |
} |
| 2800 |
|
| 2801 |
|
| 2802 |
|
| 2803 |
|
| 2804 |
|
| 2805 |
|
| 2806 |
|
| 2807 |
|
| 2808 |
|
| 2809 |
|
| 2810 |
|
| 2811 |
|
| 2812 |
|
| 2813 |
|
| 2814 |
|
| 2815 |
|
| 2816 |
|
| 2817 |
|
| 2818 |
static int |
| 2819 |
WmMinsizeCmd( |
| 2820 |
Tk_Window tkwin, |
| 2821 |
TkWindow *winPtr, |
| 2822 |
Tcl_Interp *interp, |
| 2823 |
int objc, |
| 2824 |
Tcl_Obj *CONST objv[]) |
| 2825 |
{ |
| 2826 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2827 |
int width, height; |
| 2828 |
|
| 2829 |
if ((objc != 3) && (objc != 5)) { |
| 2830 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); |
| 2831 |
return TCL_ERROR; |
| 2832 |
} |
| 2833 |
if (objc == 3) { |
| 2834 |
Tcl_IntResults(interp, 2, 0, wmPtr->minWidth, wmPtr->minHeight); |
| 2835 |
return TCL_OK; |
| 2836 |
} |
| 2837 |
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK) |
| 2838 |
|| (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) { |
| 2839 |
return TCL_ERROR; |
| 2840 |
} |
| 2841 |
wmPtr->minWidth = width; |
| 2842 |
wmPtr->minHeight = height; |
| 2843 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 2844 |
WmUpdateGeom(wmPtr, winPtr); |
| 2845 |
return TCL_OK; |
| 2846 |
} |
| 2847 |
|
| 2848 |
|
| 2849 |
|
| 2850 |
|
| 2851 |
|
| 2852 |
|
| 2853 |
|
| 2854 |
|
| 2855 |
|
| 2856 |
|
| 2857 |
|
| 2858 |
|
| 2859 |
|
| 2860 |
|
| 2861 |
|
| 2862 |
|
| 2863 |
|
| 2864 |
|
| 2865 |
static int |
| 2866 |
WmOverrideredirectCmd( |
| 2867 |
Tk_Window tkwin, |
| 2868 |
TkWindow *winPtr, |
| 2869 |
Tcl_Interp *interp, |
| 2870 |
int objc, |
| 2871 |
Tcl_Obj *CONST objv[]) |
| 2872 |
{ |
| 2873 |
int boolean, curValue; |
| 2874 |
XSetWindowAttributes atts; |
| 2875 |
|
| 2876 |
if ((objc != 3) && (objc != 4)) { |
| 2877 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); |
| 2878 |
return TCL_ERROR; |
| 2879 |
} |
| 2880 |
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect; |
| 2881 |
if (objc == 3) { |
| 2882 |
Tcl_SetBooleanObj(Tcl_GetObjResult(interp), curValue); |
| 2883 |
return TCL_OK; |
| 2884 |
} |
| 2885 |
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) { |
| 2886 |
return TCL_ERROR; |
| 2887 |
} |
| 2888 |
if (curValue != boolean) { |
| 2889 |
|
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
atts.override_redirect = (boolean) ? True : False; |
| 2895 |
atts.save_under = (boolean) ? True : False; |
| 2896 |
|
| 2897 |
Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect|CWSaveUnder, |
| 2898 |
&atts); |
| 2899 |
if (winPtr->wmInfoPtr->wrapperPtr != NULL) { |
| 2900 |
Tk_ChangeWindowAttributes( |
| 2901 |
(Tk_Window) winPtr->wmInfoPtr->wrapperPtr, |
| 2902 |
CWOverrideRedirect, &atts); |
| 2903 |
} |
| 2904 |
} |
| 2905 |
return TCL_OK; |
| 2906 |
} |
| 2907 |
|
| 2908 |
|
| 2909 |
|
| 2910 |
|
| 2911 |
|
| 2912 |
|
| 2913 |
|
| 2914 |
|
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
static int |
| 2926 |
WmPositionfromCmd( |
| 2927 |
Tk_Window tkwin, |
| 2928 |
TkWindow *winPtr, |
| 2929 |
Tcl_Interp *interp, |
| 2930 |
int objc, |
| 2931 |
Tcl_Obj *CONST objv[]) |
| 2932 |
{ |
| 2933 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2934 |
static CONST char *optionStrings[] = { |
| 2935 |
"program", "user", NULL }; |
| 2936 |
enum options { |
| 2937 |
OPT_PROGRAM, OPT_USER }; |
| 2938 |
int index; |
| 2939 |
|
| 2940 |
if ((objc != 3) && (objc != 4)) { |
| 2941 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?"); |
| 2942 |
return TCL_ERROR; |
| 2943 |
} |
| 2944 |
if (objc == 3) { |
| 2945 |
if (wmPtr->sizeHintsFlags & USPosition) { |
| 2946 |
Tcl_SetResult(interp, "user", TCL_STATIC); |
| 2947 |
} else if (wmPtr->sizeHintsFlags & PPosition) { |
| 2948 |
Tcl_SetResult(interp, "program", TCL_STATIC); |
| 2949 |
} |
| 2950 |
return TCL_OK; |
| 2951 |
} |
| 2952 |
if (*Tcl_GetString(objv[3]) == '\0') { |
| 2953 |
wmPtr->sizeHintsFlags &= ~(USPosition|PPosition); |
| 2954 |
} else { |
| 2955 |
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
| 2956 |
&index) != TCL_OK) { |
| 2957 |
return TCL_ERROR; |
| 2958 |
} |
| 2959 |
if (index == OPT_USER) { |
| 2960 |
wmPtr->sizeHintsFlags &= ~PPosition; |
| 2961 |
wmPtr->sizeHintsFlags |= USPosition; |
| 2962 |
} else { |
| 2963 |
wmPtr->sizeHintsFlags &= ~USPosition; |
| 2964 |
wmPtr->sizeHintsFlags |= PPosition; |
| 2965 |
} |
| 2966 |
} |
| 2967 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 2968 |
WmUpdateGeom(wmPtr, winPtr); |
| 2969 |
return TCL_OK; |
| 2970 |
} |
| 2971 |
|
| 2972 |
|
| 2973 |
|
| 2974 |
|
| 2975 |
|
| 2976 |
|
| 2977 |
|
| 2978 |
|
| 2979 |
|
| 2980 |
|
| 2981 |
|
| 2982 |
|
| 2983 |
|
| 2984 |
|
| 2985 |
|
| 2986 |
|
| 2987 |
|
| 2988 |
|
| 2989 |
static int |
| 2990 |
WmProtocolCmd( |
| 2991 |
Tk_Window tkwin, |
| 2992 |
TkWindow *winPtr, |
| 2993 |
Tcl_Interp *interp, |
| 2994 |
int objc, |
| 2995 |
Tcl_Obj *CONST objv[]) |
| 2996 |
{ |
| 2997 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 2998 |
register ProtocolHandler *protPtr, *prevPtr; |
| 2999 |
Atom protocol; |
| 3000 |
char *cmd; |
| 3001 |
int cmdLength; |
| 3002 |
|
| 3003 |
if ((objc < 3) || (objc > 5)) { |
| 3004 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); |
| 3005 |
return TCL_ERROR; |
| 3006 |
} |
| 3007 |
if (objc == 3) { |
| 3008 |
|
| 3009 |
|
| 3010 |
|
| 3011 |
|
| 3012 |
for (protPtr = wmPtr->protPtr; protPtr != NULL; |
| 3013 |
protPtr = protPtr->nextPtr) { |
| 3014 |
Tcl_AppendElement(interp, |
| 3015 |
Tk_GetAtomName((Tk_Window) winPtr, protPtr->protocol)); |
| 3016 |
} |
| 3017 |
return TCL_OK; |
| 3018 |
} |
| 3019 |
protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3])); |
| 3020 |
if (objc == 4) { |
| 3021 |
|
| 3022 |
|
| 3023 |
|
| 3024 |
|
| 3025 |
for (protPtr = wmPtr->protPtr; protPtr != NULL; |
| 3026 |
protPtr = protPtr->nextPtr) { |
| 3027 |
if (protPtr->protocol == protocol) { |
| 3028 |
Tcl_SetObjResult(interp,LangCallbackObj(protPtr->command)); |
| 3029 |
return TCL_OK; |
| 3030 |
} |
| 3031 |
} |
| 3032 |
return TCL_OK; |
| 3033 |
} |
| 3034 |
|
| 3035 |
|
| 3036 |
|
| 3037 |
|
| 3038 |
|
| 3039 |
|
| 3040 |
for (protPtr = wmPtr->protPtr, prevPtr = NULL; protPtr != NULL; |
| 3041 |
prevPtr = protPtr, protPtr = protPtr->nextPtr) { |
| 3042 |
if (protPtr->protocol == protocol) { |
| 3043 |
if (prevPtr == NULL) { |
| 3044 |
wmPtr->protPtr = protPtr->nextPtr; |
| 3045 |
} else { |
| 3046 |
prevPtr->nextPtr = protPtr->nextPtr; |
| 3047 |
} |
| 3048 |
Tcl_EventuallyFree((ClientData) protPtr, ProtocolFree); |
| 3049 |
break; |
| 3050 |
} |
| 3051 |
} |
| 3052 |
cmd = Tcl_GetStringFromObj(objv[4], &cmdLength); |
| 3053 |
if (cmdLength > 0) { |
| 3054 |
#ifndef _LANG |
| 3055 |
protPtr = (ProtocolHandler *) ckalloc(HANDLER_SIZE(cmdLength)); |
| 3056 |
#else |
| 3057 |
protPtr = (ProtocolHandler *) ckalloc(sizeof(ProtocolHandler)); |
| 3058 |
#endif |
| 3059 |
protPtr->protocol = protocol; |
| 3060 |
protPtr->nextPtr = wmPtr->protPtr; |
| 3061 |
wmPtr->protPtr = protPtr; |
| 3062 |
protPtr->interp = interp; |
| 3063 |
#ifndef _LANG |
| 3064 |
strcpy(protPtr->command, cmd); |
| 3065 |
#else |
| 3066 |
protPtr->command = LangMakeCallback(objv[4]); |
| 3067 |
#endif |
| 3068 |
} |
| 3069 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 3070 |
UpdateWmProtocols(wmPtr); |
| 3071 |
} |
| 3072 |
return TCL_OK; |
| 3073 |
} |
| 3074 |
|
| 3075 |
|
| 3076 |
|
| 3077 |
|
| 3078 |
|
| 3079 |
|
| 3080 |
|
| 3081 |
|
| 3082 |
|
| 3083 |
|
| 3084 |
|
| 3085 |
|
| 3086 |
|
| 3087 |
|
| 3088 |
|
| 3089 |
|
| 3090 |
|
| 3091 |
|
| 3092 |
static int |
| 3093 |
WmResizableCmd( |
| 3094 |
Tk_Window tkwin, |
| 3095 |
TkWindow *winPtr, |
| 3096 |
Tcl_Interp *interp, |
| 3097 |
int objc, |
| 3098 |
Tcl_Obj *CONST objv[]) |
| 3099 |
{ |
| 3100 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 3101 |
int width, height; |
| 3102 |
|
| 3103 |
if ((objc != 3) && (objc != 5)) { |
| 3104 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); |
| 3105 |
return TCL_ERROR; |
| 3106 |
} |
| 3107 |
if (objc == 3) { |
| 3108 |
Tcl_IntResults(interp, 2, 0, |
| 3109 |
(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1, |
| 3110 |
(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1); |
| 3111 |
return TCL_OK; |
| 3112 |
} |
| 3113 |
if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK) |
| 3114 |
|| (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) { |
| 3115 |
return TCL_ERROR; |
| 3116 |
} |
| 3117 |
if (width) { |
| 3118 |
wmPtr->flags &= ~WM_WIDTH_NOT_RESIZABLE; |
| 3119 |
} else { |
| 3120 |
wmPtr->flags |= WM_WIDTH_NOT_RESIZABLE; |
| 3121 |
} |
| 3122 |
if (height) { |
| 3123 |
wmPtr->flags &= ~WM_HEIGHT_NOT_RESIZABLE; |
| 3124 |
} else { |
| 3125 |
wmPtr->flags |= WM_HEIGHT_NOT_RESIZABLE; |
| 3126 |
} |
| 3127 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 3128 |
WmUpdateGeom(wmPtr, winPtr); |
| 3129 |
return TCL_OK; |
| 3130 |
} |
| 3131 |
|
| 3132 |
|
| 3133 |
|
| 3134 |
|
| 3135 |
|
| 3136 |
|
| 3137 |
|
| 3138 |
|
| 3139 |
|
| 3140 |
|
| 3141 |
|
| 3142 |
|
| 3143 |
|
| 3144 |
|
| 3145 |
|
| 3146 |
|
| 3147 |
|
| 3148 |
|
| 3149 |
static int |
| 3150 |
WmSizefromCmd( |
| 3151 |
Tk_Window tkwin, |
| 3152 |
TkWindow *winPtr, |
| 3153 |
Tcl_Interp *interp, |
| 3154 |
int objc, |
| 3155 |
Tcl_Obj *CONST objv[]) |
| 3156 |
{ |
| 3157 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 3158 |
static CONST char *optionStrings[] = { |
| 3159 |
"program", "user", NULL }; |
| 3160 |
enum options { |
| 3161 |
OPT_PROGRAM, OPT_USER }; |
| 3162 |
int index; |
| 3163 |
|
| 3164 |
if ((objc != 3) && (objc != 4)) { |
| 3165 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?"); |
| 3166 |
return TCL_ERROR; |
| 3167 |
} |
| 3168 |
if (objc == 3) { |
| 3169 |
if (wmPtr->sizeHintsFlags & USSize) { |
| 3170 |
Tcl_SetResult(interp, "user", TCL_STATIC); |
| 3171 |
} else if (wmPtr->sizeHintsFlags & PSize) { |
| 3172 |
Tcl_SetResult(interp, "program", TCL_STATIC); |
| 3173 |
} |
| 3174 |
return TCL_OK; |
| 3175 |
} |
| 3176 |
|
| 3177 |
if (*Tcl_GetString(objv[3]) == '\0') { |
| 3178 |
wmPtr->sizeHintsFlags &= ~(USSize|PSize); |
| 3179 |
} else { |
| 3180 |
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
| 3181 |
&index) != TCL_OK) { |
| 3182 |
return TCL_ERROR; |
| 3183 |
} |
| 3184 |
if (index == OPT_USER) { |
| 3185 |
wmPtr->sizeHintsFlags &= ~PSize; |
| 3186 |
wmPtr->sizeHintsFlags |= USSize; |
| 3187 |
} else { |
| 3188 |
wmPtr->sizeHintsFlags &= ~USSize; |
| 3189 |
wmPtr->sizeHintsFlags |= PSize; |
| 3190 |
} |
| 3191 |
} |
| 3192 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 3193 |
WmUpdateGeom(wmPtr, winPtr); |
| 3194 |
return TCL_OK; |
| 3195 |
} |
| 3196 |
|
| 3197 |
|
| 3198 |
|
| 3199 |
|
| 3200 |
|
| 3201 |
|
| 3202 |
|
| 3203 |
|
| 3204 |
|
| 3205 |
|
| 3206 |
|
| 3207 |
|
| 3208 |
|
| 3209 |
|
| 3210 |
|
| 3211 |
|
| 3212 |
|
| 3213 |
|
| 3214 |
static int |
| 3215 |
WmStackorderCmd( |
| 3216 |
Tk_Window tkwin, |
| 3217 |
TkWindow *winPtr, |
| 3218 |
Tcl_Interp *interp, |
| 3219 |
int objc, |
| 3220 |
Tcl_Obj *CONST objv[]) |
| 3221 |
{ |
| 3222 |
TkWindow **windows, **window_ptr; |
| 3223 |
static CONST char *optionStrings[] = { |
| 3224 |
"isabove", "isbelow", NULL }; |
| 3225 |
enum options { |
| 3226 |
OPT_ISABOVE, OPT_ISBELOW }; |
| 3227 |
int index; |
| 3228 |
|
| 3229 |
if ((objc != 3) && (objc != 5)) { |
| 3230 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?isabove|isbelow window?"); |
| 3231 |
return TCL_ERROR; |
| 3232 |
} |
| 3233 |
|
| 3234 |
if (objc == 3) { |
| 3235 |
windows = TkWmStackorderToplevel(winPtr); |
| 3236 |
if (windows == NULL) { |
| 3237 |
Tcl_Panic("TkWmStackorderToplevel failed"); |
| 3238 |
} else { |
| 3239 |
for (window_ptr = windows; *window_ptr ; window_ptr++) { |
| 3240 |
Tcl_AppendElement(interp, (*window_ptr)->pathName); |
| 3241 |
} |
| 3242 |
ckfree((char *) windows); |
| 3243 |
return TCL_OK; |
| 3244 |
} |
| 3245 |
} else { |
| 3246 |
TkWindow *winPtr2; |
| 3247 |
int index1=-1, index2=-1, result; |
| 3248 |
|
| 3249 |
if (TkGetWindowFromObj(interp, tkwin, objv[4], (Tk_Window *) &winPtr2) |
| 3250 |
!= TCL_OK) { |
| 3251 |
return TCL_ERROR; |
| 3252 |
} |
| 3253 |
|
| 3254 |
if (!Tk_IsTopLevel(winPtr2)) { |
| 3255 |
Tcl_AppendResult(interp, "window \"", winPtr2->pathName, |
| 3256 |
"\" isn't a top-level window", NULL); |
| 3257 |
return TCL_ERROR; |
| 3258 |
} |
| 3259 |
|
| 3260 |
if (!Tk_IsMapped(winPtr)) { |
| 3261 |
Tcl_AppendResult(interp, "window \"", winPtr->pathName, |
| 3262 |
"\" isn't mapped", NULL); |
| 3263 |
return TCL_ERROR; |
| 3264 |
} |
| 3265 |
|
| 3266 |
if (!Tk_IsMapped(winPtr2)) { |
| 3267 |
Tcl_AppendResult(interp, "window \"", winPtr2->pathName, |
| 3268 |
"\" isn't mapped", NULL); |
| 3269 |
return TCL_ERROR; |
| 3270 |
} |
| 3271 |
|
| 3272 |
|
| 3273 |
|
| 3274 |
|
| 3275 |
|
| 3276 |
|
| 3277 |
windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); |
| 3278 |
|
| 3279 |
if (windows == NULL) { |
| 3280 |
Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL); |
| 3281 |
return TCL_ERROR; |
| 3282 |
} else { |
| 3283 |
for (window_ptr = windows; *window_ptr ; window_ptr++) { |
| 3284 |
if (*window_ptr == winPtr) { |
| 3285 |
index1 = (window_ptr - windows); |
| 3286 |
} |
| 3287 |
if (*window_ptr == winPtr2) { |
| 3288 |
index2 = (window_ptr - windows); |
| 3289 |
} |
| 3290 |
} |
| 3291 |
if (index1 == -1) { |
| 3292 |
Tcl_Panic("winPtr window not found"); |
| 3293 |
} |
| 3294 |
if (index2 == -1) { |
| 3295 |
Tcl_Panic("winPtr2 window not found"); |
| 3296 |
} |
| 3297 |
|
| 3298 |
ckfree((char *) windows); |
| 3299 |
} |
| 3300 |
|
| 3301 |
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
| 3302 |
&index) != TCL_OK) { |
| 3303 |
return TCL_ERROR; |
| 3304 |
} |
| 3305 |
if (index == OPT_ISABOVE) { |
| 3306 |
result = index1 > index2; |
| 3307 |
} else { |
| 3308 |
result = index1 < index2; |
| 3309 |
} |
| 3310 |
Tcl_SetIntObj(Tcl_GetObjResult(interp), result); |
| 3311 |
return TCL_OK; |
| 3312 |
} |
| 3313 |
return TCL_OK; |
| 3314 |
} |
| 3315 |
|
| 3316 |
|
| 3317 |
|
| 3318 |
|
| 3319 |
|
| 3320 |
|
| 3321 |
|
| 3322 |
|
| 3323 |
|
| 3324 |
|
| 3325 |
|
| 3326 |
|
| 3327 |
|
| 3328 |
|
| 3329 |
|
| 3330 |
|
| 3331 |
|
| 3332 |
|
| 3333 |
static int |
| 3334 |
WmStateCmd( |
| 3335 |
Tk_Window tkwin, |
| 3336 |
TkWindow *winPtr, |
| 3337 |
Tcl_Interp *interp, |
| 3338 |
int objc, |
| 3339 |
Tcl_Obj *CONST objv[]) |
| 3340 |
{ |
| 3341 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 3342 |
static CONST char *optionStrings[] = { |
| 3343 |
"normal", "iconic", "withdrawn", NULL }; |
| 3344 |
enum options { |
| 3345 |
OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN }; |
| 3346 |
int index; |
| 3347 |
|
| 3348 |
if ((objc < 3) || (objc > 4)) { |
| 3349 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?state?"); |
| 3350 |
return TCL_ERROR; |
| 3351 |
} |
| 3352 |
if (objc == 4) { |
| 3353 |
if (wmPtr->iconFor != NULL) { |
| 3354 |
Tcl_AppendResult(interp, "can't change state of ", |
| 3355 |
Tcl_GetString(objv[2]), ": it is an icon for ", |
| 3356 |
Tk_PathName(wmPtr->iconFor), NULL); |
| 3357 |
return TCL_ERROR; |
| 3358 |
} |
| 3359 |
|
| 3360 |
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, |
| 3361 |
&index) != TCL_OK) { |
| 3362 |
return TCL_ERROR; |
| 3363 |
} |
| 3364 |
|
| 3365 |
if (index == OPT_NORMAL) { |
| 3366 |
wmPtr->flags &= ~WM_WITHDRAWN; |
| 3367 |
(void) TkpWmSetState(winPtr, NormalState); |
| 3368 |
} else if (index == OPT_ICONIC) { |
| 3369 |
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { |
| 3370 |
Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, |
| 3371 |
"\": override-redirect flag is set", NULL); |
| 3372 |
return TCL_ERROR; |
| 3373 |
} |
| 3374 |
if (wmPtr->masterPtr != NULL) { |
| 3375 |
Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, |
| 3376 |
"\": it is a transient", NULL); |
| 3377 |
return TCL_ERROR; |
| 3378 |
} |
| 3379 |
if (TkpWmSetState(winPtr, IconicState) == 0) { |
| 3380 |
Tcl_SetResult(interp, |
| 3381 |
"couldn't send iconify message to window manager", |
| 3382 |
TCL_STATIC); |
| 3383 |
return TCL_ERROR; |
| 3384 |
} |
| 3385 |
} else { |
| 3386 |
wmPtr->flags |= WM_WITHDRAWN; |
| 3387 |
if (TkpWmSetState(winPtr, WithdrawnState) == 0) { |
| 3388 |
Tcl_SetResult(interp, |
| 3389 |
"couldn't send withdraw message to window manager", |
| 3390 |
TCL_STATIC); |
| 3391 |
return TCL_ERROR; |
| 3392 |
} |
| 3393 |
} |
| 3394 |
} else { |
| 3395 |
if (wmPtr->iconFor != NULL) { |
| 3396 |
Tcl_SetResult(interp, "icon", TCL_STATIC); |
| 3397 |
} else if (wmPtr->withdrawn) { |
| 3398 |
Tcl_SetResult(interp, "withdrawn", TCL_STATIC); |
| 3399 |
} else if (Tk_IsMapped((Tk_Window) winPtr) |
| 3400 |
|| ((wmPtr->flags & WM_NEVER_MAPPED) |
| 3401 |
&& (wmPtr->hints.initial_state == NormalState))) { |
| 3402 |
Tcl_SetResult(interp, "normal", TCL_STATIC); |
| 3403 |
} else { |
| 3404 |
Tcl_SetResult(interp, "iconic", TCL_STATIC); |
| 3405 |
} |
| 3406 |
} |
| 3407 |
return TCL_OK; |
| 3408 |
} |
| 3409 |
|
| 3410 |
|
| 3411 |
|
| 3412 |
|
| 3413 |
|
| 3414 |
|
| 3415 |
|
| 3416 |
|
| 3417 |
|
| 3418 |
|
| 3419 |
|
| 3420 |
|
| 3421 |
|
| 3422 |
|
| 3423 |
|
| 3424 |
|
| 3425 |
|
| 3426 |
|
| 3427 |
static int |
| 3428 |
WmTitleCmd( |
| 3429 |
Tk_Window tkwin, |
| 3430 |
TkWindow *winPtr, |
| 3431 |
Tcl_Interp *interp, |
| 3432 |
int objc, |
| 3433 |
Tcl_Obj *CONST objv[]) |
| 3434 |
{ |
| 3435 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 3436 |
char *argv3; |
| 3437 |
int length; |
| 3438 |
|
| 3439 |
if (objc > 4) { |
| 3440 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?"); |
| 3441 |
return TCL_ERROR; |
| 3442 |
} |
| 3443 |
if (objc == 3) { |
| 3444 |
Tcl_SetResult(interp, (char *) |
| 3445 |
((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid), |
| 3446 |
TCL_STATIC); |
| 3447 |
return TCL_OK; |
| 3448 |
} else { |
| 3449 |
if (wmPtr->title != NULL) { |
| 3450 |
ckfree((char *) wmPtr->title); |
| 3451 |
} |
| 3452 |
argv3 = Tcl_GetStringFromObj(objv[3], &length); |
| 3453 |
wmPtr->title = ckalloc((unsigned) (length + 1)); |
| 3454 |
strcpy(wmPtr->title, argv3); |
| 3455 |
|
| 3456 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 3457 |
UpdateTitle(winPtr); |
| 3458 |
} |
| 3459 |
} |
| 3460 |
return TCL_OK; |
| 3461 |
} |
| 3462 |
|
| 3463 |
|
| 3464 |
|
| 3465 |
|
| 3466 |
|
| 3467 |
|
| 3468 |
|
| 3469 |
|
| 3470 |
|
| 3471 |
|
| 3472 |
|
| 3473 |
|
| 3474 |
|
| 3475 |
|
| 3476 |
|
| 3477 |
|
| 3478 |
|
| 3479 |
|
| 3480 |
static int |
| 3481 |
WmTransientCmd( |
| 3482 |
Tk_Window tkwin, |
| 3483 |
TkWindow *winPtr, |
| 3484 |
Tcl_Interp *interp, |
| 3485 |
int objc, |
| 3486 |
Tcl_Obj *CONST objv[]) |
| 3487 |
{ |
| 3488 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 3489 |
TkWindow *masterPtr = wmPtr->masterPtr; |
| 3490 |
WmInfo *wmPtr2; |
| 3491 |
|
| 3492 |
if ((objc != 3) && (objc != 4)) { |
| 3493 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); |
| 3494 |
return TCL_ERROR; |
| 3495 |
} |
| 3496 |
if (objc == 3) { |
| 3497 |
if (masterPtr != NULL) { |
| 3498 |
Tk_Window master = (Tk_Window) masterPtr; |
| 3499 |
Tcl_SetResult(interp, Tk_PathName(master), TCL_STATIC); |
| 3500 |
} |
| 3501 |
return TCL_OK; |
| 3502 |
} |
| 3503 |
if (Tcl_GetString(objv[3])[0] == '\0') { |
| 3504 |
if (masterPtr != NULL) { |
| 3505 |
|
| 3506 |
|
| 3507 |
|
| 3508 |
|
| 3509 |
|
| 3510 |
masterPtr->wmInfoPtr->numTransients--; |
| 3511 |
Tk_DeleteEventHandler((Tk_Window) masterPtr, StructureNotifyMask, |
| 3512 |
WmWaitMapProc, (ClientData) winPtr); |
| 3513 |
|
| 3514 |
|
| 3515 |
|
| 3516 |
|
| 3517 |
|
| 3518 |
|
| 3519 |
} |
| 3520 |
|
| 3521 |
wmPtr->masterPtr = NULL; |
| 3522 |
} else { |
| 3523 |
if (TkGetWindowFromObj(interp, tkwin, objv[3], |
| 3524 |
(Tk_Window *) &masterPtr) != TCL_OK) { |
| 3525 |
return TCL_ERROR; |
| 3526 |
} |
| 3527 |
while (!Tk_TopWinHierarchy(masterPtr)) { |
| 3528 |
|
| 3529 |
|
| 3530 |
|
| 3531 |
|
| 3532 |
masterPtr = masterPtr->parentPtr; |
| 3533 |
} |
| 3534 |
Tk_MakeWindowExist((Tk_Window) masterPtr); |
| 3535 |
|
| 3536 |
if (wmPtr->iconFor != NULL) { |
| 3537 |
Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[2]), |
| 3538 |
"\" a transient: it is an icon for ", |
| 3539 |
Tk_PathName(wmPtr->iconFor), NULL); |
| 3540 |
return TCL_ERROR; |
| 3541 |
} |
| 3542 |
|
| 3543 |
wmPtr2 = masterPtr->wmInfoPtr; |
| 3544 |
if (wmPtr2->wrapperPtr == NULL) { |
| 3545 |
CreateWrapper(wmPtr2); |
| 3546 |
} |
| 3547 |
|
| 3548 |
if (wmPtr2->iconFor != NULL) { |
| 3549 |
Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[3]), |
| 3550 |
"\" a master: it is an icon for ", |
| 3551 |
Tk_PathName(wmPtr2->iconFor), NULL); |
| 3552 |
return TCL_ERROR; |
| 3553 |
} |
| 3554 |
|
| 3555 |
if (masterPtr == winPtr) { |
| 3556 |
Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr), |
| 3557 |
"\" its own master", NULL); |
| 3558 |
return TCL_ERROR; |
| 3559 |
} else if (masterPtr != wmPtr->masterPtr) { |
| 3560 |
|
| 3561 |
|
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
if (wmPtr->masterPtr != NULL) { |
| 3567 |
wmPtr->masterPtr->wmInfoPtr->numTransients--; |
| 3568 |
Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr, |
| 3569 |
StructureNotifyMask, |
| 3570 |
WmWaitMapProc, (ClientData) winPtr); |
| 3571 |
} |
| 3572 |
|
| 3573 |
masterPtr->wmInfoPtr->numTransients++; |
| 3574 |
Tk_CreateEventHandler((Tk_Window) masterPtr, |
| 3575 |
StructureNotifyMask, WmWaitMapProc, (ClientData) winPtr); |
| 3576 |
|
| 3577 |
wmPtr->masterPtr = masterPtr; |
| 3578 |
} |
| 3579 |
} |
| 3580 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 3581 |
if (wmPtr->masterPtr != NULL && !Tk_IsMapped(wmPtr->masterPtr)) { |
| 3582 |
if (TkpWmSetState(winPtr, WithdrawnState) == 0) { |
| 3583 |
Tcl_SetResult(interp, |
| 3584 |
"couldn't send withdraw message to window manager", |
| 3585 |
TCL_STATIC); |
| 3586 |
return TCL_ERROR; |
| 3587 |
} |
| 3588 |
} else { |
| 3589 |
if (wmPtr->masterPtr != NULL) { |
| 3590 |
XSetTransientForHint(winPtr->display, |
| 3591 |
wmPtr->wrapperPtr->window, |
| 3592 |
wmPtr->masterPtr->wmInfoPtr->wrapperPtr->window); |
| 3593 |
} else { |
| 3594 |
XDeleteProperty(winPtr->display, wmPtr->wrapperPtr->window, |
| 3595 |
Tk_InternAtom((Tk_Window)winPtr, "WM_TRANSIENT_FOR")); |
| 3596 |
} |
| 3597 |
} |
| 3598 |
} |
| 3599 |
return TCL_OK; |
| 3600 |
} |
| 3601 |
|
| 3602 |
|
| 3603 |
|
| 3604 |
|
| 3605 |
|
| 3606 |
|
| 3607 |
|
| 3608 |
|
| 3609 |
|
| 3610 |
|
| 3611 |
|
| 3612 |
|
| 3613 |
|
| 3614 |
|
| 3615 |
|
| 3616 |
|
| 3617 |
|
| 3618 |
|
| 3619 |
static int |
| 3620 |
WmWithdrawCmd( |
| 3621 |
Tk_Window tkwin, |
| 3622 |
TkWindow *winPtr, |
| 3623 |
Tcl_Interp *interp, |
| 3624 |
int objc, |
| 3625 |
Tcl_Obj *CONST objv[]) |
| 3626 |
{ |
| 3627 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 3628 |
|
| 3629 |
if (objc != 3) { |
| 3630 |
Tcl_WrongNumArgs(interp, 2, objv, "window"); |
| 3631 |
return TCL_ERROR; |
| 3632 |
} |
| 3633 |
if (wmPtr->iconFor != NULL) { |
| 3634 |
Tcl_AppendResult(interp, "can't withdraw ", Tcl_GetString(objv[2]), |
| 3635 |
": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL); |
| 3636 |
return TCL_ERROR; |
| 3637 |
} |
| 3638 |
wmPtr->flags |= WM_WITHDRAWN; |
| 3639 |
if (TkpWmSetState(winPtr, WithdrawnState) == 0) { |
| 3640 |
Tcl_SetResult(interp, |
| 3641 |
"couldn't send withdraw message to window manager", |
| 3642 |
TCL_STATIC); |
| 3643 |
return TCL_ERROR; |
| 3644 |
} |
| 3645 |
return TCL_OK; |
| 3646 |
} |
| 3647 |
|
| 3648 |
|
| 3649 |
|
| 3650 |
|
| 3651 |
|
| 3652 |
|
| 3653 |
static void |
| 3654 |
WmUpdateGeom( |
| 3655 |
WmInfo *wmPtr, |
| 3656 |
TkWindow *winPtr) |
| 3657 |
{ |
| 3658 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 3659 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr); |
| 3660 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 3661 |
} |
| 3662 |
} |
| 3663 |
|
| 3664 |
|
| 3665 |
|
| 3666 |
|
| 3667 |
|
| 3668 |
|
| 3669 |
static void |
| 3670 |
WmWaitMapProc( |
| 3671 |
ClientData clientData, |
| 3672 |
XEvent *eventPtr) |
| 3673 |
{ |
| 3674 |
TkWindow *winPtr = (TkWindow *) clientData; |
| 3675 |
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr; |
| 3676 |
|
| 3677 |
if (masterPtr == NULL) { |
| 3678 |
return; |
| 3679 |
} |
| 3680 |
|
| 3681 |
if (eventPtr->type == MapNotify) { |
| 3682 |
if (!(winPtr->wmInfoPtr->flags & WM_WITHDRAWN)) { |
| 3683 |
(void) TkpWmSetState(winPtr, NormalState); |
| 3684 |
} |
| 3685 |
} else if (eventPtr->type == UnmapNotify) { |
| 3686 |
(void) TkpWmSetState(winPtr, WithdrawnState); |
| 3687 |
} |
| 3688 |
} |
| 3689 |
|
| 3690 |
|
| 3691 |
|
| 3692 |
|
| 3693 |
|
| 3694 |
|
| 3695 |
|
| 3696 |
|
| 3697 |
|
| 3698 |
|
| 3699 |
|
| 3700 |
|
| 3701 |
|
| 3702 |
|
| 3703 |
|
| 3704 |
|
| 3705 |
|
| 3706 |
|
| 3707 |
|
| 3708 |
|
| 3709 |
|
| 3710 |
|
| 3711 |
|
| 3712 |
void |
| 3713 |
Tk_SetGrid( |
| 3714 |
Tk_Window tkwin, |
| 3715 |
|
| 3716 |
|
| 3717 |
int reqWidth, |
| 3718 |
|
| 3719 |
int reqHeight, |
| 3720 |
|
| 3721 |
int widthInc, int heightInc) |
| 3722 |
|
| 3723 |
{ |
| 3724 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 3725 |
register WmInfo *wmPtr; |
| 3726 |
|
| 3727 |
|
| 3728 |
|
| 3729 |
|
| 3730 |
|
| 3731 |
if (widthInc <= 0) { |
| 3732 |
widthInc = 1; |
| 3733 |
} |
| 3734 |
if (heightInc <= 0) { |
| 3735 |
heightInc = 1; |
| 3736 |
} |
| 3737 |
|
| 3738 |
|
| 3739 |
|
| 3740 |
|
| 3741 |
|
| 3742 |
|
| 3743 |
while (!(winPtr->flags & TK_TOP_HIERARCHY)) { |
| 3744 |
winPtr = winPtr->parentPtr; |
| 3745 |
if (winPtr == NULL) { |
| 3746 |
|
| 3747 |
|
| 3748 |
|
| 3749 |
|
| 3750 |
return; |
| 3751 |
} |
| 3752 |
} |
| 3753 |
wmPtr = winPtr->wmInfoPtr; |
| 3754 |
if (wmPtr == NULL) { |
| 3755 |
return; |
| 3756 |
} |
| 3757 |
|
| 3758 |
if ((wmPtr->gridWin != NULL) && (wmPtr->gridWin != tkwin)) { |
| 3759 |
return; |
| 3760 |
} |
| 3761 |
|
| 3762 |
if ((wmPtr->reqGridWidth == reqWidth) |
| 3763 |
&& (wmPtr->reqGridHeight == reqHeight) |
| 3764 |
&& (wmPtr->widthInc == widthInc) |
| 3765 |
&& (wmPtr->heightInc == heightInc) |
| 3766 |
&& ((wmPtr->sizeHintsFlags & (PBaseSize|PResizeInc)) |
| 3767 |
== (PBaseSize|PResizeInc))) { |
| 3768 |
return; |
| 3769 |
} |
| 3770 |
|
| 3771 |
|
| 3772 |
|
| 3773 |
|
| 3774 |
|
| 3775 |
|
| 3776 |
|
| 3777 |
|
| 3778 |
|
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
|
| 3783 |
if ((wmPtr->gridWin == NULL) && !(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 3784 |
wmPtr->width = -1; |
| 3785 |
wmPtr->height = -1; |
| 3786 |
} |
| 3787 |
|
| 3788 |
|
| 3789 |
|
| 3790 |
|
| 3791 |
|
| 3792 |
|
| 3793 |
wmPtr->gridWin = tkwin; |
| 3794 |
wmPtr->reqGridWidth = reqWidth; |
| 3795 |
wmPtr->reqGridHeight = reqHeight; |
| 3796 |
wmPtr->widthInc = widthInc; |
| 3797 |
wmPtr->heightInc = heightInc; |
| 3798 |
wmPtr->sizeHintsFlags |= PBaseSize|PResizeInc; |
| 3799 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 3800 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 3801 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr); |
| 3802 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 3803 |
} |
| 3804 |
} |
| 3805 |
|
| 3806 |
|
| 3807 |
|
| 3808 |
|
| 3809 |
|
| 3810 |
|
| 3811 |
|
| 3812 |
|
| 3813 |
|
| 3814 |
|
| 3815 |
|
| 3816 |
|
| 3817 |
|
| 3818 |
|
| 3819 |
|
| 3820 |
|
| 3821 |
|
| 3822 |
|
| 3823 |
|
| 3824 |
void |
| 3825 |
Tk_UnsetGrid( |
| 3826 |
Tk_Window tkwin) |
| 3827 |
|
| 3828 |
{ |
| 3829 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 3830 |
register WmInfo *wmPtr; |
| 3831 |
|
| 3832 |
|
| 3833 |
|
| 3834 |
|
| 3835 |
|
| 3836 |
|
| 3837 |
while (!(winPtr->flags & TK_TOP_HIERARCHY)) { |
| 3838 |
winPtr = winPtr->parentPtr; |
| 3839 |
if (winPtr == NULL) { |
| 3840 |
|
| 3841 |
|
| 3842 |
|
| 3843 |
|
| 3844 |
return; |
| 3845 |
} |
| 3846 |
} |
| 3847 |
wmPtr = winPtr->wmInfoPtr; |
| 3848 |
if (wmPtr == NULL) { |
| 3849 |
return; |
| 3850 |
} |
| 3851 |
|
| 3852 |
if (tkwin != wmPtr->gridWin) { |
| 3853 |
return; |
| 3854 |
} |
| 3855 |
|
| 3856 |
wmPtr->gridWin = NULL; |
| 3857 |
wmPtr->sizeHintsFlags &= ~(PBaseSize|PResizeInc); |
| 3858 |
if (wmPtr->width != -1) { |
| 3859 |
wmPtr->width = winPtr->reqWidth + (wmPtr->width |
| 3860 |
- wmPtr->reqGridWidth)*wmPtr->widthInc; |
| 3861 |
wmPtr->height = winPtr->reqHeight + (wmPtr->height |
| 3862 |
- wmPtr->reqGridHeight)*wmPtr->heightInc; |
| 3863 |
} |
| 3864 |
wmPtr->widthInc = 1; |
| 3865 |
wmPtr->heightInc = 1; |
| 3866 |
|
| 3867 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 3868 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 3869 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr); |
| 3870 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 3871 |
} |
| 3872 |
} |
| 3873 |
|
| 3874 |
|
| 3875 |
|
| 3876 |
|
| 3877 |
|
| 3878 |
|
| 3879 |
|
| 3880 |
|
| 3881 |
|
| 3882 |
|
| 3883 |
|
| 3884 |
|
| 3885 |
|
| 3886 |
|
| 3887 |
|
| 3888 |
|
| 3889 |
|
| 3890 |
|
| 3891 |
|
| 3892 |
static void |
| 3893 |
ConfigureEvent( |
| 3894 |
WmInfo *wmPtr, |
| 3895 |
XConfigureEvent *configEventPtr) |
| 3896 |
|
| 3897 |
|
| 3898 |
{ |
| 3899 |
TkWindow *wrapperPtr = wmPtr->wrapperPtr; |
| 3900 |
TkWindow *winPtr = wmPtr->winPtr; |
| 3901 |
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; |
| 3902 |
Tk_ErrorHandler handler; |
| 3903 |
|
| 3904 |
|
| 3905 |
|
| 3906 |
|
| 3907 |
|
| 3908 |
|
| 3909 |
|
| 3910 |
|
| 3911 |
|
| 3912 |
|
| 3913 |
|
| 3914 |
|
| 3915 |
|
| 3916 |
|
| 3917 |
if (((wrapperPtr->changes.width != configEventPtr->width) |
| 3918 |
|| (wrapperPtr->changes.height != configEventPtr->height)) |
| 3919 |
&& !(wmPtr->flags & WM_SYNC_PENDING)) { |
| 3920 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 3921 |
printf("TopLevelEventProc: user changed %s size to %dx%d\n", |
| 3922 |
winPtr->pathName, configEventPtr->width, |
| 3923 |
configEventPtr->height); |
| 3924 |
} |
| 3925 |
if ((wmPtr->width == -1) |
| 3926 |
&& (configEventPtr->width == winPtr->reqWidth)) { |
| 3927 |
|
| 3928 |
|
| 3929 |
|
| 3930 |
|
| 3931 |
} else { |
| 3932 |
|
| 3933 |
|
| 3934 |
|
| 3935 |
|
| 3936 |
|
| 3937 |
|
| 3938 |
|
| 3939 |
|
| 3940 |
|
| 3941 |
if (!(winPtr->flags & TK_EMBEDDED)) { |
| 3942 |
if (wmPtr->gridWin != NULL) { |
| 3943 |
wmPtr->width = wmPtr->reqGridWidth |
| 3944 |
+ (configEventPtr->width |
| 3945 |
- winPtr->reqWidth)/wmPtr->widthInc; |
| 3946 |
if (wmPtr->width < 0) { |
| 3947 |
wmPtr->width = 0; |
| 3948 |
} |
| 3949 |
} else { |
| 3950 |
wmPtr->width = configEventPtr->width; |
| 3951 |
} |
| 3952 |
} |
| 3953 |
} |
| 3954 |
if ((wmPtr->height == -1) |
| 3955 |
&& (configEventPtr->height == |
| 3956 |
(winPtr->reqHeight + wmPtr->menuHeight))) { |
| 3957 |
|
| 3958 |
|
| 3959 |
|
| 3960 |
|
| 3961 |
} else { |
| 3962 |
|
| 3963 |
|
| 3964 |
|
| 3965 |
|
| 3966 |
|
| 3967 |
if (!(winPtr->flags & TK_EMBEDDED)) { |
| 3968 |
if (wmPtr->gridWin != NULL) { |
| 3969 |
wmPtr->height = wmPtr->reqGridHeight |
| 3970 |
+ (configEventPtr->height - wmPtr->menuHeight |
| 3971 |
- winPtr->reqHeight)/wmPtr->heightInc; |
| 3972 |
if (wmPtr->height < 0) { |
| 3973 |
wmPtr->height = 0; |
| 3974 |
} |
| 3975 |
} else { |
| 3976 |
wmPtr->height = configEventPtr->height - wmPtr->menuHeight; |
| 3977 |
} |
| 3978 |
} |
| 3979 |
} |
| 3980 |
wmPtr->configWidth = configEventPtr->width; |
| 3981 |
wmPtr->configHeight = configEventPtr->height; |
| 3982 |
} |
| 3983 |
|
| 3984 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 3985 |
printf("ConfigureEvent: %s x = %d y = %d, width = %d, height = %d\n", |
| 3986 |
winPtr->pathName, configEventPtr->x, configEventPtr->y, |
| 3987 |
configEventPtr->width, configEventPtr->height); |
| 3988 |
printf(" send_event = %d, serial = %ld (win %p, wrapper %p)\n", |
| 3989 |
configEventPtr->send_event, configEventPtr->serial, |
| 3990 |
winPtr, wrapperPtr); |
| 3991 |
} |
| 3992 |
wrapperPtr->changes.width = configEventPtr->width; |
| 3993 |
wrapperPtr->changes.height = configEventPtr->height; |
| 3994 |
wrapperPtr->changes.border_width = configEventPtr->border_width; |
| 3995 |
wrapperPtr->changes.sibling = configEventPtr->above; |
| 3996 |
wrapperPtr->changes.stack_mode = Above; |
| 3997 |
|
| 3998 |
|
| 3999 |
|
| 4000 |
|
| 4001 |
|
| 4002 |
|
| 4003 |
|
| 4004 |
|
| 4005 |
|
| 4006 |
|
| 4007 |
|
| 4008 |
|
| 4009 |
|
| 4010 |
|
| 4011 |
|
| 4012 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4013 |
printf(" %s parent == %p, above %p\n", |
| 4014 |
winPtr->pathName, (void *) wmPtr->reparent, |
| 4015 |
(void *) configEventPtr->above); |
| 4016 |
} |
| 4017 |
|
| 4018 |
if ((wmPtr->reparent == None) || !ComputeReparentGeometry(wmPtr)) { |
| 4019 |
wmPtr->parentWidth = configEventPtr->width |
| 4020 |
+ 2*configEventPtr->border_width; |
| 4021 |
wmPtr->parentHeight = configEventPtr->height |
| 4022 |
+ 2*configEventPtr->border_width; |
| 4023 |
wrapperPtr->changes.x = wmPtr->x = configEventPtr->x; |
| 4024 |
wrapperPtr->changes.y = wmPtr->y = configEventPtr->y; |
| 4025 |
if (wmPtr->flags & WM_NEGATIVE_X) { |
| 4026 |
wmPtr->x = wmPtr->vRootWidth - (wmPtr->x + wmPtr->parentWidth); |
| 4027 |
} |
| 4028 |
if (wmPtr->flags & WM_NEGATIVE_Y) { |
| 4029 |
wmPtr->y = wmPtr->vRootHeight - (wmPtr->y + wmPtr->parentHeight); |
| 4030 |
} |
| 4031 |
} |
| 4032 |
|
| 4033 |
|
| 4034 |
|
| 4035 |
|
| 4036 |
|
| 4037 |
|
| 4038 |
|
| 4039 |
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, NULL, NULL); |
| 4040 |
XMoveResizeWindow(winPtr->display, winPtr->window, 0, |
| 4041 |
wmPtr->menuHeight, (unsigned) wrapperPtr->changes.width, |
| 4042 |
(unsigned) (wrapperPtr->changes.height - wmPtr->menuHeight)); |
| 4043 |
Tk_DeleteErrorHandler(handler); |
| 4044 |
if ((wmPtr->menubar != NULL) |
| 4045 |
&& ((Tk_Width(wmPtr->menubar) != wrapperPtr->changes.width) |
| 4046 |
|| (Tk_Height(wmPtr->menubar) != wmPtr->menuHeight))) { |
| 4047 |
Tk_MoveResizeWindow(wmPtr->menubar, 0, 0, wrapperPtr->changes.width, |
| 4048 |
wmPtr->menuHeight); |
| 4049 |
} |
| 4050 |
|
| 4051 |
|
| 4052 |
|
| 4053 |
|
| 4054 |
|
| 4055 |
|
| 4056 |
|
| 4057 |
|
| 4058 |
winPtr->changes.x = wrapperPtr->changes.x; |
| 4059 |
winPtr->changes.y = wrapperPtr->changes.y + wmPtr->menuHeight; |
| 4060 |
winPtr->changes.width = wrapperPtr->changes.width; |
| 4061 |
winPtr->changes.height = wrapperPtr->changes.height - wmPtr->menuHeight; |
| 4062 |
TkDoConfigureNotify(winPtr); |
| 4063 |
} |
| 4064 |
|
| 4065 |
|
| 4066 |
|
| 4067 |
|
| 4068 |
|
| 4069 |
|
| 4070 |
|
| 4071 |
|
| 4072 |
|
| 4073 |
|
| 4074 |
|
| 4075 |
|
| 4076 |
|
| 4077 |
|
| 4078 |
|
| 4079 |
|
| 4080 |
|
| 4081 |
|
| 4082 |
static void |
| 4083 |
ReparentEvent( |
| 4084 |
WmInfo *wmPtr, |
| 4085 |
XReparentEvent *reparentEventPtr) |
| 4086 |
|
| 4087 |
|
| 4088 |
{ |
| 4089 |
TkWindow *wrapperPtr = wmPtr->wrapperPtr; |
| 4090 |
Window vRoot, ancestor, *children, dummy2, *virtualRootPtr; |
| 4091 |
Atom actualType; |
| 4092 |
int actualFormat; |
| 4093 |
unsigned long numItems, bytesAfter; |
| 4094 |
unsigned int dummy; |
| 4095 |
Tk_ErrorHandler handler; |
| 4096 |
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; |
| 4097 |
|
| 4098 |
|
| 4099 |
|
| 4100 |
|
| 4101 |
|
| 4102 |
|
| 4103 |
|
| 4104 |
|
| 4105 |
|
| 4106 |
vRoot = RootWindow(wrapperPtr->display, wrapperPtr->screenNum); |
| 4107 |
wmPtr->vRoot = None; |
| 4108 |
handler = Tk_CreateErrorHandler(wrapperPtr->display, -1,-1,-1, NULL,NULL); |
| 4109 |
if (((XGetWindowProperty(wrapperPtr->display, wrapperPtr->window, |
| 4110 |
Tk_InternAtom((Tk_Window) wrapperPtr, "__WM_ROOT"), 0, (long) 1, |
| 4111 |
False, XA_WINDOW, &actualType, &actualFormat, &numItems, |
| 4112 |
&bytesAfter, (unsigned char **) &virtualRootPtr) == Success) |
| 4113 |
&& (actualType == XA_WINDOW)) |
| 4114 |
|| ((XGetWindowProperty(wrapperPtr->display, wrapperPtr->window, |
| 4115 |
Tk_InternAtom((Tk_Window) wrapperPtr, "__SWM_ROOT"), 0, (long) 1, |
| 4116 |
False, XA_WINDOW, &actualType, &actualFormat, &numItems, |
| 4117 |
&bytesAfter, (unsigned char **) &virtualRootPtr) == Success) |
| 4118 |
&& (actualType == XA_WINDOW))) { |
| 4119 |
if ((actualFormat == 32) && (numItems == 1)) { |
| 4120 |
vRoot = wmPtr->vRoot = *virtualRootPtr; |
| 4121 |
} else if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4122 |
printf("%s format %d numItems %ld\n", |
| 4123 |
"ReparentEvent got bogus VROOT property:", actualFormat, |
| 4124 |
numItems); |
| 4125 |
} |
| 4126 |
XFree((char *) virtualRootPtr); |
| 4127 |
} |
| 4128 |
Tk_DeleteErrorHandler(handler); |
| 4129 |
|
| 4130 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4131 |
printf("ReparentEvent: %s (%p) reparented to 0x%x, vRoot = 0x%x\n", |
| 4132 |
wmPtr->winPtr->pathName, wmPtr->winPtr, |
| 4133 |
(unsigned int) reparentEventPtr->parent, (unsigned int) vRoot); |
| 4134 |
} |
| 4135 |
|
| 4136 |
|
| 4137 |
|
| 4138 |
|
| 4139 |
|
| 4140 |
UpdateVRootGeometry(wmPtr); |
| 4141 |
|
| 4142 |
|
| 4143 |
|
| 4144 |
|
| 4145 |
|
| 4146 |
|
| 4147 |
if (reparentEventPtr->parent == vRoot) { |
| 4148 |
noReparent: |
| 4149 |
wmPtr->reparent = None; |
| 4150 |
wmPtr->parentWidth = wrapperPtr->changes.width; |
| 4151 |
wmPtr->parentHeight = wrapperPtr->changes.height; |
| 4152 |
wmPtr->xInParent = wmPtr->yInParent = 0; |
| 4153 |
wrapperPtr->changes.x = reparentEventPtr->x; |
| 4154 |
wrapperPtr->changes.y = reparentEventPtr->y; |
| 4155 |
wmPtr->winPtr->changes.x = reparentEventPtr->x; |
| 4156 |
wmPtr->winPtr->changes.y = reparentEventPtr->y + wmPtr->menuHeight; |
| 4157 |
return; |
| 4158 |
} |
| 4159 |
|
| 4160 |
|
| 4161 |
|
| 4162 |
|
| 4163 |
|
| 4164 |
|
| 4165 |
|
| 4166 |
|
| 4167 |
|
| 4168 |
|
| 4169 |
handler = Tk_CreateErrorHandler(wrapperPtr->display, -1,-1,-1, NULL,NULL); |
| 4170 |
wmPtr->reparent = reparentEventPtr->parent; |
| 4171 |
while (1) { |
| 4172 |
if (XQueryTree(wrapperPtr->display, wmPtr->reparent, &dummy2, |
| 4173 |
&ancestor, &children, &dummy) == 0) { |
| 4174 |
Tk_DeleteErrorHandler(handler); |
| 4175 |
goto noReparent; |
| 4176 |
} |
| 4177 |
XFree((char *) children); |
| 4178 |
if ((ancestor == vRoot) || |
| 4179 |
(ancestor == RootWindow(wrapperPtr->display, |
| 4180 |
wrapperPtr->screenNum))) { |
| 4181 |
break; |
| 4182 |
} |
| 4183 |
wmPtr->reparent = ancestor; |
| 4184 |
} |
| 4185 |
Tk_DeleteErrorHandler(handler); |
| 4186 |
|
| 4187 |
if (!ComputeReparentGeometry(wmPtr)) { |
| 4188 |
goto noReparent; |
| 4189 |
} |
| 4190 |
} |
| 4191 |
|
| 4192 |
|
| 4193 |
|
| 4194 |
|
| 4195 |
|
| 4196 |
|
| 4197 |
|
| 4198 |
|
| 4199 |
|
| 4200 |
|
| 4201 |
|
| 4202 |
|
| 4203 |
|
| 4204 |
|
| 4205 |
|
| 4206 |
|
| 4207 |
|
| 4208 |
|
| 4209 |
|
| 4210 |
|
| 4211 |
|
| 4212 |
|
| 4213 |
static int |
| 4214 |
ComputeReparentGeometry( |
| 4215 |
WmInfo *wmPtr) |
| 4216 |
|
| 4217 |
{ |
| 4218 |
TkWindow *wrapperPtr = wmPtr->wrapperPtr; |
| 4219 |
int width, height, bd; |
| 4220 |
unsigned int dummy; |
| 4221 |
int xOffset, yOffset, x, y; |
| 4222 |
Window dummy2; |
| 4223 |
Status status; |
| 4224 |
Tk_ErrorHandler handler; |
| 4225 |
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; |
| 4226 |
|
| 4227 |
handler = Tk_CreateErrorHandler(wrapperPtr->display, -1,-1,-1, NULL,NULL); |
| 4228 |
(void) XTranslateCoordinates(wrapperPtr->display, wrapperPtr->window, |
| 4229 |
wmPtr->reparent, 0, 0, &xOffset, &yOffset, &dummy2); |
| 4230 |
status = XGetGeometry(wrapperPtr->display, wmPtr->reparent, |
| 4231 |
&dummy2, &x, &y, (unsigned int *) &width, |
| 4232 |
(unsigned int *) &height, (unsigned int *) &bd, &dummy); |
| 4233 |
Tk_DeleteErrorHandler(handler); |
| 4234 |
if (status == 0) { |
| 4235 |
|
| 4236 |
|
| 4237 |
|
| 4238 |
|
| 4239 |
|
| 4240 |
wmPtr->reparent = None; |
| 4241 |
wmPtr->xInParent = wmPtr->yInParent = 0; |
| 4242 |
return 0; |
| 4243 |
} |
| 4244 |
wmPtr->xInParent = xOffset + bd; |
| 4245 |
wmPtr->yInParent = yOffset + bd; |
| 4246 |
wmPtr->parentWidth = width + 2*bd; |
| 4247 |
wmPtr->parentHeight = height + 2*bd; |
| 4248 |
|
| 4249 |
|
| 4250 |
|
| 4251 |
|
| 4252 |
|
| 4253 |
|
| 4254 |
|
| 4255 |
|
| 4256 |
|
| 4257 |
|
| 4258 |
|
| 4259 |
|
| 4260 |
|
| 4261 |
|
| 4262 |
|
| 4263 |
|
| 4264 |
|
| 4265 |
|
| 4266 |
|
| 4267 |
|
| 4268 |
|
| 4269 |
|
| 4270 |
|
| 4271 |
|
| 4272 |
|
| 4273 |
|
| 4274 |
|
| 4275 |
if (!(wmPtr->flags & WM_MOVE_PENDING) |
| 4276 |
&& ((wrapperPtr->changes.x != (x + wmPtr->xInParent)) |
| 4277 |
|| (wrapperPtr->changes.y != (y + wmPtr->yInParent)))) { |
| 4278 |
wmPtr->x = x; |
| 4279 |
if (wmPtr->flags & WM_NEGATIVE_X) { |
| 4280 |
wmPtr->x = wmPtr->vRootWidth - (wmPtr->x + wmPtr->parentWidth); |
| 4281 |
} |
| 4282 |
wmPtr->y = y; |
| 4283 |
if (wmPtr->flags & WM_NEGATIVE_Y) { |
| 4284 |
wmPtr->y = wmPtr->vRootHeight - (wmPtr->y + wmPtr->parentHeight); |
| 4285 |
} |
| 4286 |
} |
| 4287 |
|
| 4288 |
wrapperPtr->changes.x = x + wmPtr->xInParent; |
| 4289 |
wrapperPtr->changes.y = y + wmPtr->yInParent; |
| 4290 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4291 |
printf("wrapperPtr %p coords %d,%d\n", |
| 4292 |
wrapperPtr, wrapperPtr->changes.x, wrapperPtr->changes.y); |
| 4293 |
printf(" wmPtr %p coords %d,%d, offsets %d %d\n", |
| 4294 |
wmPtr, wmPtr->x, wmPtr->y, wmPtr->xInParent, wmPtr->yInParent); |
| 4295 |
} |
| 4296 |
return 1; |
| 4297 |
} |
| 4298 |
|
| 4299 |
|
| 4300 |
|
| 4301 |
|
| 4302 |
|
| 4303 |
|
| 4304 |
|
| 4305 |
|
| 4306 |
|
| 4307 |
|
| 4308 |
|
| 4309 |
|
| 4310 |
|
| 4311 |
|
| 4312 |
|
| 4313 |
static void |
| 4314 |
PropertyEvent( |
| 4315 |
WmInfo *wmPtr, |
| 4316 |
XPropertyEvent *eventPtr) |
| 4317 |
{ |
| 4318 |
TkWindow *wrapperPtr = wmPtr->wrapperPtr; |
| 4319 |
Atom _NET_WM_STATE = |
| 4320 |
Tk_InternAtom((Tk_Window)wmPtr->winPtr, "_NET_WM_STATE"); |
| 4321 |
|
| 4322 |
if (eventPtr->atom == _NET_WM_STATE) { |
| 4323 |
Atom actualType; |
| 4324 |
int actualFormat; |
| 4325 |
unsigned long numItems, bytesAfter; |
| 4326 |
unsigned char *propertyValue = 0; |
| 4327 |
long maxLength = 1024; |
| 4328 |
|
| 4329 |
if (XGetWindowProperty( |
| 4330 |
wrapperPtr->display, wrapperPtr->window, _NET_WM_STATE, |
| 4331 |
0l, maxLength, False, XA_ATOM, |
| 4332 |
&actualType, &actualFormat, &numItems, &bytesAfter, |
| 4333 |
&propertyValue) == Success |
| 4334 |
) { |
| 4335 |
CheckNetWmState(wmPtr, (Atom*)propertyValue, (int)numItems); |
| 4336 |
XFree(propertyValue); |
| 4337 |
} |
| 4338 |
} |
| 4339 |
} |
| 4340 |
|
| 4341 |
|
| 4342 |
|
| 4343 |
|
| 4344 |
|
| 4345 |
|
| 4346 |
|
| 4347 |
|
| 4348 |
|
| 4349 |
|
| 4350 |
|
| 4351 |
|
| 4352 |
|
| 4353 |
|
| 4354 |
|
| 4355 |
|
| 4356 |
|
| 4357 |
|
| 4358 |
|
| 4359 |
static const unsigned int WrapperEventMask = |
| 4360 |
(StructureNotifyMask | PropertyChangeMask); |
| 4361 |
|
| 4362 |
static void |
| 4363 |
WrapperEventProc( |
| 4364 |
ClientData clientData, |
| 4365 |
XEvent *eventPtr) |
| 4366 |
{ |
| 4367 |
WmInfo *wmPtr = (WmInfo *) clientData; |
| 4368 |
XEvent mapEvent; |
| 4369 |
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr; |
| 4370 |
|
| 4371 |
wmPtr->flags |= WM_VROOT_OFFSET_STALE; |
| 4372 |
if (eventPtr->type == DestroyNotify) { |
| 4373 |
Tk_ErrorHandler handler; |
| 4374 |
|
| 4375 |
if (!(wmPtr->wrapperPtr->flags & TK_ALREADY_DEAD)) { |
| 4376 |
|
| 4377 |
|
| 4378 |
|
| 4379 |
|
| 4380 |
|
| 4381 |
|
| 4382 |
|
| 4383 |
|
| 4384 |
handler = Tk_CreateErrorHandler(wmPtr->winPtr->display, -1, -1, -1, |
| 4385 |
NULL, NULL); |
| 4386 |
Tk_DestroyWindow((Tk_Window) wmPtr->winPtr); |
| 4387 |
Tk_DeleteErrorHandler(handler); |
| 4388 |
} |
| 4389 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4390 |
printf("TopLevelEventProc: %s deleted\n", wmPtr->winPtr->pathName); |
| 4391 |
} |
| 4392 |
} else if (eventPtr->type == ConfigureNotify) { |
| 4393 |
|
| 4394 |
|
| 4395 |
|
| 4396 |
|
| 4397 |
|
| 4398 |
|
| 4399 |
|
| 4400 |
|
| 4401 |
|
| 4402 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 4403 |
ConfigureEvent(wmPtr, &eventPtr->xconfigure); |
| 4404 |
} |
| 4405 |
} else if (eventPtr->type == MapNotify) { |
| 4406 |
wmPtr->wrapperPtr->flags |= TK_MAPPED; |
| 4407 |
wmPtr->winPtr->flags |= TK_MAPPED; |
| 4408 |
XMapWindow(wmPtr->winPtr->display, wmPtr->winPtr->window); |
| 4409 |
goto doMapEvent; |
| 4410 |
} else if (eventPtr->type == UnmapNotify) { |
| 4411 |
wmPtr->wrapperPtr->flags &= ~TK_MAPPED; |
| 4412 |
wmPtr->winPtr->flags &= ~TK_MAPPED; |
| 4413 |
XUnmapWindow(wmPtr->winPtr->display, wmPtr->winPtr->window); |
| 4414 |
goto doMapEvent; |
| 4415 |
} else if (eventPtr->type == ReparentNotify) { |
| 4416 |
ReparentEvent(wmPtr, &eventPtr->xreparent); |
| 4417 |
} else if (eventPtr->type == PropertyNotify) { |
| 4418 |
PropertyEvent(wmPtr, &eventPtr->xproperty); |
| 4419 |
} else if (0 && eventPtr->type == Expose) { |
| 4420 |
mapEvent = *eventPtr; |
| 4421 |
mapEvent.xexpose.window = wmPtr->winPtr->window; |
| 4422 |
Tk_HandleEvent(&mapEvent); |
| 4423 |
} |
| 4424 |
return; |
| 4425 |
|
| 4426 |
doMapEvent: |
| 4427 |
mapEvent = *eventPtr; |
| 4428 |
mapEvent.xmap.event = wmPtr->winPtr->window; |
| 4429 |
mapEvent.xmap.window = wmPtr->winPtr->window; |
| 4430 |
Tk_HandleEvent(&mapEvent); |
| 4431 |
} |
| 4432 |
|
| 4433 |
|
| 4434 |
|
| 4435 |
|
| 4436 |
|
| 4437 |
|
| 4438 |
|
| 4439 |
|
| 4440 |
|
| 4441 |
|
| 4442 |
|
| 4443 |
|
| 4444 |
|
| 4445 |
|
| 4446 |
|
| 4447 |
|
| 4448 |
|
| 4449 |
|
| 4450 |
|
| 4451 |
|
| 4452 |
static void |
| 4453 |
TopLevelReqProc( |
| 4454 |
ClientData dummy, |
| 4455 |
Tk_Window tkwin) |
| 4456 |
{ |
| 4457 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 4458 |
WmInfo *wmPtr; |
| 4459 |
|
| 4460 |
wmPtr = winPtr->wmInfoPtr; |
| 4461 |
|
| 4462 |
if ((wmPtr->width >= 0) && (wmPtr->height >= 0)) { |
| 4463 |
|
| 4464 |
|
| 4465 |
|
| 4466 |
|
| 4467 |
|
| 4468 |
|
| 4469 |
|
| 4470 |
|
| 4471 |
|
| 4472 |
|
| 4473 |
|
| 4474 |
|
| 4475 |
return; |
| 4476 |
} |
| 4477 |
|
| 4478 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 4479 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 4480 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr); |
| 4481 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 4482 |
} |
| 4483 |
|
| 4484 |
|
| 4485 |
|
| 4486 |
|
| 4487 |
|
| 4488 |
|
| 4489 |
if (wmPtr->flags & (WM_NEGATIVE_X | WM_NEGATIVE_Y)) { |
| 4490 |
wmPtr->flags |= WM_MOVE_PENDING; |
| 4491 |
} |
| 4492 |
} |
| 4493 |
|
| 4494 |
|
| 4495 |
|
| 4496 |
|
| 4497 |
|
| 4498 |
|
| 4499 |
|
| 4500 |
|
| 4501 |
|
| 4502 |
|
| 4503 |
|
| 4504 |
|
| 4505 |
|
| 4506 |
|
| 4507 |
|
| 4508 |
|
| 4509 |
|
| 4510 |
|
| 4511 |
|
| 4512 |
|
| 4513 |
|
| 4514 |
|
| 4515 |
static void |
| 4516 |
UpdateGeometryInfo( |
| 4517 |
ClientData clientData) |
| 4518 |
{ |
| 4519 |
register TkWindow *winPtr = (TkWindow *) clientData; |
| 4520 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 4521 |
int x, y, width, height, min, max; |
| 4522 |
unsigned long serial; |
| 4523 |
|
| 4524 |
wmPtr->flags &= ~WM_UPDATE_PENDING; |
| 4525 |
|
| 4526 |
|
| 4527 |
|
| 4528 |
|
| 4529 |
|
| 4530 |
|
| 4531 |
|
| 4532 |
|
| 4533 |
|
| 4534 |
|
| 4535 |
|
| 4536 |
if (wmPtr->width == -1) { |
| 4537 |
width = winPtr->reqWidth; |
| 4538 |
} else if (wmPtr->gridWin != NULL) { |
| 4539 |
width = winPtr->reqWidth |
| 4540 |
+ (wmPtr->width - wmPtr->reqGridWidth)*wmPtr->widthInc; |
| 4541 |
} else { |
| 4542 |
width = wmPtr->width; |
| 4543 |
} |
| 4544 |
if (width <= 0) { |
| 4545 |
width = 1; |
| 4546 |
} |
| 4547 |
|
| 4548 |
|
| 4549 |
|
| 4550 |
|
| 4551 |
|
| 4552 |
if (wmPtr->gridWin != NULL) { |
| 4553 |
min = winPtr->reqWidth |
| 4554 |
+ (wmPtr->minWidth - wmPtr->reqGridWidth)*wmPtr->widthInc; |
| 4555 |
if (wmPtr->maxWidth > 0) { |
| 4556 |
max = winPtr->reqWidth |
| 4557 |
+ (wmPtr->maxWidth - wmPtr->reqGridWidth)*wmPtr->widthInc; |
| 4558 |
} else { |
| 4559 |
max = 0; |
| 4560 |
} |
| 4561 |
} else { |
| 4562 |
min = wmPtr->minWidth; |
| 4563 |
max = wmPtr->maxWidth; |
| 4564 |
} |
| 4565 |
if (width < min) { |
| 4566 |
width = min; |
| 4567 |
} else if ((max > 0) && (width > max)) { |
| 4568 |
width = max; |
| 4569 |
} |
| 4570 |
|
| 4571 |
if (wmPtr->height == -1) { |
| 4572 |
height = winPtr->reqHeight; |
| 4573 |
} else if (wmPtr->gridWin != NULL) { |
| 4574 |
height = winPtr->reqHeight |
| 4575 |
+ (wmPtr->height - wmPtr->reqGridHeight)*wmPtr->heightInc; |
| 4576 |
} else { |
| 4577 |
height = wmPtr->height; |
| 4578 |
} |
| 4579 |
if (height <= 0) { |
| 4580 |
height = 1; |
| 4581 |
} |
| 4582 |
|
| 4583 |
|
| 4584 |
|
| 4585 |
|
| 4586 |
|
| 4587 |
if (wmPtr->gridWin != NULL) { |
| 4588 |
min = winPtr->reqHeight |
| 4589 |
+ (wmPtr->minHeight - wmPtr->reqGridHeight)*wmPtr->heightInc; |
| 4590 |
if (wmPtr->maxHeight > 0) { |
| 4591 |
max = winPtr->reqHeight |
| 4592 |
+ (wmPtr->maxHeight - wmPtr->reqGridHeight)*wmPtr->heightInc; |
| 4593 |
} else { |
| 4594 |
max = 0; |
| 4595 |
} |
| 4596 |
} else { |
| 4597 |
min = wmPtr->minHeight; |
| 4598 |
max = wmPtr->maxHeight; |
| 4599 |
} |
| 4600 |
if (height < min) { |
| 4601 |
height = min; |
| 4602 |
} else if ((max > 0) && (height > max)) { |
| 4603 |
height = max; |
| 4604 |
} |
| 4605 |
|
| 4606 |
|
| 4607 |
|
| 4608 |
|
| 4609 |
|
| 4610 |
|
| 4611 |
|
| 4612 |
|
| 4613 |
|
| 4614 |
if (wmPtr->flags & WM_NEGATIVE_X) { |
| 4615 |
x = wmPtr->vRootWidth - wmPtr->x |
| 4616 |
- (width + (wmPtr->parentWidth - winPtr->changes.width)); |
| 4617 |
} else { |
| 4618 |
x = wmPtr->x; |
| 4619 |
} |
| 4620 |
if (wmPtr->flags & WM_NEGATIVE_Y) { |
| 4621 |
y = wmPtr->vRootHeight - wmPtr->y |
| 4622 |
- (height + (wmPtr->parentHeight - winPtr->changes.height)); |
| 4623 |
} else { |
| 4624 |
y = wmPtr->y; |
| 4625 |
} |
| 4626 |
|
| 4627 |
|
| 4628 |
|
| 4629 |
|
| 4630 |
|
| 4631 |
|
| 4632 |
|
| 4633 |
|
| 4634 |
if (((width != winPtr->changes.width) |
| 4635 |
|| (height != winPtr->changes.height)) |
| 4636 |
&& (wmPtr->gridWin == NULL) |
| 4637 |
&& ((wmPtr->sizeHintsFlags & (PMinSize|PMaxSize)) == 0)) { |
| 4638 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 4639 |
} |
| 4640 |
if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) { |
| 4641 |
UpdateSizeHints(winPtr, width, height); |
| 4642 |
} |
| 4643 |
|
| 4644 |
|
| 4645 |
|
| 4646 |
|
| 4647 |
|
| 4648 |
|
| 4649 |
|
| 4650 |
|
| 4651 |
|
| 4652 |
|
| 4653 |
|
| 4654 |
|
| 4655 |
|
| 4656 |
|
| 4657 |
|
| 4658 |
|
| 4659 |
|
| 4660 |
|
| 4661 |
|
| 4662 |
|
| 4663 |
|
| 4664 |
|
| 4665 |
if ((winPtr->flags & (TK_EMBEDDED|TK_BOTH_HALVES)) |
| 4666 |
== (TK_EMBEDDED|TK_BOTH_HALVES)) { |
| 4667 |
TkWindow *childPtr = TkpGetOtherWindow(winPtr); |
| 4668 |
|
| 4669 |
|
| 4670 |
|
| 4671 |
|
| 4672 |
|
| 4673 |
|
| 4674 |
|
| 4675 |
|
| 4676 |
|
| 4677 |
wmPtr->x = wmPtr->y = 0; |
| 4678 |
wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); |
| 4679 |
height += wmPtr->menuHeight; |
| 4680 |
if (childPtr != NULL) { |
| 4681 |
Tk_GeometryRequest((Tk_Window) childPtr, width, height); |
| 4682 |
} |
| 4683 |
return; |
| 4684 |
} |
| 4685 |
serial = NextRequest(winPtr->display); |
| 4686 |
height += wmPtr->menuHeight; |
| 4687 |
if (wmPtr->flags & WM_MOVE_PENDING) { |
| 4688 |
if ((x + wmPtr->xInParent == winPtr->changes.x) && |
| 4689 |
(y + wmPtr->yInParent + wmPtr->menuHeight == winPtr->changes.y) |
| 4690 |
&& (width == wmPtr->wrapperPtr->changes.width) |
| 4691 |
&& (height == wmPtr->wrapperPtr->changes.height)) { |
| 4692 |
|
| 4693 |
|
| 4694 |
|
| 4695 |
|
| 4696 |
|
| 4697 |
|
| 4698 |
|
| 4699 |
wmPtr->flags &= ~WM_MOVE_PENDING; |
| 4700 |
return; |
| 4701 |
} |
| 4702 |
wmPtr->configWidth = width; |
| 4703 |
wmPtr->configHeight = height; |
| 4704 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4705 |
printf("UpdateGeometryInfo moving to %d %d, resizing to %dx%d,\n", |
| 4706 |
x, y, width, height); |
| 4707 |
} |
| 4708 |
XMoveResizeWindow(winPtr->display, wmPtr->wrapperPtr->window, x, y, |
| 4709 |
(unsigned) width, (unsigned) height); |
| 4710 |
} else if ((width != wmPtr->configWidth) |
| 4711 |
|| (height != wmPtr->configHeight)) { |
| 4712 |
if ((width == wmPtr->wrapperPtr->changes.width) |
| 4713 |
&& (height == wmPtr->wrapperPtr->changes.height)) { |
| 4714 |
|
| 4715 |
|
| 4716 |
|
| 4717 |
|
| 4718 |
|
| 4719 |
|
| 4720 |
|
| 4721 |
return; |
| 4722 |
} |
| 4723 |
wmPtr->configWidth = width; |
| 4724 |
wmPtr->configHeight = height; |
| 4725 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 4726 |
printf("UpdateGeometryInfo resizing %p to %d x %d\n", |
| 4727 |
(void *)wmPtr->wrapperPtr->window, width, height); |
| 4728 |
} |
| 4729 |
XResizeWindow(winPtr->display, wmPtr->wrapperPtr->window, |
| 4730 |
(unsigned) width, (unsigned) height); |
| 4731 |
} else if ((wmPtr->menubar != NULL) |
| 4732 |
&& ((Tk_Width(wmPtr->menubar) != wmPtr->wrapperPtr->changes.width) |
| 4733 |
|| (Tk_Height(wmPtr->menubar) != wmPtr->menuHeight))) { |
| 4734 |
|
| 4735 |
|
| 4736 |
|
| 4737 |
|
| 4738 |
|
| 4739 |
Tk_MoveResizeWindow(wmPtr->menubar, 0, 0, |
| 4740 |
wmPtr->wrapperPtr->changes.width, wmPtr->menuHeight); |
| 4741 |
XResizeWindow(winPtr->display, wmPtr->wrapperPtr->window, |
| 4742 |
(unsigned) width, (unsigned) height); |
| 4743 |
} else { |
| 4744 |
return; |
| 4745 |
} |
| 4746 |
|
| 4747 |
|
| 4748 |
|
| 4749 |
|
| 4750 |
|
| 4751 |
|
| 4752 |
|
| 4753 |
if (!(wmPtr->flags & WM_ABOUT_TO_MAP)) { |
| 4754 |
WaitForConfigureNotify(winPtr, serial); |
| 4755 |
} |
| 4756 |
} |
| 4757 |
|
| 4758 |
|
| 4759 |
|
| 4760 |
|
| 4761 |
|
| 4762 |
|
| 4763 |
|
| 4764 |
|
| 4765 |
|
| 4766 |
|
| 4767 |
|
| 4768 |
|
| 4769 |
|
| 4770 |
|
| 4771 |
|
| 4772 |
|
| 4773 |
|
| 4774 |
|
| 4775 |
static void |
| 4776 |
UpdateSizeHints( |
| 4777 |
TkWindow *winPtr, |
| 4778 |
int newWidth, |
| 4779 |
int newHeight) |
| 4780 |
{ |
| 4781 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 4782 |
XSizeHints *hintsPtr; |
| 4783 |
int maxWidth, maxHeight; |
| 4784 |
|
| 4785 |
wmPtr->flags &= ~WM_UPDATE_SIZE_HINTS; |
| 4786 |
|
| 4787 |
hintsPtr = XAllocSizeHints(); |
| 4788 |
if (hintsPtr == NULL) { |
| 4789 |
return; |
| 4790 |
} |
| 4791 |
|
| 4792 |
|
| 4793 |
|
| 4794 |
|
| 4795 |
|
| 4796 |
|
| 4797 |
GetMaxSize(wmPtr, &maxWidth, &maxHeight); |
| 4798 |
if (wmPtr->gridWin != NULL) { |
| 4799 |
hintsPtr->base_width = winPtr->reqWidth |
| 4800 |
- (wmPtr->reqGridWidth * wmPtr->widthInc); |
| 4801 |
if (hintsPtr->base_width < 0) { |
| 4802 |
hintsPtr->base_width = 0; |
| 4803 |
} |
| 4804 |
hintsPtr->base_height = winPtr->reqHeight + wmPtr->menuHeight |
| 4805 |
- (wmPtr->reqGridHeight * wmPtr->heightInc); |
| 4806 |
if (hintsPtr->base_height < 0) { |
| 4807 |
hintsPtr->base_height = 0; |
| 4808 |
} |
| 4809 |
hintsPtr->min_width = hintsPtr->base_width |
| 4810 |
+ (wmPtr->minWidth * wmPtr->widthInc); |
| 4811 |
hintsPtr->min_height = hintsPtr->base_height |
| 4812 |
+ (wmPtr->minHeight * wmPtr->heightInc); |
| 4813 |
hintsPtr->max_width = hintsPtr->base_width |
| 4814 |
+ (maxWidth * wmPtr->widthInc); |
| 4815 |
hintsPtr->max_height = hintsPtr->base_height |
| 4816 |
+ (maxHeight * wmPtr->heightInc); |
| 4817 |
} else { |
| 4818 |
hintsPtr->min_width = wmPtr->minWidth; |
| 4819 |
hintsPtr->min_height = wmPtr->minHeight; |
| 4820 |
hintsPtr->max_width = maxWidth; |
| 4821 |
hintsPtr->max_height = maxHeight; |
| 4822 |
hintsPtr->base_width = 0; |
| 4823 |
hintsPtr->base_height = 0; |
| 4824 |
} |
| 4825 |
hintsPtr->width_inc = wmPtr->widthInc; |
| 4826 |
hintsPtr->height_inc = wmPtr->heightInc; |
| 4827 |
hintsPtr->min_aspect.x = wmPtr->minAspect.x; |
| 4828 |
hintsPtr->min_aspect.y = wmPtr->minAspect.y; |
| 4829 |
hintsPtr->max_aspect.x = wmPtr->maxAspect.x; |
| 4830 |
hintsPtr->max_aspect.y = wmPtr->maxAspect.y; |
| 4831 |
hintsPtr->win_gravity = wmPtr->gravity; |
| 4832 |
hintsPtr->flags = wmPtr->sizeHintsFlags | PMinSize; |
| 4833 |
|
| 4834 |
|
| 4835 |
|
| 4836 |
|
| 4837 |
|
| 4838 |
|
| 4839 |
if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { |
| 4840 |
hintsPtr->max_width = hintsPtr->min_width = newWidth; |
| 4841 |
hintsPtr->flags |= PMaxSize; |
| 4842 |
} |
| 4843 |
if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { |
| 4844 |
hintsPtr->max_height = hintsPtr->min_height = |
| 4845 |
newHeight + wmPtr->menuHeight; |
| 4846 |
hintsPtr->flags |= PMaxSize; |
| 4847 |
} |
| 4848 |
|
| 4849 |
XSetWMNormalHints(winPtr->display, wmPtr->wrapperPtr->window, hintsPtr); |
| 4850 |
|
| 4851 |
XFree((char *) hintsPtr); |
| 4852 |
} |
| 4853 |
|
| 4854 |
|
| 4855 |
|
| 4856 |
|
| 4857 |
|
| 4858 |
|
| 4859 |
|
| 4860 |
|
| 4861 |
|
| 4862 |
|
| 4863 |
|
| 4864 |
|
| 4865 |
|
| 4866 |
|
| 4867 |
|
| 4868 |
|
| 4869 |
|
| 4870 |
|
| 4871 |
|
| 4872 |
|
| 4873 |
|
| 4874 |
|
| 4875 |
static void |
| 4876 |
UpdateTitle( |
| 4877 |
TkWindow *winPtr) |
| 4878 |
{ |
| 4879 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 4880 |
Atom XA_UTF8_STRING = Tk_InternAtom((Tk_Window) winPtr, "UTF8_STRING"); |
| 4881 |
const char *string; |
| 4882 |
Tcl_DString ds; |
| 4883 |
|
| 4884 |
|
| 4885 |
|
| 4886 |
|
| 4887 |
|
| 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); |
| 4893 |
|
| 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)); |
| 4898 |
|
| 4899 |
|
| 4900 |
|
| 4901 |
|
| 4902 |
|
| 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); |
| 4908 |
|
| 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)); |
| 4914 |
} |
| 4915 |
} |
| 4916 |
|
| 4917 |
|
| 4918 |
|
| 4919 |
|
| 4920 |
|
| 4921 |
|
| 4922 |
|
| 4923 |
|
| 4924 |
|
| 4925 |
|
| 4926 |
|
| 4927 |
|
| 4928 |
|
| 4929 |
|
| 4930 |
|
| 4931 |
static void |
| 4932 |
UpdatePhotoIcon( |
| 4933 |
TkWindow *winPtr) |
| 4934 |
{ |
| 4935 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 4936 |
unsigned char *data = wmPtr->iconDataPtr; |
| 4937 |
int size = wmPtr->iconDataSize; |
| 4938 |
|
| 4939 |
if (data == NULL) { |
| 4940 |
data = winPtr->dispPtr->iconDataPtr; |
| 4941 |
size = winPtr->dispPtr->iconDataSize; |
| 4942 |
} |
| 4943 |
if (data != NULL) { |
| 4944 |
|
| 4945 |
|
| 4946 |
|
| 4947 |
|
| 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); |
| 4952 |
} |
| 4953 |
} |
| 4954 |
|
| 4955 |
|
| 4956 |
|
| 4957 |
|
| 4958 |
|
| 4959 |
|
| 4960 |
|
| 4961 |
|
| 4962 |
|
| 4963 |
|
| 4964 |
|
| 4965 |
|
| 4966 |
|
| 4967 |
|
| 4968 |
|
| 4969 |
|
| 4970 |
|
| 4971 |
|
| 4972 |
|
| 4973 |
#define _NET_WM_STATE_REMOVE 0l |
| 4974 |
#define _NET_WM_STATE_ADD 1l |
| 4975 |
#define _NET_WM_STATE_TOGGLE 2l |
| 4976 |
|
| 4977 |
static void SetNetWmState(TkWindow *winPtr, const char *atomName, int on) |
| 4978 |
{ |
| 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); |
| 4983 |
XEvent e; |
| 4984 |
|
| 4985 |
if (!winPtr->wmInfoPtr->wrapperPtr) { |
| 4986 |
return; |
| 4987 |
} |
| 4988 |
|
| 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; |
| 4996 |
|
| 4997 |
XSendEvent(winPtr->display, |
| 4998 |
RootWindow(winPtr->display, winPtr->screenNum), 0, |
| 4999 |
SubstructureNotifyMask|SubstructureRedirectMask, &e); |
| 5000 |
} |
| 5001 |
|
| 5002 |
|
| 5003 |
|
| 5004 |
|
| 5005 |
|
| 5006 |
|
| 5007 |
|
| 5008 |
|
| 5009 |
|
| 5010 |
|
| 5011 |
|
| 5012 |
|
| 5013 |
|
| 5014 |
|
| 5015 |
static void CheckNetWmState(WmInfo *wmPtr, Atom *atoms, int numAtoms) |
| 5016 |
{ |
| 5017 |
Tk_Window tkwin = (Tk_Window)wmPtr->wrapperPtr; |
| 5018 |
int i; |
| 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"); |
| 5027 |
|
| 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; |
| 5040 |
} |
| 5041 |
} |
| 5042 |
|
| 5043 |
wmPtr->attributes.zoomed = (wmPtr->attributes.zoomed == 3); |
| 5044 |
|
| 5045 |
return; |
| 5046 |
} |
| 5047 |
|
| 5048 |
|
| 5049 |
|
| 5050 |
|
| 5051 |
|
| 5052 |
|
| 5053 |
|
| 5054 |
#define NET_WM_STATE_MAX_ATOMS 4 |
| 5055 |
static void UpdateNetWmState(WmInfo *wmPtr) |
| 5056 |
{ |
| 5057 |
Tk_Window tkwin = (Tk_Window)wmPtr->wrapperPtr; |
| 5058 |
Atom atoms[NET_WM_STATE_MAX_ATOMS]; |
| 5059 |
long numAtoms = 0; |
| 5060 |
|
| 5061 |
if (wmPtr->reqState.topmost) { |
| 5062 |
atoms[numAtoms++] = Tk_InternAtom(tkwin,"_NET_WM_STATE_ABOVE"); |
| 5063 |
} |
| 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"); |
| 5067 |
} |
| 5068 |
if (wmPtr->reqState.fullscreen) { |
| 5069 |
atoms[numAtoms++] = Tk_InternAtom(tkwin, "_NET_WM_STATE_FULLSCREEN"); |
| 5070 |
} |
| 5071 |
|
| 5072 |
XChangeProperty(Tk_Display(tkwin), wmPtr->wrapperPtr->window, |
| 5073 |
Tk_InternAtom(tkwin, "_NET_WM_STATE"), XA_ATOM, 32, |
| 5074 |
PropModeReplace, (unsigned char *)atoms, numAtoms); |
| 5075 |
} |
| 5076 |
|
| 5077 |
|
| 5078 |
|
| 5079 |
|
| 5080 |
|
| 5081 |
|
| 5082 |
|
| 5083 |
|
| 5084 |
|
| 5085 |
|
| 5086 |
|
| 5087 |
|
| 5088 |
|
| 5089 |
|
| 5090 |
|
| 5091 |
|
| 5092 |
|
| 5093 |
|
| 5094 |
|
| 5095 |
|
| 5096 |
|
| 5097 |
|
| 5098 |
|
| 5099 |
|
| 5100 |
|
| 5101 |
|
| 5102 |
|
| 5103 |
|
| 5104 |
|
| 5105 |
|
| 5106 |
|
| 5107 |
|
| 5108 |
|
| 5109 |
|
| 5110 |
|
| 5111 |
|
| 5112 |
|
| 5113 |
|
| 5114 |
|
| 5115 |
|
| 5116 |
|
| 5117 |
static void |
| 5118 |
WaitForConfigureNotify( |
| 5119 |
TkWindow *winPtr, |
| 5120 |
|
| 5121 |
unsigned long serial) |
| 5122 |
|
| 5123 |
{ |
| 5124 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 5125 |
XEvent event; |
| 5126 |
int diff, code; |
| 5127 |
int gotConfig = 0; |
| 5128 |
Window window = (wmPtr->reparent != None) ? wmPtr->reparent : wmPtr->wrapperPtr->window; |
| 5129 |
|
| 5130 |
|
| 5131 |
|
| 5132 |
|
| 5133 |
|
| 5134 |
|
| 5135 |
|
| 5136 |
|
| 5137 |
|
| 5138 |
|
| 5139 |
|
| 5140 |
|
| 5141 |
|
| 5142 |
if (window != wmPtr->wrapperPtr->window) { |
| 5143 |
Tk_ErrorHandler handler; |
| 5144 |
|
| 5145 |
|
| 5146 |
|
| 5147 |
|
| 5148 |
|
| 5149 |
|
| 5150 |
|
| 5151 |
|
| 5152 |
|
| 5153 |
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, |
| 5154 |
(Tk_ErrorProc *) NULL, (ClientData) NULL); |
| 5155 |
XSelectInput(winPtr->display, window, StructureNotifyMask); |
| 5156 |
Tk_DeleteErrorHandler(handler); |
| 5157 |
} |
| 5158 |
|
| 5159 |
while (!gotConfig) { |
| 5160 |
wmPtr->flags |= WM_SYNC_PENDING; |
| 5161 |
code = WaitForEvent(winPtr->display, wmPtr, ConfigureNotify, &event); |
| 5162 |
wmPtr->flags &= ~WM_SYNC_PENDING; |
| 5163 |
if (code != TCL_OK) { |
| 5164 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 5165 |
printf("WaitForConfigureNotify giving up on %s\n", |
| 5166 |
winPtr->pathName); |
| 5167 |
} |
| 5168 |
break; |
| 5169 |
} |
| 5170 |
diff = event.xconfigure.serial - serial; |
| 5171 |
if (diff >= 0) { |
| 5172 |
gotConfig = 1; |
| 5173 |
} |
| 5174 |
} |
| 5175 |
wmPtr->flags &= ~WM_MOVE_PENDING; |
| 5176 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 5177 |
printf("WaitForConfigureNotify finished with %s, serial %ld\n", |
| 5178 |
winPtr->pathName, serial); |
| 5179 |
} |
| 5180 |
|
| 5181 |
if (window != wmPtr->wrapperPtr->window) { |
| 5182 |
Tk_ErrorHandler handler; |
| 5183 |
|
| 5184 |
|
| 5185 |
|
| 5186 |
|
| 5187 |
|
| 5188 |
|
| 5189 |
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, |
| 5190 |
(Tk_ErrorProc *) NULL, (ClientData) NULL); |
| 5191 |
XSelectInput(winPtr->display, window, (long) 0); |
| 5192 |
Tk_DeleteErrorHandler(handler); |
| 5193 |
} |
| 5194 |
} |
| 5195 |
|
| 5196 |
|
| 5197 |
|
| 5198 |
|
| 5199 |
|
| 5200 |
|
| 5201 |
|
| 5202 |
|
| 5203 |
|
| 5204 |
|
| 5205 |
|
| 5206 |
|
| 5207 |
|
| 5208 |
|
| 5209 |
|
| 5210 |
|
| 5211 |
|
| 5212 |
|
| 5213 |
|
| 5214 |
|
| 5215 |
|
| 5216 |
|
| 5217 |
|
| 5218 |
|
| 5219 |
|
| 5220 |
static int |
| 5221 |
WaitForEvent( |
| 5222 |
Display *display, |
| 5223 |
WmInfo *wmInfoPtr, |
| 5224 |
int type, |
| 5225 |
XEvent *eventPtr) |
| 5226 |
{ |
| 5227 |
WaitRestrictInfo info; |
| 5228 |
Tk_RestrictProc *oldRestrictProc; |
| 5229 |
ClientData oldRestrictData; |
| 5230 |
Tcl_Time timeout; |
| 5231 |
|
| 5232 |
|
| 5233 |
|
| 5234 |
|
| 5235 |
|
| 5236 |
|
| 5237 |
|
| 5238 |
info.display = display; |
| 5239 |
info.wmInfoPtr = wmInfoPtr; |
| 5240 |
info.type = type; |
| 5241 |
info.eventPtr = eventPtr; |
| 5242 |
info.foundEvent = 0; |
| 5243 |
oldRestrictProc = Tk_RestrictEvents(WaitRestrictProc, (ClientData) &info, |
| 5244 |
&oldRestrictData); |
| 5245 |
|
| 5246 |
Tcl_GetTime(&timeout); |
| 5247 |
timeout.sec += 2; |
| 5248 |
|
| 5249 |
while (!info.foundEvent) { |
| 5250 |
if (!TkUnixDoOneXEvent(&timeout)) { |
| 5251 |
break; |
| 5252 |
} |
| 5253 |
} |
| 5254 |
(void) Tk_RestrictEvents(oldRestrictProc, oldRestrictData, |
| 5255 |
&oldRestrictData); |
| 5256 |
if (info.foundEvent) { |
| 5257 |
return TCL_OK; |
| 5258 |
} |
| 5259 |
return TCL_ERROR; |
| 5260 |
} |
| 5261 |
|
| 5262 |
|
| 5263 |
|
| 5264 |
|
| 5265 |
|
| 5266 |
|
| 5267 |
|
| 5268 |
|
| 5269 |
|
| 5270 |
|
| 5271 |
|
| 5272 |
|
| 5273 |
|
| 5274 |
|
| 5275 |
|
| 5276 |
|
| 5277 |
|
| 5278 |
|
| 5279 |
|
| 5280 |
|
| 5281 |
|
| 5282 |
|
| 5283 |
static Tk_RestrictAction |
| 5284 |
WaitRestrictProc( |
| 5285 |
ClientData clientData, |
| 5286 |
XEvent *eventPtr) |
| 5287 |
{ |
| 5288 |
WaitRestrictInfo *infoPtr = (WaitRestrictInfo *) clientData; |
| 5289 |
|
| 5290 |
if (eventPtr->type == SelectionNotify) { |
| 5291 |
return TK_PROCESS_EVENT; |
| 5292 |
} |
| 5293 |
if (eventPtr->type == ReparentNotify) { |
| 5294 |
return TK_PROCESS_EVENT; |
| 5295 |
} |
| 5296 |
if (((eventPtr->xany.window != infoPtr->wmInfoPtr->wrapperPtr->window) |
| 5297 |
&& (eventPtr->xany.window != infoPtr->wmInfoPtr->reparent)) |
| 5298 |
|| (eventPtr->xany.display != infoPtr->display)) { |
| 5299 |
return TK_DEFER_EVENT; |
| 5300 |
} |
| 5301 |
if (eventPtr->type == infoPtr->type) { |
| 5302 |
*infoPtr->eventPtr = *eventPtr; |
| 5303 |
infoPtr->foundEvent = 1; |
| 5304 |
return TK_PROCESS_EVENT; |
| 5305 |
} |
| 5306 |
if (eventPtr->type == ConfigureNotify || eventPtr->type == MapNotify |
| 5307 |
|| eventPtr->type == UnmapNotify) { |
| 5308 |
return TK_PROCESS_EVENT; |
| 5309 |
} |
| 5310 |
return TK_DEFER_EVENT; |
| 5311 |
} |
| 5312 |
|
| 5313 |
|
| 5314 |
|
| 5315 |
|
| 5316 |
|
| 5317 |
|
| 5318 |
|
| 5319 |
|
| 5320 |
|
| 5321 |
|
| 5322 |
|
| 5323 |
|
| 5324 |
|
| 5325 |
|
| 5326 |
|
| 5327 |
|
| 5328 |
|
| 5329 |
|
| 5330 |
|
| 5331 |
|
| 5332 |
|
| 5333 |
|
| 5334 |
|
| 5335 |
|
| 5336 |
|
| 5337 |
|
| 5338 |
static void |
| 5339 |
WaitForMapNotify( |
| 5340 |
TkWindow *winPtr, |
| 5341 |
|
| 5342 |
int mapped) |
| 5343 |
|
| 5344 |
|
| 5345 |
{ |
| 5346 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 5347 |
XEvent event; |
| 5348 |
int code; |
| 5349 |
|
| 5350 |
while (1) { |
| 5351 |
if (mapped) { |
| 5352 |
if (winPtr->flags & TK_MAPPED) { |
| 5353 |
break; |
| 5354 |
} |
| 5355 |
} else if (!(winPtr->flags & TK_MAPPED)) { |
| 5356 |
break; |
| 5357 |
} |
| 5358 |
wmPtr->flags |= WM_SYNC_PENDING; |
| 5359 |
code = WaitForEvent(winPtr->display, wmPtr, |
| 5360 |
mapped ? MapNotify : UnmapNotify, &event); |
| 5361 |
wmPtr->flags &= ~WM_SYNC_PENDING; |
| 5362 |
if (code != TCL_OK) { |
| 5363 |
|
| 5364 |
|
| 5365 |
|
| 5366 |
|
| 5367 |
|
| 5368 |
|
| 5369 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 5370 |
printf("WaitForMapNotify giving up on %s\n", winPtr->pathName); |
| 5371 |
} |
| 5372 |
break; |
| 5373 |
} |
| 5374 |
} |
| 5375 |
wmPtr->flags &= ~WM_MOVE_PENDING; |
| 5376 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 5377 |
printf("WaitForMapNotify finished with %s (winPtr %p, wmPtr %p)\n", |
| 5378 |
winPtr->pathName, winPtr, wmPtr); |
| 5379 |
} |
| 5380 |
} |
| 5381 |
|
| 5382 |
|
| 5383 |
|
| 5384 |
|
| 5385 |
|
| 5386 |
|
| 5387 |
|
| 5388 |
|
| 5389 |
|
| 5390 |
|
| 5391 |
|
| 5392 |
|
| 5393 |
|
| 5394 |
|
| 5395 |
|
| 5396 |
|
| 5397 |
|
| 5398 |
|
| 5399 |
static void |
| 5400 |
UpdateHints( |
| 5401 |
TkWindow *winPtr) |
| 5402 |
{ |
| 5403 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 5404 |
|
| 5405 |
if (wmPtr->flags & WM_NEVER_MAPPED) { |
| 5406 |
return; |
| 5407 |
} |
| 5408 |
XSetWMHints(winPtr->display, wmPtr->wrapperPtr->window, &wmPtr->hints); |
| 5409 |
} |
| 5410 |
|
| 5411 |
|
| 5412 |
|
| 5413 |
|
| 5414 |
|
| 5415 |
|
| 5416 |
|
| 5417 |
|
| 5418 |
|
| 5419 |
|
| 5420 |
|
| 5421 |
|
| 5422 |
|
| 5423 |
|
| 5424 |
|
| 5425 |
|
| 5426 |
|
| 5427 |
|
| 5428 |
|
| 5429 |
static int |
| 5430 |
ParseGeometry( |
| 5431 |
Tcl_Interp *interp, |
| 5432 |
char *string, |
| 5433 |
|
| 5434 |
TkWindow *winPtr) |
| 5435 |
|
| 5436 |
{ |
| 5437 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 5438 |
int x, y, width, height, flags; |
| 5439 |
char *end; |
| 5440 |
register char *p = string; |
| 5441 |
|
| 5442 |
|
| 5443 |
|
| 5444 |
|
| 5445 |
|
| 5446 |
if (*p == '=') { |
| 5447 |
p++; |
| 5448 |
} |
| 5449 |
|
| 5450 |
|
| 5451 |
|
| 5452 |
|
| 5453 |
|
| 5454 |
|
| 5455 |
|
| 5456 |
width = wmPtr->width; |
| 5457 |
height = wmPtr->height; |
| 5458 |
x = wmPtr->x; |
| 5459 |
y = wmPtr->y; |
| 5460 |
flags = wmPtr->flags; |
| 5461 |
if (isdigit(UCHAR(*p))) { |
| 5462 |
width = strtoul(p, &end, 10); |
| 5463 |
p = end; |
| 5464 |
if (*p != 'x') { |
| 5465 |
goto error; |
| 5466 |
} |
| 5467 |
p++; |
| 5468 |
if (!isdigit(UCHAR(*p))) { |
| 5469 |
goto error; |
| 5470 |
} |
| 5471 |
height = strtoul(p, &end, 10); |
| 5472 |
p = end; |
| 5473 |
} |
| 5474 |
|
| 5475 |
|
| 5476 |
|
| 5477 |
|
| 5478 |
|
| 5479 |
if (*p != '\0') { |
| 5480 |
flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y); |
| 5481 |
if (*p == '-') { |
| 5482 |
flags |= WM_NEGATIVE_X; |
| 5483 |
} else if (*p != '+') { |
| 5484 |
goto error; |
| 5485 |
} |
| 5486 |
p++; |
| 5487 |
if (!isdigit(UCHAR(*p)) && (*p != '-')) { |
| 5488 |
goto error; |
| 5489 |
} |
| 5490 |
x = strtol(p, &end, 10); |
| 5491 |
p = end; |
| 5492 |
if (*p == '-') { |
| 5493 |
flags |= WM_NEGATIVE_Y; |
| 5494 |
} else if (*p != '+') { |
| 5495 |
goto error; |
| 5496 |
} |
| 5497 |
p++; |
| 5498 |
if (!isdigit(UCHAR(*p)) && (*p != '-')) { |
| 5499 |
goto error; |
| 5500 |
} |
| 5501 |
y = strtol(p, &end, 10); |
| 5502 |
if (*end != '\0') { |
| 5503 |
goto error; |
| 5504 |
} |
| 5505 |
|
| 5506 |
|
| 5507 |
|
| 5508 |
|
| 5509 |
|
| 5510 |
|
| 5511 |
|
| 5512 |
|
| 5513 |
if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) { |
| 5514 |
wmPtr->sizeHintsFlags |= USPosition; |
| 5515 |
flags |= WM_UPDATE_SIZE_HINTS; |
| 5516 |
} |
| 5517 |
} |
| 5518 |
|
| 5519 |
|
| 5520 |
|
| 5521 |
|
| 5522 |
|
| 5523 |
|
| 5524 |
|
| 5525 |
wmPtr->width = width; |
| 5526 |
wmPtr->height = height; |
| 5527 |
wmPtr->x = x; |
| 5528 |
wmPtr->y = y; |
| 5529 |
flags |= WM_MOVE_PENDING; |
| 5530 |
wmPtr->flags = flags; |
| 5531 |
|
| 5532 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 5533 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr); |
| 5534 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 5535 |
} |
| 5536 |
return TCL_OK; |
| 5537 |
|
| 5538 |
error: |
| 5539 |
Tcl_AppendResult(interp, "bad geometry specifier \"", string, "\"", NULL); |
| 5540 |
return TCL_ERROR; |
| 5541 |
} |
| 5542 |
|
| 5543 |
|
| 5544 |
|
| 5545 |
|
| 5546 |
|
| 5547 |
|
| 5548 |
|
| 5549 |
|
| 5550 |
|
| 5551 |
|
| 5552 |
|
| 5553 |
|
| 5554 |
|
| 5555 |
|
| 5556 |
|
| 5557 |
|
| 5558 |
|
| 5559 |
|
| 5560 |
|
| 5561 |
|
| 5562 |
|
| 5563 |
|
| 5564 |
void |
| 5565 |
Tk_GetRootCoords( |
| 5566 |
Tk_Window tkwin, |
| 5567 |
int *xPtr, |
| 5568 |
int *yPtr) |
| 5569 |
{ |
| 5570 |
int x, y; |
| 5571 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 5572 |
|
| 5573 |
|
| 5574 |
|
| 5575 |
|
| 5576 |
|
| 5577 |
|
| 5578 |
x = y = 0; |
| 5579 |
while (1) { |
| 5580 |
x += winPtr->changes.x + winPtr->changes.border_width; |
| 5581 |
y += winPtr->changes.y + winPtr->changes.border_width; |
| 5582 |
if ((winPtr->wmInfoPtr != NULL) |
| 5583 |
&& (winPtr->wmInfoPtr->menubar == (Tk_Window) winPtr)) { |
| 5584 |
|
| 5585 |
|
| 5586 |
|
| 5587 |
|
| 5588 |
|
| 5589 |
y -= winPtr->wmInfoPtr->menuHeight; |
| 5590 |
winPtr = winPtr->wmInfoPtr->winPtr; |
| 5591 |
continue; |
| 5592 |
} |
| 5593 |
if (winPtr->flags & TK_TOP_LEVEL) { |
| 5594 |
TkWindow *otherPtr; |
| 5595 |
if (!(winPtr->flags & TK_EMBEDDED)) { |
| 5596 |
break; |
| 5597 |
} |
| 5598 |
otherPtr = TkpGetOtherWindow(winPtr); |
| 5599 |
if (otherPtr == NULL) { |
| 5600 |
|
| 5601 |
|
| 5602 |
|
| 5603 |
|
| 5604 |
|
| 5605 |
Window root, dummyChild; |
| 5606 |
int rootX, rootY; |
| 5607 |
|
| 5608 |
root = winPtr->wmInfoPtr->vRoot; |
| 5609 |
if (root == None) { |
| 5610 |
root = RootWindowOfScreen(Tk_Screen((Tk_Window)winPtr)); |
| 5611 |
} |
| 5612 |
XTranslateCoordinates(winPtr->display, winPtr->window, |
| 5613 |
root, 0, 0, &rootX, &rootY, &dummyChild); |
| 5614 |
x += rootX; |
| 5615 |
y += rootY; |
| 5616 |
break; |
| 5617 |
} else { |
| 5618 |
|
| 5619 |
|
| 5620 |
|
| 5621 |
|
| 5622 |
|
| 5623 |
winPtr = otherPtr; |
| 5624 |
continue; |
| 5625 |
} |
| 5626 |
} |
| 5627 |
winPtr = winPtr->parentPtr; |
| 5628 |
if (winPtr == NULL) { |
| 5629 |
break; |
| 5630 |
} |
| 5631 |
} |
| 5632 |
*xPtr = x; |
| 5633 |
*yPtr = y; |
| 5634 |
} |
| 5635 |
|
| 5636 |
|
| 5637 |
|
| 5638 |
|
| 5639 |
|
| 5640 |
|
| 5641 |
|
| 5642 |
|
| 5643 |
|
| 5644 |
|
| 5645 |
|
| 5646 |
|
| 5647 |
|
| 5648 |
|
| 5649 |
|
| 5650 |
|
| 5651 |
|
| 5652 |
|
| 5653 |
|
| 5654 |
|
| 5655 |
|
| 5656 |
Tk_Window |
| 5657 |
Tk_CoordsToWindow( |
| 5658 |
int rootX, int rootY, |
| 5659 |
|
| 5660 |
|
| 5661 |
|
| 5662 |
Tk_Window tkwin) |
| 5663 |
|
| 5664 |
{ |
| 5665 |
Window window, parent, child; |
| 5666 |
int x, y, childX, childY, tmpx, tmpy, bd; |
| 5667 |
WmInfo *wmPtr; |
| 5668 |
TkWindow *winPtr, *childPtr, *nextPtr; |
| 5669 |
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; |
| 5670 |
Tk_ErrorHandler handler = NULL; |
| 5671 |
|
| 5672 |
|
| 5673 |
|
| 5674 |
|
| 5675 |
|
| 5676 |
|
| 5677 |
|
| 5678 |
parent = window = RootWindowOfScreen(Tk_Screen(tkwin)); |
| 5679 |
x = rootX; |
| 5680 |
y = rootY; |
| 5681 |
for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; |
| 5682 |
wmPtr = wmPtr->nextPtr) { |
| 5683 |
if (Tk_Screen(wmPtr->winPtr) != Tk_Screen(tkwin)) { |
| 5684 |
continue; |
| 5685 |
} |
| 5686 |
if (wmPtr->vRoot == None) { |
| 5687 |
continue; |
| 5688 |
} |
| 5689 |
UpdateVRootGeometry(wmPtr); |
| 5690 |
parent = wmPtr->vRoot; |
| 5691 |
break; |
| 5692 |
} |
| 5693 |
|
| 5694 |
|
| 5695 |
|
| 5696 |
|
| 5697 |
|
| 5698 |
|
| 5699 |
|
| 5700 |
|
| 5701 |
|
| 5702 |
|
| 5703 |
|
| 5704 |
|
| 5705 |
|
| 5706 |
|
| 5707 |
|
| 5708 |
handler = Tk_CreateErrorHandler(Tk_Display(tkwin), -1, -1, -1, NULL, NULL); |
| 5709 |
while (1) { |
| 5710 |
if (XTranslateCoordinates(Tk_Display(tkwin), parent, window, |
| 5711 |
x, y, &childX, &childY, &child) == False) { |
| 5712 |
|
| 5713 |
|
| 5714 |
|
| 5715 |
|
| 5716 |
|
| 5717 |
Tk_DeleteErrorHandler(handler); |
| 5718 |
return NULL; |
| 5719 |
} |
| 5720 |
if (child == None) { |
| 5721 |
Tk_DeleteErrorHandler(handler); |
| 5722 |
return NULL; |
| 5723 |
} |
| 5724 |
for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; |
| 5725 |
wmPtr = wmPtr->nextPtr) { |
| 5726 |
if (wmPtr->reparent == child) { |
| 5727 |
goto gotToplevel; |
| 5728 |
} |
| 5729 |
if (wmPtr->wrapperPtr != NULL) { |
| 5730 |
if (child == wmPtr->wrapperPtr->window) { |
| 5731 |
goto gotToplevel; |
| 5732 |
} |
| 5733 |
} else if (child == wmPtr->winPtr->window) { |
| 5734 |
goto gotToplevel; |
| 5735 |
} |
| 5736 |
} |
| 5737 |
x = childX; |
| 5738 |
y = childY; |
| 5739 |
parent = window; |
| 5740 |
window = child; |
| 5741 |
} |
| 5742 |
|
| 5743 |
gotToplevel: |
| 5744 |
if (handler) { |
| 5745 |
|
| 5746 |
|
| 5747 |
|
| 5748 |
|
| 5749 |
|
| 5750 |
Tk_DeleteErrorHandler(handler); |
| 5751 |
handler = NULL; |
| 5752 |
} |
| 5753 |
winPtr = wmPtr->winPtr; |
| 5754 |
if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { |
| 5755 |
return NULL; |
| 5756 |
} |
| 5757 |
|
| 5758 |
|
| 5759 |
|
| 5760 |
|
| 5761 |
|
| 5762 |
|
| 5763 |
|
| 5764 |
|
| 5765 |
|
| 5766 |
x = childX - winPtr->changes.x; |
| 5767 |
y = childY - winPtr->changes.y; |
| 5768 |
if ((x < 0) || (x >= winPtr->changes.width) |
| 5769 |
|| (y >= winPtr->changes.height)) { |
| 5770 |
return NULL; |
| 5771 |
} |
| 5772 |
if (y < 0) { |
| 5773 |
winPtr = (TkWindow *) wmPtr->menubar; |
| 5774 |
if (winPtr == NULL) { |
| 5775 |
return NULL; |
| 5776 |
} |
| 5777 |
y += wmPtr->menuHeight; |
| 5778 |
if (y < 0) { |
| 5779 |
return NULL; |
| 5780 |
} |
| 5781 |
} |
| 5782 |
|
| 5783 |
|
| 5784 |
|
| 5785 |
|
| 5786 |
|
| 5787 |
|
| 5788 |
|
| 5789 |
|
| 5790 |
while (1) { |
| 5791 |
nextPtr = NULL; |
| 5792 |
for (childPtr = winPtr->childList; childPtr != NULL; |
| 5793 |
childPtr = childPtr->nextPtr) { |
| 5794 |
if (!Tk_IsMapped(childPtr) |
| 5795 |
|| (childPtr->flags & TK_TOP_HIERARCHY)) { |
| 5796 |
continue; |
| 5797 |
} |
| 5798 |
if (childPtr->flags & TK_REPARENTED) { |
| 5799 |
continue; |
| 5800 |
} |
| 5801 |
tmpx = x - childPtr->changes.x; |
| 5802 |
tmpy = y - childPtr->changes.y; |
| 5803 |
bd = childPtr->changes.border_width; |
| 5804 |
if ((tmpx >= -bd) && (tmpy >= -bd) |
| 5805 |
&& (tmpx < (childPtr->changes.width + bd)) |
| 5806 |
&& (tmpy < (childPtr->changes.height + bd))) { |
| 5807 |
nextPtr = childPtr; |
| 5808 |
} |
| 5809 |
} |
| 5810 |
if (nextPtr == NULL) { |
| 5811 |
break; |
| 5812 |
} |
| 5813 |
winPtr = nextPtr; |
| 5814 |
x -= winPtr->changes.x; |
| 5815 |
y -= winPtr->changes.y; |
| 5816 |
if ((winPtr->flags & TK_CONTAINER) |
| 5817 |
&& (winPtr->flags & TK_BOTH_HALVES)) { |
| 5818 |
|
| 5819 |
|
| 5820 |
|
| 5821 |
|
| 5822 |
|
| 5823 |
|
| 5824 |
|
| 5825 |
winPtr = TkpGetOtherWindow(winPtr); |
| 5826 |
if (winPtr == NULL) { |
| 5827 |
return NULL; |
| 5828 |
} |
| 5829 |
wmPtr = winPtr->wmInfoPtr; |
| 5830 |
childX = x; |
| 5831 |
childY = y; |
| 5832 |
goto gotToplevel; |
| 5833 |
} |
| 5834 |
} |
| 5835 |
return (Tk_Window) winPtr; |
| 5836 |
} |
| 5837 |
|
| 5838 |
|
| 5839 |
|
| 5840 |
|
| 5841 |
|
| 5842 |
|
| 5843 |
|
| 5844 |
|
| 5845 |
|
| 5846 |
|
| 5847 |
|
| 5848 |
|
| 5849 |
|
| 5850 |
|
| 5851 |
|
| 5852 |
|
| 5853 |
|
| 5854 |
|
| 5855 |
|
| 5856 |
static void |
| 5857 |
UpdateVRootGeometry( |
| 5858 |
WmInfo *wmPtr) |
| 5859 |
|
| 5860 |
{ |
| 5861 |
TkWindow *winPtr = wmPtr->winPtr; |
| 5862 |
int bd; |
| 5863 |
unsigned int dummy; |
| 5864 |
Window dummy2; |
| 5865 |
Status status; |
| 5866 |
Tk_ErrorHandler handler; |
| 5867 |
|
| 5868 |
|
| 5869 |
|
| 5870 |
|
| 5871 |
|
| 5872 |
|
| 5873 |
wmPtr->flags &= ~WM_VROOT_OFFSET_STALE; |
| 5874 |
if (wmPtr->vRoot == None) { |
| 5875 |
noVRoot: |
| 5876 |
wmPtr->vRootX = wmPtr->vRootY = 0; |
| 5877 |
wmPtr->vRootWidth = DisplayWidth(winPtr->display, winPtr->screenNum); |
| 5878 |
wmPtr->vRootHeight = DisplayHeight(winPtr->display, winPtr->screenNum); |
| 5879 |
return; |
| 5880 |
} |
| 5881 |
|
| 5882 |
|
| 5883 |
|
| 5884 |
|
| 5885 |
|
| 5886 |
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, NULL, NULL); |
| 5887 |
status = XGetGeometry(winPtr->display, wmPtr->vRoot, |
| 5888 |
&dummy2, &wmPtr->vRootX, &wmPtr->vRootY, |
| 5889 |
(unsigned int *) &wmPtr->vRootWidth, |
| 5890 |
(unsigned int *) &wmPtr->vRootHeight, (unsigned int *) &bd, |
| 5891 |
&dummy); |
| 5892 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 5893 |
printf("UpdateVRootGeometry: x = %d, y = %d, width = %d, ", |
| 5894 |
wmPtr->vRootX, wmPtr->vRootY, wmPtr->vRootWidth); |
| 5895 |
printf("height = %d, status = %d\n", wmPtr->vRootHeight, status); |
| 5896 |
} |
| 5897 |
Tk_DeleteErrorHandler(handler); |
| 5898 |
if (status == 0) { |
| 5899 |
|
| 5900 |
|
| 5901 |
|
| 5902 |
|
| 5903 |
wmPtr->vRoot = None; |
| 5904 |
goto noVRoot; |
| 5905 |
} |
| 5906 |
} |
| 5907 |
|
| 5908 |
|
| 5909 |
|
| 5910 |
|
| 5911 |
|
| 5912 |
|
| 5913 |
|
| 5914 |
|
| 5915 |
|
| 5916 |
|
| 5917 |
|
| 5918 |
|
| 5919 |
|
| 5920 |
|
| 5921 |
|
| 5922 |
|
| 5923 |
|
| 5924 |
|
| 5925 |
|
| 5926 |
|
| 5927 |
|
| 5928 |
|
| 5929 |
void |
| 5930 |
Tk_GetVRootGeometry( |
| 5931 |
Tk_Window tkwin, |
| 5932 |
|
| 5933 |
int *xPtr, int *yPtr, |
| 5934 |
|
| 5935 |
int *widthPtr, int *heightPtr) |
| 5936 |
|
| 5937 |
{ |
| 5938 |
WmInfo *wmPtr; |
| 5939 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 5940 |
|
| 5941 |
|
| 5942 |
|
| 5943 |
|
| 5944 |
|
| 5945 |
|
| 5946 |
while (!(winPtr->flags & TK_TOP_HIERARCHY) |
| 5947 |
&& (winPtr->parentPtr != NULL)) { |
| 5948 |
winPtr = winPtr->parentPtr; |
| 5949 |
} |
| 5950 |
wmPtr = winPtr->wmInfoPtr; |
| 5951 |
if (wmPtr == NULL) { |
| 5952 |
|
| 5953 |
*xPtr = 0; |
| 5954 |
*yPtr = 0; |
| 5955 |
*widthPtr = 0; |
| 5956 |
*heightPtr = 0; |
| 5957 |
} |
| 5958 |
|
| 5959 |
|
| 5960 |
|
| 5961 |
|
| 5962 |
|
| 5963 |
|
| 5964 |
if (wmPtr->flags & WM_VROOT_OFFSET_STALE) { |
| 5965 |
UpdateVRootGeometry(wmPtr); |
| 5966 |
} |
| 5967 |
*xPtr = wmPtr->vRootX; |
| 5968 |
*yPtr = wmPtr->vRootY; |
| 5969 |
*widthPtr = wmPtr->vRootWidth; |
| 5970 |
*heightPtr = wmPtr->vRootHeight; |
| 5971 |
} |
| 5972 |
|
| 5973 |
|
| 5974 |
|
| 5975 |
|
| 5976 |
|
| 5977 |
|
| 5978 |
|
| 5979 |
|
| 5980 |
|
| 5981 |
|
| 5982 |
|
| 5983 |
|
| 5984 |
|
| 5985 |
|
| 5986 |
|
| 5987 |
|
| 5988 |
|
| 5989 |
|
| 5990 |
|
| 5991 |
|
| 5992 |
|
| 5993 |
void |
| 5994 |
Tk_MoveToplevelWindow( |
| 5995 |
Tk_Window tkwin, |
| 5996 |
int x, int y) |
| 5997 |
{ |
| 5998 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 5999 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 6000 |
|
| 6001 |
if (!(winPtr->flags & TK_TOP_LEVEL)) { |
| 6002 |
Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window"); |
| 6003 |
} |
| 6004 |
wmPtr->x = x; |
| 6005 |
wmPtr->y = y; |
| 6006 |
wmPtr->flags |= WM_MOVE_PENDING; |
| 6007 |
wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); |
| 6008 |
if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) { |
| 6009 |
wmPtr->sizeHintsFlags |= USPosition; |
| 6010 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 6011 |
} |
| 6012 |
|
| 6013 |
|
| 6014 |
|
| 6015 |
|
| 6016 |
|
| 6017 |
|
| 6018 |
|
| 6019 |
if (!(wmPtr->flags & WM_NEVER_MAPPED)) { |
| 6020 |
if (wmPtr->flags & WM_UPDATE_PENDING) { |
| 6021 |
Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); |
| 6022 |
} |
| 6023 |
UpdateGeometryInfo((ClientData) winPtr); |
| 6024 |
} |
| 6025 |
} |
| 6026 |
|
| 6027 |
|
| 6028 |
|
| 6029 |
|
| 6030 |
|
| 6031 |
|
| 6032 |
|
| 6033 |
|
| 6034 |
|
| 6035 |
|
| 6036 |
|
| 6037 |
|
| 6038 |
|
| 6039 |
|
| 6040 |
|
| 6041 |
|
| 6042 |
|
| 6043 |
|
| 6044 |
|
| 6045 |
static void |
| 6046 |
UpdateWmProtocols( |
| 6047 |
register WmInfo *wmPtr) |
| 6048 |
{ |
| 6049 |
register ProtocolHandler *protPtr; |
| 6050 |
Atom deleteWindowAtom; |
| 6051 |
int count; |
| 6052 |
Atom *arrayPtr, *atomPtr; |
| 6053 |
|
| 6054 |
|
| 6055 |
|
| 6056 |
|
| 6057 |
|
| 6058 |
|
| 6059 |
|
| 6060 |
|
| 6061 |
for (protPtr = wmPtr->protPtr, count = 1; protPtr != NULL; |
| 6062 |
protPtr = protPtr->nextPtr, count++) { |
| 6063 |
|
| 6064 |
} |
| 6065 |
arrayPtr = (Atom *) ckalloc((unsigned) (count * sizeof(Atom))); |
| 6066 |
deleteWindowAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr, |
| 6067 |
"WM_DELETE_WINDOW"); |
| 6068 |
arrayPtr[0] = deleteWindowAtom; |
| 6069 |
for (protPtr = wmPtr->protPtr, atomPtr = &arrayPtr[1]; |
| 6070 |
protPtr != NULL; protPtr = protPtr->nextPtr) { |
| 6071 |
if (protPtr->protocol != deleteWindowAtom) { |
| 6072 |
*atomPtr = protPtr->protocol; |
| 6073 |
atomPtr++; |
| 6074 |
} |
| 6075 |
} |
| 6076 |
XChangeProperty(wmPtr->winPtr->display, wmPtr->wrapperPtr->window, |
| 6077 |
Tk_InternAtom((Tk_Window) wmPtr->winPtr, "WM_PROTOCOLS"), |
| 6078 |
XA_ATOM, 32, PropModeReplace, (unsigned char *) arrayPtr, |
| 6079 |
atomPtr-arrayPtr); |
| 6080 |
ckfree((char *) arrayPtr); |
| 6081 |
} |
| 6082 |
|
| 6083 |
|
| 6084 |
|
| 6085 |
|
| 6086 |
|
| 6087 |
|
| 6088 |
|
| 6089 |
|
| 6090 |
|
| 6091 |
|
| 6092 |
|
| 6093 |
|
| 6094 |
|
| 6095 |
|
| 6096 |
|
| 6097 |
|
| 6098 |
|
| 6099 |
|
| 6100 |
|
| 6101 |
void |
| 6102 |
TkWmProtocolEventProc( |
| 6103 |
TkWindow *winPtr, |
| 6104 |
XEvent *eventPtr) |
| 6105 |
{ |
| 6106 |
WmInfo *wmPtr; |
| 6107 |
register ProtocolHandler *protPtr; |
| 6108 |
Atom protocol; |
| 6109 |
int result; |
| 6110 |
CONST char *protocolName; |
| 6111 |
Tcl_Interp *interp; |
| 6112 |
|
| 6113 |
wmPtr = winPtr->wmInfoPtr; |
| 6114 |
if (wmPtr == NULL) { |
| 6115 |
return; |
| 6116 |
} |
| 6117 |
protocol = (Atom) eventPtr->xclient.data.l[0]; |
| 6118 |
|
| 6119 |
|
| 6120 |
|
| 6121 |
|
| 6122 |
|
| 6123 |
|
| 6124 |
|
| 6125 |
|
| 6126 |
|
| 6127 |
protocolName = Tk_GetAtomName((Tk_Window) winPtr, protocol); |
| 6128 |
for (protPtr = wmPtr->protPtr; protPtr != NULL; |
| 6129 |
protPtr = protPtr->nextPtr) { |
| 6130 |
if (protocol == protPtr->protocol) { |
| 6131 |
Tcl_Preserve((ClientData) protPtr); |
| 6132 |
interp = protPtr->interp; |
| 6133 |
Tcl_Preserve((ClientData) interp); |
| 6134 |
winPtr->dispPtr->lastEventTime = (Time) eventPtr->xclient.data.l[1]; |
| 6135 |
result = LangDoCallback(protPtr->interp, protPtr->command, 0, 0); |
| 6136 |
if (result != TCL_OK) { |
| 6137 |
Tcl_AddErrorInfo(interp, "\n (command for \""); |
| 6138 |
Tcl_AddErrorInfo(interp, protocolName); |
| 6139 |
Tcl_AddErrorInfo(interp, |
| 6140 |
"\" window manager protocol)"); |
| 6141 |
Tcl_BackgroundError(interp); |
| 6142 |
} |
| 6143 |
Tcl_Release((ClientData) interp); |
| 6144 |
Tcl_Release((ClientData) protPtr); |
| 6145 |
return; |
| 6146 |
} |
| 6147 |
} |
| 6148 |
|
| 6149 |
|
| 6150 |
|
| 6151 |
|
| 6152 |
|
| 6153 |
|
| 6154 |
if (protocol == Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW")) { |
| 6155 |
Tk_DestroyWindow((Tk_Window) wmPtr->winPtr); |
| 6156 |
} |
| 6157 |
} |
| 6158 |
|
| 6159 |
|
| 6160 |
|
| 6161 |
|
| 6162 |
|
| 6163 |
|
| 6164 |
|
| 6165 |
|
| 6166 |
|
| 6167 |
|
| 6168 |
|
| 6169 |
|
| 6170 |
|
| 6171 |
|
| 6172 |
|
| 6173 |
|
| 6174 |
|
| 6175 |
|
| 6176 |
|
| 6177 |
|
| 6178 |
|
| 6179 |
|
| 6180 |
static void |
| 6181 |
TkWmStackorderToplevelWrapperMap( |
| 6182 |
TkWindow *winPtr, |
| 6183 |
Display *display, |
| 6184 |
Tcl_HashTable *table) |
| 6185 |
{ |
| 6186 |
TkWindow *childPtr; |
| 6187 |
|
| 6188 |
if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && |
| 6189 |
!Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { |
| 6190 |
Window wrapper = (winPtr->wmInfoPtr->reparent != None) |
| 6191 |
? winPtr->wmInfoPtr->reparent |
| 6192 |
: winPtr->wmInfoPtr->wrapperPtr->window; |
| 6193 |
Tcl_HashEntry *hPtr; |
| 6194 |
int newEntry; |
| 6195 |
|
| 6196 |
hPtr = Tcl_CreateHashEntry(table, (char *) wrapper, &newEntry); |
| 6197 |
Tcl_SetHashValue(hPtr, winPtr); |
| 6198 |
} |
| 6199 |
|
| 6200 |
for (childPtr = winPtr->childList; childPtr != NULL; |
| 6201 |
childPtr = childPtr->nextPtr) { |
| 6202 |
TkWmStackorderToplevelWrapperMap(childPtr, display, table); |
| 6203 |
} |
| 6204 |
} |
| 6205 |
|
| 6206 |
|
| 6207 |
|
| 6208 |
|
| 6209 |
|
| 6210 |
|
| 6211 |
|
| 6212 |
|
| 6213 |
|
| 6214 |
|
| 6215 |
|
| 6216 |
|
| 6217 |
|
| 6218 |
|
| 6219 |
|
| 6220 |
|
| 6221 |
|
| 6222 |
|
| 6223 |
TkWindow ** |
| 6224 |
TkWmStackorderToplevel( |
| 6225 |
TkWindow *parentPtr) |
| 6226 |
{ |
| 6227 |
Window dummy1, dummy2, vRoot; |
| 6228 |
Window *children; |
| 6229 |
unsigned int numChildren, i; |
| 6230 |
TkWindow *childWinPtr, **windows, **window_ptr; |
| 6231 |
Tcl_HashTable table; |
| 6232 |
Tcl_HashEntry *hPtr; |
| 6233 |
Tcl_HashSearch search; |
| 6234 |
|
| 6235 |
|
| 6236 |
|
| 6237 |
|
| 6238 |
|
| 6239 |
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); |
| 6240 |
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); |
| 6241 |
|
| 6242 |
window_ptr = windows = (TkWindow **) |
| 6243 |
ckalloc((table.numEntries+1) * sizeof(TkWindow *)); |
| 6244 |
|
| 6245 |
|
| 6246 |
|
| 6247 |
|
| 6248 |
|
| 6249 |
|
| 6250 |
switch (table.numEntries) { |
| 6251 |
case 0: |
| 6252 |
windows[0] = NULL; |
| 6253 |
goto done; |
| 6254 |
case 1: |
| 6255 |
hPtr = Tcl_FirstHashEntry(&table, &search); |
| 6256 |
windows[0] = (TkWindow *) Tcl_GetHashValue(hPtr); |
| 6257 |
windows[1] = NULL; |
| 6258 |
goto done; |
| 6259 |
} |
| 6260 |
|
| 6261 |
vRoot = parentPtr->wmInfoPtr->vRoot; |
| 6262 |
if (vRoot == None) { |
| 6263 |
vRoot = RootWindowOfScreen(Tk_Screen((Tk_Window) parentPtr)); |
| 6264 |
} |
| 6265 |
|
| 6266 |
if (XQueryTree(parentPtr->display, vRoot, &dummy1, &dummy2, |
| 6267 |
&children, &numChildren) == 0) { |
| 6268 |
ckfree((char *) windows); |
| 6269 |
windows = NULL; |
| 6270 |
} else { |
| 6271 |
for (i = 0; i < numChildren; i++) { |
| 6272 |
hPtr = Tcl_FindHashEntry(&table, (char *) children[i]); |
| 6273 |
if (hPtr != NULL) { |
| 6274 |
childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr); |
| 6275 |
*window_ptr++ = childWinPtr; |
| 6276 |
} |
| 6277 |
} |
| 6278 |
if ((window_ptr - windows) != table.numEntries) { |
| 6279 |
Tcl_Panic("num matched toplevel windows does not equal num children"); |
| 6280 |
} |
| 6281 |
*window_ptr = NULL; |
| 6282 |
if (numChildren) { |
| 6283 |
XFree((char *) children); |
| 6284 |
} |
| 6285 |
} |
| 6286 |
|
| 6287 |
done: |
| 6288 |
Tcl_DeleteHashTable(&table); |
| 6289 |
return windows; |
| 6290 |
} |
| 6291 |
|
| 6292 |
|
| 6293 |
|
| 6294 |
|
| 6295 |
|
| 6296 |
|
| 6297 |
|
| 6298 |
|
| 6299 |
|
| 6300 |
|
| 6301 |
|
| 6302 |
|
| 6303 |
|
| 6304 |
|
| 6305 |
|
| 6306 |
|
| 6307 |
|
| 6308 |
void |
| 6309 |
TkWmRestackToplevel( |
| 6310 |
TkWindow *winPtr, |
| 6311 |
int aboveBelow, |
| 6312 |
|
| 6313 |
TkWindow *otherPtr) |
| 6314 |
|
| 6315 |
|
| 6316 |
{ |
| 6317 |
XWindowChanges changes; |
| 6318 |
unsigned int mask; |
| 6319 |
TkWindow *wrapperPtr; |
| 6320 |
|
| 6321 |
memset(&changes, 0, sizeof(XWindowChanges)); |
| 6322 |
changes.stack_mode = aboveBelow; |
| 6323 |
mask = CWStackMode; |
| 6324 |
|
| 6325 |
|
| 6326 |
|
| 6327 |
|
| 6328 |
|
| 6329 |
if (winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { |
| 6330 |
TkWmMapWindow(winPtr); |
| 6331 |
} |
| 6332 |
wrapperPtr = winPtr->wmInfoPtr->wrapperPtr; |
| 6333 |
|
| 6334 |
if (otherPtr != NULL) { |
| 6335 |
|
| 6336 |
|
| 6337 |
|
| 6338 |
|
| 6339 |
|
| 6340 |
if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { |
| 6341 |
TkWmMapWindow(otherPtr); |
| 6342 |
} |
| 6343 |
changes.sibling = otherPtr->wmInfoPtr->wrapperPtr->window; |
| 6344 |
mask |= CWSibling; |
| 6345 |
} |
| 6346 |
|
| 6347 |
|
| 6348 |
|
| 6349 |
|
| 6350 |
|
| 6351 |
|
| 6352 |
|
| 6353 |
|
| 6354 |
XReconfigureWMWindow(winPtr->display, wrapperPtr->window, |
| 6355 |
Tk_ScreenNumber((Tk_Window) winPtr), mask, &changes); |
| 6356 |
} |
| 6357 |
|
| 6358 |
|
| 6359 |
|
| 6360 |
|
| 6361 |
|
| 6362 |
|
| 6363 |
|
| 6364 |
|
| 6365 |
|
| 6366 |
|
| 6367 |
|
| 6368 |
|
| 6369 |
|
| 6370 |
|
| 6371 |
|
| 6372 |
|
| 6373 |
|
| 6374 |
|
| 6375 |
|
| 6376 |
|
| 6377 |
|
| 6378 |
|
| 6379 |
|
| 6380 |
|
| 6381 |
void |
| 6382 |
TkWmAddToColormapWindows( |
| 6383 |
TkWindow *winPtr) |
| 6384 |
|
| 6385 |
{ |
| 6386 |
TkWindow *wrapperPtr; |
| 6387 |
TkWindow *topPtr; |
| 6388 |
Window *oldPtr, *newPtr; |
| 6389 |
int count, i; |
| 6390 |
|
| 6391 |
if (winPtr->window == None) { |
| 6392 |
return; |
| 6393 |
} |
| 6394 |
|
| 6395 |
for (topPtr = winPtr->parentPtr; ; topPtr = topPtr->parentPtr) { |
| 6396 |
if (topPtr == NULL) { |
| 6397 |
|
| 6398 |
|
| 6399 |
|
| 6400 |
|
| 6401 |
return; |
| 6402 |
} |
| 6403 |
if (topPtr->flags & TK_TOP_HIERARCHY) { |
| 6404 |
break; |
| 6405 |
} |
| 6406 |
} |
| 6407 |
if (topPtr->wmInfoPtr == NULL) { |
| 6408 |
return; |
| 6409 |
} |
| 6410 |
|
| 6411 |
if (topPtr->wmInfoPtr->flags & WM_COLORMAPS_EXPLICIT) { |
| 6412 |
return; |
| 6413 |
} |
| 6414 |
if (topPtr->wmInfoPtr->wrapperPtr == NULL) { |
| 6415 |
CreateWrapper(topPtr->wmInfoPtr); |
| 6416 |
} |
| 6417 |
wrapperPtr = topPtr->wmInfoPtr->wrapperPtr; |
| 6418 |
|
| 6419 |
|
| 6420 |
|
| 6421 |
|
| 6422 |
|
| 6423 |
if (XGetWMColormapWindows(topPtr->display, wrapperPtr->window, |
| 6424 |
&oldPtr, &count) == 0) { |
| 6425 |
oldPtr = NULL; |
| 6426 |
count = 0; |
| 6427 |
} |
| 6428 |
|
| 6429 |
|
| 6430 |
|
| 6431 |
|
| 6432 |
|
| 6433 |
for (i = 0; i < count; i++) { |
| 6434 |
if (oldPtr[i] == winPtr->window) { |
| 6435 |
return; |
| 6436 |
} |
| 6437 |
} |
| 6438 |
|
| 6439 |
|
| 6440 |
|
| 6441 |
|
| 6442 |
|
| 6443 |
|
| 6444 |
newPtr = (Window *) ckalloc((unsigned) ((count+2)*sizeof(Window))); |
| 6445 |
for (i = 0; i < count; i++) { |
| 6446 |
newPtr[i] = oldPtr[i]; |
| 6447 |
} |
| 6448 |
if (count == 0) { |
| 6449 |
count++; |
| 6450 |
} |
| 6451 |
newPtr[count-1] = winPtr->window; |
| 6452 |
newPtr[count] = topPtr->window; |
| 6453 |
XSetWMColormapWindows(topPtr->display, wrapperPtr->window, newPtr, |
| 6454 |
count+1); |
| 6455 |
ckfree((char *) newPtr); |
| 6456 |
if (oldPtr != NULL) { |
| 6457 |
XFree((char *) oldPtr); |
| 6458 |
} |
| 6459 |
} |
| 6460 |
|
| 6461 |
|
| 6462 |
|
| 6463 |
|
| 6464 |
|
| 6465 |
|
| 6466 |
|
| 6467 |
|
| 6468 |
|
| 6469 |
|
| 6470 |
|
| 6471 |
|
| 6472 |
|
| 6473 |
|
| 6474 |
|
| 6475 |
|
| 6476 |
|
| 6477 |
|
| 6478 |
|
| 6479 |
|
| 6480 |
|
| 6481 |
void |
| 6482 |
TkWmRemoveFromColormapWindows( |
| 6483 |
TkWindow *winPtr) |
| 6484 |
|
| 6485 |
|
| 6486 |
|
| 6487 |
{ |
| 6488 |
TkWindow *wrapperPtr; |
| 6489 |
TkWindow *topPtr; |
| 6490 |
Window *oldPtr; |
| 6491 |
int count, i, j; |
| 6492 |
|
| 6493 |
if (winPtr->window == None) { |
| 6494 |
return; |
| 6495 |
} |
| 6496 |
|
| 6497 |
for (topPtr = winPtr->parentPtr; ; topPtr = topPtr->parentPtr) { |
| 6498 |
if (topPtr == NULL) { |
| 6499 |
|
| 6500 |
|
| 6501 |
|
| 6502 |
|
| 6503 |
|
| 6504 |
return; |
| 6505 |
} |
| 6506 |
if (topPtr->flags & TK_TOP_HIERARCHY) { |
| 6507 |
break; |
| 6508 |
} |
| 6509 |
} |
| 6510 |
if (topPtr->flags & TK_ALREADY_DEAD) { |
| 6511 |
|
| 6512 |
|
| 6513 |
|
| 6514 |
|
| 6515 |
|
| 6516 |
return; |
| 6517 |
} |
| 6518 |
if (topPtr->wmInfoPtr == NULL) { |
| 6519 |
return; |
| 6520 |
} |
| 6521 |
|
| 6522 |
if (topPtr->wmInfoPtr->wrapperPtr == NULL) { |
| 6523 |
CreateWrapper(topPtr->wmInfoPtr); |
| 6524 |
} |
| 6525 |
wrapperPtr = topPtr->wmInfoPtr->wrapperPtr; |
| 6526 |
if (wrapperPtr == NULL) { |
| 6527 |
return; |
| 6528 |
} |
| 6529 |
|
| 6530 |
|
| 6531 |
|
| 6532 |
|
| 6533 |
|
| 6534 |
if (XGetWMColormapWindows(topPtr->display, wrapperPtr->window, |
| 6535 |
&oldPtr, &count) == 0) { |
| 6536 |
return; |
| 6537 |
} |
| 6538 |
|
| 6539 |
|
| 6540 |
|
| 6541 |
|
| 6542 |
|
| 6543 |
for (i = 0; i < count; i++) { |
| 6544 |
if (oldPtr[i] == winPtr->window) { |
| 6545 |
for (j = i ; j < count-1; j++) { |
| 6546 |
oldPtr[j] = oldPtr[j+1]; |
| 6547 |
} |
| 6548 |
XSetWMColormapWindows(topPtr->display, wrapperPtr->window, |
| 6549 |
oldPtr, count-1); |
| 6550 |
break; |
| 6551 |
} |
| 6552 |
} |
| 6553 |
XFree((char *) oldPtr); |
| 6554 |
} |
| 6555 |
|
| 6556 |
|
| 6557 |
|
| 6558 |
|
| 6559 |
|
| 6560 |
|
| 6561 |
|
| 6562 |
|
| 6563 |
|
| 6564 |
|
| 6565 |
|
| 6566 |
|
| 6567 |
|
| 6568 |
|
| 6569 |
|
| 6570 |
|
| 6571 |
|
| 6572 |
|
| 6573 |
|
| 6574 |
|
| 6575 |
void |
| 6576 |
TkGetPointerCoords( |
| 6577 |
Tk_Window tkwin, |
| 6578 |
|
| 6579 |
int *xPtr, int *yPtr) |
| 6580 |
{ |
| 6581 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 6582 |
WmInfo *wmPtr; |
| 6583 |
Window w, root, child; |
| 6584 |
int rootX, rootY; |
| 6585 |
unsigned int mask; |
| 6586 |
|
| 6587 |
wmPtr = winPtr->wmInfoPtr; |
| 6588 |
|
| 6589 |
w = wmPtr->vRoot; |
| 6590 |
if (w == None) { |
| 6591 |
w = RootWindow(winPtr->display, winPtr->screenNum); |
| 6592 |
} |
| 6593 |
if (XQueryPointer(winPtr->display, w, &root, &child, &rootX, &rootY, |
| 6594 |
xPtr, yPtr, &mask) != True) { |
| 6595 |
*xPtr = -1; |
| 6596 |
*yPtr = -1; |
| 6597 |
} |
| 6598 |
} |
| 6599 |
|
| 6600 |
|
| 6601 |
|
| 6602 |
|
| 6603 |
|
| 6604 |
|
| 6605 |
|
| 6606 |
|
| 6607 |
|
| 6608 |
|
| 6609 |
|
| 6610 |
|
| 6611 |
|
| 6612 |
|
| 6613 |
|
| 6614 |
|
| 6615 |
|
| 6616 |
|
| 6617 |
|
| 6618 |
|
| 6619 |
|
| 6620 |
|
| 6621 |
static void |
| 6622 |
GetMaxSize( |
| 6623 |
WmInfo *wmPtr, |
| 6624 |
|
| 6625 |
int *maxWidthPtr, |
| 6626 |
|
| 6627 |
int *maxHeightPtr) |
| 6628 |
|
| 6629 |
{ |
| 6630 |
int tmp; |
| 6631 |
|
| 6632 |
if (wmPtr->maxWidth > 0) { |
| 6633 |
*maxWidthPtr = wmPtr->maxWidth; |
| 6634 |
} else { |
| 6635 |
|
| 6636 |
|
| 6637 |
|
| 6638 |
|
| 6639 |
|
| 6640 |
tmp = DisplayWidth(wmPtr->winPtr->display, wmPtr->winPtr->screenNum) |
| 6641 |
- 15; |
| 6642 |
if (wmPtr->gridWin != NULL) { |
| 6643 |
|
| 6644 |
|
| 6645 |
|
| 6646 |
|
| 6647 |
tmp = wmPtr->reqGridWidth |
| 6648 |
+ (tmp - wmPtr->winPtr->reqWidth)/wmPtr->widthInc; |
| 6649 |
} |
| 6650 |
*maxWidthPtr = tmp; |
| 6651 |
} |
| 6652 |
if (wmPtr->maxHeight > 0) { |
| 6653 |
*maxHeightPtr = wmPtr->maxHeight; |
| 6654 |
} else { |
| 6655 |
tmp = DisplayHeight(wmPtr->winPtr->display, wmPtr->winPtr->screenNum) |
| 6656 |
- 30; |
| 6657 |
if (wmPtr->gridWin != NULL) { |
| 6658 |
tmp = wmPtr->reqGridHeight |
| 6659 |
+ (tmp - wmPtr->winPtr->reqHeight)/wmPtr->heightInc; |
| 6660 |
} |
| 6661 |
*maxHeightPtr = tmp; |
| 6662 |
} |
| 6663 |
} |
| 6664 |
|
| 6665 |
|
| 6666 |
|
| 6667 |
|
| 6668 |
|
| 6669 |
|
| 6670 |
|
| 6671 |
|
| 6672 |
|
| 6673 |
|
| 6674 |
|
| 6675 |
|
| 6676 |
|
| 6677 |
|
| 6678 |
|
| 6679 |
|
| 6680 |
|
| 6681 |
|
| 6682 |
void |
| 6683 |
TkpMakeMenuWindow( |
| 6684 |
Tk_Window tkwin, |
| 6685 |
int transient) |
| 6686 |
|
| 6687 |
|
| 6688 |
|
| 6689 |
|
| 6690 |
{ |
| 6691 |
WmInfo *wmPtr; |
| 6692 |
XSetWindowAttributes atts; |
| 6693 |
TkWindow *wrapperPtr; |
| 6694 |
|
| 6695 |
if (!Tk_HasWrapper(tkwin)) { |
| 6696 |
return; |
| 6697 |
} |
| 6698 |
wmPtr = ((TkWindow *) tkwin)->wmInfoPtr; |
| 6699 |
if (wmPtr->wrapperPtr == NULL) { |
| 6700 |
CreateWrapper(wmPtr); |
| 6701 |
} |
| 6702 |
wrapperPtr = wmPtr->wrapperPtr; |
| 6703 |
if (transient) { |
| 6704 |
atts.override_redirect = True; |
| 6705 |
atts.save_under = True; |
| 6706 |
} else { |
| 6707 |
atts.override_redirect = False; |
| 6708 |
atts.save_under = False; |
| 6709 |
} |
| 6710 |
|
| 6711 |
|
| 6712 |
|
| 6713 |
|
| 6714 |
|
| 6715 |
|
| 6716 |
|
| 6717 |
|
| 6718 |
if ((atts.override_redirect!=Tk_Attributes(wrapperPtr)->override_redirect) |
| 6719 |
|| (atts.save_under != Tk_Attributes(wrapperPtr)->save_under)) { |
| 6720 |
Tk_ChangeWindowAttributes((Tk_Window) wrapperPtr, |
| 6721 |
CWOverrideRedirect|CWSaveUnder, &atts); |
| 6722 |
} |
| 6723 |
if ((atts.override_redirect != Tk_Attributes(tkwin)->override_redirect) |
| 6724 |
|| (atts.save_under != Tk_Attributes(tkwin)->save_under)) { |
| 6725 |
Tk_ChangeWindowAttributes(tkwin, |
| 6726 |
CWOverrideRedirect|CWSaveUnder, &atts); |
| 6727 |
} |
| 6728 |
} |
| 6729 |
|
| 6730 |
|
| 6731 |
|
| 6732 |
|
| 6733 |
|
| 6734 |
|
| 6735 |
|
| 6736 |
|
| 6737 |
|
| 6738 |
|
| 6739 |
|
| 6740 |
|
| 6741 |
|
| 6742 |
|
| 6743 |
|
| 6744 |
|
| 6745 |
|
| 6746 |
|
| 6747 |
|
| 6748 |
static void |
| 6749 |
CreateWrapper( |
| 6750 |
WmInfo *wmPtr) |
| 6751 |
|
| 6752 |
{ |
| 6753 |
TkWindow *winPtr, *wrapperPtr; |
| 6754 |
Window parent; |
| 6755 |
Tcl_HashEntry *hPtr; |
| 6756 |
int new; |
| 6757 |
|
| 6758 |
winPtr = wmPtr->winPtr; |
| 6759 |
if (winPtr->window == None) { |
| 6760 |
Tk_MakeWindowExist((Tk_Window) winPtr); |
| 6761 |
} |
| 6762 |
|
| 6763 |
|
| 6764 |
|
| 6765 |
|
| 6766 |
|
| 6767 |
|
| 6768 |
|
| 6769 |
|
| 6770 |
|
| 6771 |
|
| 6772 |
wmPtr->wrapperPtr = wrapperPtr = TkAllocWindow(winPtr->dispPtr, |
| 6773 |
Tk_ScreenNumber((Tk_Window) winPtr), winPtr); |
| 6774 |
wrapperPtr->dirtyAtts |= CWBorderPixel; |
| 6775 |
|
| 6776 |
|
| 6777 |
|
| 6778 |
|
| 6779 |
|
| 6780 |
|
| 6781 |
|
| 6782 |
|
| 6783 |
|
| 6784 |
wrapperPtr->flags |= TK_WRAPPER; |
| 6785 |
wrapperPtr->atts.event_mask |= StructureNotifyMask|FocusChangeMask; |
| 6786 |
wrapperPtr->atts.override_redirect = winPtr->atts.override_redirect; |
| 6787 |
if (winPtr->flags & TK_EMBEDDED) { |
| 6788 |
parent = TkUnixContainerId(winPtr); |
| 6789 |
} else { |
| 6790 |
parent = XRootWindow(wrapperPtr->display, wrapperPtr->screenNum); |
| 6791 |
} |
| 6792 |
wrapperPtr->window = XCreateWindow(wrapperPtr->display, |
| 6793 |
parent, wrapperPtr->changes.x, wrapperPtr->changes.y, |
| 6794 |
(unsigned) wrapperPtr->changes.width, |
| 6795 |
(unsigned) wrapperPtr->changes.height, |
| 6796 |
(unsigned) wrapperPtr->changes.border_width, wrapperPtr->depth, |
| 6797 |
InputOutput, wrapperPtr->visual, |
| 6798 |
wrapperPtr->dirtyAtts|CWOverrideRedirect, &wrapperPtr->atts); |
| 6799 |
hPtr = Tcl_CreateHashEntry(&wrapperPtr->dispPtr->winTable, |
| 6800 |
(char *) wrapperPtr->window, &new); |
| 6801 |
Tcl_SetHashValue(hPtr, wrapperPtr); |
| 6802 |
wrapperPtr->mainPtr = winPtr->mainPtr; |
| 6803 |
wrapperPtr->mainPtr->refCount++; |
| 6804 |
wrapperPtr->dirtyAtts = 0; |
| 6805 |
wrapperPtr->dirtyChanges = 0; |
| 6806 |
wrapperPtr->wmInfoPtr = wmPtr; |
| 6807 |
|
| 6808 |
|
| 6809 |
|
| 6810 |
|
| 6811 |
|
| 6812 |
XReparentWindow(wrapperPtr->display, winPtr->window, wrapperPtr->window, |
| 6813 |
0, 0); |
| 6814 |
|
| 6815 |
|
| 6816 |
|
| 6817 |
|
| 6818 |
|
| 6819 |
|
| 6820 |
|
| 6821 |
Tk_CreateEventHandler((Tk_Window) wmPtr->wrapperPtr, |
| 6822 |
WrapperEventMask, WrapperEventProc, (ClientData) wmPtr); |
| 6823 |
} |
| 6824 |
|
| 6825 |
|
| 6826 |
|
| 6827 |
|
| 6828 |
|
| 6829 |
|
| 6830 |
|
| 6831 |
|
| 6832 |
|
| 6833 |
|
| 6834 |
|
| 6835 |
|
| 6836 |
|
| 6837 |
|
| 6838 |
|
| 6839 |
|
| 6840 |
|
| 6841 |
|
| 6842 |
|
| 6843 |
|
| 6844 |
|
| 6845 |
|
| 6846 |
TkWindow * |
| 6847 |
TkWmFocusToplevel( |
| 6848 |
TkWindow *winPtr) |
| 6849 |
|
| 6850 |
{ |
| 6851 |
if (!(winPtr->flags & TK_WRAPPER)) { |
| 6852 |
return NULL; |
| 6853 |
} |
| 6854 |
return winPtr->wmInfoPtr->winPtr; |
| 6855 |
} |
| 6856 |
|
| 6857 |
|
| 6858 |
|
| 6859 |
|
| 6860 |
|
| 6861 |
|
| 6862 |
|
| 6863 |
|
| 6864 |
|
| 6865 |
|
| 6866 |
|
| 6867 |
|
| 6868 |
|
| 6869 |
|
| 6870 |
|
| 6871 |
|
| 6872 |
|
| 6873 |
|
| 6874 |
|
| 6875 |
|
| 6876 |
|
| 6877 |
|
| 6878 |
void |
| 6879 |
TkUnixSetMenubar( |
| 6880 |
Tk_Window tkwin, |
| 6881 |
Tk_Window menubar) |
| 6882 |
|
| 6883 |
|
| 6884 |
|
| 6885 |
|
| 6886 |
{ |
| 6887 |
WmInfo *wmPtr = ((TkWindow *) tkwin)->wmInfoPtr; |
| 6888 |
Tk_Window parent; |
| 6889 |
TkWindow *menubarPtr = (TkWindow *) menubar; |
| 6890 |
|
| 6891 |
if (wmPtr == NULL) { |
| 6892 |
return; |
| 6893 |
} |
| 6894 |
|
| 6895 |
if (wmPtr->menubar != NULL) { |
| 6896 |
|
| 6897 |
|
| 6898 |
|
| 6899 |
|
| 6900 |
|
| 6901 |
|
| 6902 |
if (wmPtr->menubar == menubar) { |
| 6903 |
return; |
| 6904 |
} |
| 6905 |
((TkWindow *) wmPtr->menubar)->wmInfoPtr = NULL; |
| 6906 |
((TkWindow *) wmPtr->menubar)->flags &= ~TK_REPARENTED; |
| 6907 |
Tk_UnmapWindow(wmPtr->menubar); |
| 6908 |
parent = Tk_Parent(wmPtr->menubar); |
| 6909 |
if (parent != NULL) { |
| 6910 |
Tk_MakeWindowExist(parent); |
| 6911 |
XReparentWindow(Tk_Display(wmPtr->menubar), |
| 6912 |
Tk_WindowId(wmPtr->menubar), Tk_WindowId(parent), 0, 0); |
| 6913 |
} |
| 6914 |
Tk_DeleteEventHandler(wmPtr->menubar, StructureNotifyMask, |
| 6915 |
MenubarDestroyProc, (ClientData) wmPtr->menubar); |
| 6916 |
Tk_ManageGeometry(wmPtr->menubar, NULL, NULL); |
| 6917 |
} |
| 6918 |
|
| 6919 |
wmPtr->menubar = menubar; |
| 6920 |
if (menubar == NULL) { |
| 6921 |
wmPtr->menuHeight = 0; |
| 6922 |
} else { |
| 6923 |
if ((menubarPtr->flags & TK_TOP_LEVEL) |
| 6924 |
|| (Tk_Screen(menubar) != Tk_Screen(tkwin))) { |
| 6925 |
Tcl_Panic("TkUnixSetMenubar got bad menubar"); |
| 6926 |
} |
| 6927 |
wmPtr->menuHeight = Tk_ReqHeight(menubar); |
| 6928 |
if (wmPtr->menuHeight == 0) { |
| 6929 |
wmPtr->menuHeight = 1; |
| 6930 |
} |
| 6931 |
Tk_MakeWindowExist(tkwin); |
| 6932 |
Tk_MakeWindowExist(menubar); |
| 6933 |
if (wmPtr->wrapperPtr == NULL) { |
| 6934 |
CreateWrapper(wmPtr); |
| 6935 |
} |
| 6936 |
XReparentWindow(Tk_Display(menubar), Tk_WindowId(menubar), |
| 6937 |
wmPtr->wrapperPtr->window, 0, 0); |
| 6938 |
menubarPtr->wmInfoPtr = wmPtr; |
| 6939 |
Tk_MoveResizeWindow(menubar, 0, 0, Tk_Width(tkwin), wmPtr->menuHeight); |
| 6940 |
Tk_MapWindow(menubar); |
| 6941 |
Tk_CreateEventHandler(menubar, StructureNotifyMask, MenubarDestroyProc, |
| 6942 |
(ClientData) menubar); |
| 6943 |
Tk_ManageGeometry(menubar, &menubarMgrType, (ClientData) wmPtr); |
| 6944 |
menubarPtr->flags |= TK_REPARENTED; |
| 6945 |
} |
| 6946 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 6947 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 6948 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) tkwin); |
| 6949 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 6950 |
} |
| 6951 |
} |
| 6952 |
|
| 6953 |
|
| 6954 |
|
| 6955 |
|
| 6956 |
|
| 6957 |
|
| 6958 |
|
| 6959 |
|
| 6960 |
|
| 6961 |
|
| 6962 |
|
| 6963 |
|
| 6964 |
|
| 6965 |
|
| 6966 |
|
| 6967 |
|
| 6968 |
|
| 6969 |
|
| 6970 |
|
| 6971 |
|
| 6972 |
static void |
| 6973 |
MenubarDestroyProc( |
| 6974 |
ClientData clientData, |
| 6975 |
XEvent *eventPtr) |
| 6976 |
{ |
| 6977 |
WmInfo *wmPtr; |
| 6978 |
|
| 6979 |
if (eventPtr->type != DestroyNotify) { |
| 6980 |
return; |
| 6981 |
} |
| 6982 |
wmPtr = ((TkWindow *) clientData)->wmInfoPtr; |
| 6983 |
wmPtr->menubar = NULL; |
| 6984 |
wmPtr->menuHeight = 0; |
| 6985 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 6986 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 6987 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) wmPtr->winPtr); |
| 6988 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 6989 |
} |
| 6990 |
} |
| 6991 |
|
| 6992 |
|
| 6993 |
|
| 6994 |
|
| 6995 |
|
| 6996 |
|
| 6997 |
|
| 6998 |
|
| 6999 |
|
| 7000 |
|
| 7001 |
|
| 7002 |
|
| 7003 |
|
| 7004 |
|
| 7005 |
|
| 7006 |
|
| 7007 |
|
| 7008 |
|
| 7009 |
static void |
| 7010 |
MenubarReqProc( |
| 7011 |
ClientData clientData, |
| 7012 |
|
| 7013 |
Tk_Window tkwin) |
| 7014 |
{ |
| 7015 |
WmInfo *wmPtr = (WmInfo *) clientData; |
| 7016 |
|
| 7017 |
wmPtr->menuHeight = Tk_ReqHeight(tkwin); |
| 7018 |
if (wmPtr->menuHeight <= 0) { |
| 7019 |
wmPtr->menuHeight = 1; |
| 7020 |
} |
| 7021 |
wmPtr->flags |= WM_UPDATE_SIZE_HINTS; |
| 7022 |
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { |
| 7023 |
Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) wmPtr->winPtr); |
| 7024 |
wmPtr->flags |= WM_UPDATE_PENDING; |
| 7025 |
} |
| 7026 |
} |
| 7027 |
|
| 7028 |
|
| 7029 |
|
| 7030 |
|
| 7031 |
|
| 7032 |
|
| 7033 |
|
| 7034 |
|
| 7035 |
|
| 7036 |
|
| 7037 |
|
| 7038 |
|
| 7039 |
|
| 7040 |
|
| 7041 |
|
| 7042 |
|
| 7043 |
|
| 7044 |
|
| 7045 |
|
| 7046 |
TkWindow * |
| 7047 |
TkpGetWrapperWindow( |
| 7048 |
TkWindow *winPtr) |
| 7049 |
{ |
| 7050 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7051 |
|
| 7052 |
if ((winPtr == NULL) || (wmPtr == NULL)) { |
| 7053 |
return NULL; |
| 7054 |
} |
| 7055 |
|
| 7056 |
return wmPtr->wrapperPtr; |
| 7057 |
} |
| 7058 |
|
| 7059 |
|
| 7060 |
|
| 7061 |
|
| 7062 |
|
| 7063 |
|
| 7064 |
|
| 7065 |
|
| 7066 |
|
| 7067 |
|
| 7068 |
|
| 7069 |
|
| 7070 |
|
| 7071 |
|
| 7072 |
|
| 7073 |
|
| 7074 |
|
| 7075 |
|
| 7076 |
static void UnmanageGeometry(tkwin) |
| 7077 |
Tk_Window tkwin; |
| 7078 |
|
| 7079 |
{ |
| 7080 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 7081 |
|
| 7082 |
if ((winPtr->geomMgrPtr != NULL) && |
| 7083 |
(winPtr->geomMgrPtr->lostSlaveProc != NULL)) { |
| 7084 |
(*winPtr->geomMgrPtr->lostSlaveProc)(winPtr->geomData, tkwin); |
| 7085 |
} |
| 7086 |
|
| 7087 |
winPtr->geomMgrPtr = NULL; |
| 7088 |
winPtr->geomData = NULL; |
| 7089 |
} |
| 7090 |
|
| 7091 |
|
| 7092 |
|
| 7093 |
|
| 7094 |
|
| 7095 |
|
| 7096 |
|
| 7097 |
|
| 7098 |
|
| 7099 |
|
| 7100 |
|
| 7101 |
|
| 7102 |
|
| 7103 |
|
| 7104 |
|
| 7105 |
|
| 7106 |
|
| 7107 |
|
| 7108 |
|
| 7109 |
static void |
| 7110 |
TopLevelEventProc(clientData, eventPtr) |
| 7111 |
ClientData clientData; |
| 7112 |
XEvent *eventPtr; |
| 7113 |
{ |
| 7114 |
register TkWindow *winPtr = (TkWindow *) clientData; |
| 7115 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7116 |
|
| 7117 |
wmPtr->flags |= WM_VROOT_OFFSET_STALE; |
| 7118 |
if (eventPtr->type == DestroyNotify) { |
| 7119 |
Tk_ErrorHandler handler; |
| 7120 |
|
| 7121 |
if (!(winPtr->flags & TK_ALREADY_DEAD)) { |
| 7122 |
|
| 7123 |
|
| 7124 |
|
| 7125 |
|
| 7126 |
|
| 7127 |
|
| 7128 |
|
| 7129 |
|
| 7130 |
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, |
| 7131 |
(Tk_ErrorProc *) NULL, (ClientData) NULL); |
| 7132 |
Tk_DestroyWindow((Tk_Window) winPtr); |
| 7133 |
Tk_DeleteErrorHandler(handler); |
| 7134 |
} |
| 7135 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 7136 |
printf("TopLevelEventProc: %s deleted\n", winPtr->pathName); |
| 7137 |
} |
| 7138 |
} else if (eventPtr->type == ConfigureNotify) { |
| 7139 |
|
| 7140 |
|
| 7141 |
|
| 7142 |
|
| 7143 |
|
| 7144 |
|
| 7145 |
|
| 7146 |
|
| 7147 |
|
| 7148 |
|
| 7149 |
if (!(winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED)) { |
| 7150 |
ConfigureEvent(wmPtr, &eventPtr->xconfigure); |
| 7151 |
} |
| 7152 |
} else if (eventPtr->type == MapNotify) { |
| 7153 |
winPtr->flags |= TK_MAPPED; |
| 7154 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 7155 |
printf("TopLevelEventProc: %s mapped\n", winPtr->pathName); |
| 7156 |
} |
| 7157 |
} else if (eventPtr->type == UnmapNotify) { |
| 7158 |
winPtr->flags &= ~TK_MAPPED; |
| 7159 |
if (winPtr->dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 7160 |
printf("TopLevelEventProc: %s unmapped\n", winPtr->pathName); |
| 7161 |
} |
| 7162 |
} else if (eventPtr->type == ReparentNotify) { |
| 7163 |
ReparentEvent(wmPtr, &eventPtr->xreparent); |
| 7164 |
} |
| 7165 |
} |
| 7166 |
|
| 7167 |
void |
| 7168 |
ImageChangedProc(clientData, x, y, width, height, imageWidth, imageHeight) |
| 7169 |
ClientData clientData; |
| 7170 |
int x; |
| 7171 |
int y; |
| 7172 |
int width; |
| 7173 |
int height; |
| 7174 |
int imageWidth; |
| 7175 |
int imageHeight; |
| 7176 |
{ |
| 7177 |
register TkWindow *winPtr = (TkWindow *) clientData; |
| 7178 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7179 |
Pixmap old = wmPtr->hints.icon_pixmap; |
| 7180 |
Pixmap pixmap = None; |
| 7181 |
if (imageWidth && imageHeight) { |
| 7182 |
pixmap = Tk_GetPixmap(winPtr->display, |
| 7183 |
RootWindowOfScreen(Tk_Screen((Tk_Window)winPtr)), |
| 7184 |
imageWidth, imageHeight, |
| 7185 |
DefaultDepthOfScreen(Tk_Screen((Tk_Window)winPtr))); |
| 7186 |
} |
| 7187 |
if (pixmap != None) { |
| 7188 |
Tk_RedrawImage(wmPtr->iconImage, 0, 0, imageWidth, imageHeight, pixmap, 0, 0); |
| 7189 |
wmPtr->hints.flags |= IconPixmapHint; |
| 7190 |
} else { |
| 7191 |
wmPtr->hints.flags &= ~IconPixmapHint; |
| 7192 |
} |
| 7193 |
wmPtr->hints.icon_pixmap = pixmap; |
| 7194 |
UpdateHints(winPtr); |
| 7195 |
if (old != None) { |
| 7196 |
Tk_FreePixmap(winPtr->display, old); |
| 7197 |
} |
| 7198 |
} |
| 7199 |
|
| 7200 |
|
| 7201 |
|
| 7202 |
|
| 7203 |
|
| 7204 |
|
| 7205 |
|
| 7206 |
|
| 7207 |
|
| 7208 |
|
| 7209 |
|
| 7210 |
|
| 7211 |
|
| 7212 |
|
| 7213 |
|
| 7214 |
|
| 7215 |
|
| 7216 |
|
| 7217 |
static void |
| 7218 |
UpdateCommand( |
| 7219 |
TkWindow *winPtr) |
| 7220 |
{ |
| 7221 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7222 |
Tcl_DString cmds, ds; |
| 7223 |
int i, *offsets; |
| 7224 |
char **cmdArgv; |
| 7225 |
int cmdArgc; |
| 7226 |
|
| 7227 |
|
| 7228 |
|
| 7229 |
|
| 7230 |
|
| 7231 |
|
| 7232 |
|
| 7233 |
|
| 7234 |
|
| 7235 |
|
| 7236 |
|
| 7237 |
|
| 7238 |
#ifdef _LANG |
| 7239 |
Tcl_Obj **cmdObjv; |
| 7240 |
if (Tcl_ListObjGetElements(NULL, wmPtr->cmdArg, &cmdArgc, &cmdObjv) != TCL_OK) { |
| 7241 |
return; |
| 7242 |
} |
| 7243 |
#else |
| 7244 |
cmdArgc = wmPtr->cmdArgc; |
| 7245 |
#endif |
| 7246 |
cmdArgv = (char **) ckalloc(sizeof(char *) * cmdArgc); |
| 7247 |
offsets = (int *) ckalloc( sizeof(int) * cmdArgc); |
| 7248 |
Tcl_DStringInit(&cmds); |
| 7249 |
for (i = 0; i < cmdArgc; i++) { |
| 7250 |
Tcl_UtfToExternalDString(NULL, |
| 7251 |
#ifdef _LANG |
| 7252 |
Tcl_GetString(cmdObjv[i]), |
| 7253 |
#else |
| 7254 |
wmPtr->cmdArgv[i], |
| 7255 |
#endif |
| 7256 |
-1, &ds); |
| 7257 |
offsets[i] = Tcl_DStringLength(&cmds); |
| 7258 |
Tcl_DStringAppend(&cmds, Tcl_DStringValue(&ds), |
| 7259 |
Tcl_DStringLength(&ds)+1); |
| 7260 |
Tcl_DStringFree(&ds); |
| 7261 |
} |
| 7262 |
cmdArgv[0] = Tcl_DStringValue(&cmds); |
| 7263 |
for (i = 1; i < cmdArgc; i++) { |
| 7264 |
cmdArgv[i] = cmdArgv[0] + offsets[i]; |
| 7265 |
} |
| 7266 |
|
| 7267 |
XSetCommand(winPtr->display, wmPtr->wrapperPtr->window, |
| 7268 |
cmdArgv, cmdArgc); |
| 7269 |
Tcl_DStringFree(&cmds); |
| 7270 |
ckfree((char *) cmdArgv); |
| 7271 |
ckfree((char *) offsets); |
| 7272 |
} |
| 7273 |
|
| 7274 |
|
| 7275 |
|
| 7276 |
|
| 7277 |
|
| 7278 |
|
| 7279 |
|
| 7280 |
|
| 7281 |
|
| 7282 |
|
| 7283 |
|
| 7284 |
|
| 7285 |
|
| 7286 |
|
| 7287 |
|
| 7288 |
|
| 7289 |
|
| 7290 |
|
| 7291 |
int |
| 7292 |
TkpWmSetState( |
| 7293 |
TkWindow *winPtr, |
| 7294 |
int state) |
| 7295 |
|
| 7296 |
{ |
| 7297 |
WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7298 |
|
| 7299 |
if (state == WithdrawnState) { |
| 7300 |
wmPtr->hints.initial_state = WithdrawnState; |
| 7301 |
wmPtr->withdrawn = 1; |
| 7302 |
if (wmPtr->flags & WM_NEVER_MAPPED) { |
| 7303 |
return 1; |
| 7304 |
} |
| 7305 |
if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window, |
| 7306 |
winPtr->screenNum) == 0) { |
| 7307 |
return 0; |
| 7308 |
} |
| 7309 |
WaitForMapNotify(winPtr, 0); |
| 7310 |
} else if (state == NormalState) { |
| 7311 |
wmPtr->hints.initial_state = NormalState; |
| 7312 |
wmPtr->withdrawn = 0; |
| 7313 |
if (wmPtr->flags & WM_NEVER_MAPPED) { |
| 7314 |
return 1; |
| 7315 |
} |
| 7316 |
UpdateHints(winPtr); |
| 7317 |
Tk_MapWindow((Tk_Window) winPtr); |
| 7318 |
} else if (state == IconicState) { |
| 7319 |
wmPtr->hints.initial_state = IconicState; |
| 7320 |
if (wmPtr->flags & WM_NEVER_MAPPED) { |
| 7321 |
return 1; |
| 7322 |
} |
| 7323 |
if (wmPtr->withdrawn) { |
| 7324 |
UpdateHints(winPtr); |
| 7325 |
Tk_MapWindow((Tk_Window) winPtr); |
| 7326 |
wmPtr->withdrawn = 0; |
| 7327 |
} else { |
| 7328 |
if (XIconifyWindow(winPtr->display, wmPtr->wrapperPtr->window, |
| 7329 |
winPtr->screenNum) == 0) { |
| 7330 |
return 0; |
| 7331 |
} |
| 7332 |
WaitForMapNotify(winPtr, 0); |
| 7333 |
} |
| 7334 |
} |
| 7335 |
|
| 7336 |
return 1; |
| 7337 |
} |
| 7338 |
|
| 7339 |
|
| 7340 |
|
| 7341 |
|
| 7342 |
|
| 7343 |
|
| 7344 |
|
| 7345 |
|
| 7346 |
|
| 7347 |
|
| 7348 |
|
| 7349 |
|
| 7350 |
|
| 7351 |
|
| 7352 |
|
| 7353 |
|
| 7354 |
|
| 7355 |
|
| 7356 |
static int |
| 7357 |
WmIconimageCmd(tkwin, winPtr, interp, objc, objv) |
| 7358 |
Tk_Window tkwin; |
| 7359 |
TkWindow *winPtr; |
| 7360 |
Tcl_Interp *interp; |
| 7361 |
int objc; |
| 7362 |
Tcl_Obj *CONST objv[]; |
| 7363 |
{ |
| 7364 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7365 |
Pixmap pixmap; |
| 7366 |
char *argv3; |
| 7367 |
|
| 7368 |
if ((objc != 3) && (objc != 4)) { |
| 7369 |
Tcl_WrongNumArgs(interp, 2, objv, "window ?image?"); |
| 7370 |
return TCL_ERROR; |
| 7371 |
} |
| 7372 |
if (objc == 3) { |
| 7373 |
if (wmPtr->hints.flags & IconPixmapHint && wmPtr->iconImage) { |
| 7374 |
Tcl_SetResult(interp, (char *) Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),TCL_STATIC); |
| 7375 |
} |
| 7376 |
return TCL_OK; |
| 7377 |
} |
| 7378 |
|
| 7379 |
if (wmPtr->hints.icon_pixmap != None) { |
| 7380 |
if (wmPtr->iconImage) { |
| 7381 |
Tk_FreePixmap(winPtr->display, wmPtr->hints.icon_pixmap); |
| 7382 |
} else { |
| 7383 |
Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); |
| 7384 |
} |
| 7385 |
wmPtr->hints.icon_pixmap = None; |
| 7386 |
} |
| 7387 |
if (wmPtr->iconImage) { |
| 7388 |
Tk_FreeImage(wmPtr->iconImage); |
| 7389 |
wmPtr->iconImage = NULL; |
| 7390 |
} |
| 7391 |
wmPtr->hints.flags &= ~IconPixmapHint; |
| 7392 |
wmPtr->iconImage = Tk_GetImage(interp, tkwin, Tcl_GetString(objv[3]), |
| 7393 |
ImageChangedProc, (ClientData) winPtr); |
| 7394 |
if (wmPtr->iconImage != NULL) { |
| 7395 |
int width = 0; |
| 7396 |
int height = 0; |
| 7397 |
Tk_SizeOfImage(wmPtr->iconImage, &width, &height); |
| 7398 |
if (!width || !height) { |
| 7399 |
LangDebug("Size of %s is %d,%d\n",Tcl_GetString(objv[3]),width,height); |
| 7400 |
} |
| 7401 |
ImageChangedProc((ClientData) winPtr, 0, 0, width, height, width, height); |
| 7402 |
return TCL_OK; |
| 7403 |
} else { |
| 7404 |
UpdateHints(winPtr); |
| 7405 |
return TCL_ERROR; |
| 7406 |
} |
| 7407 |
} |
| 7408 |
|
| 7409 |
static int |
| 7410 |
WmCaptureCmd(tkwin, winPtr, interp, objc, objv) |
| 7411 |
Tk_Window tkwin; |
| 7412 |
TkWindow *winPtr; |
| 7413 |
Tcl_Interp *interp; |
| 7414 |
int objc; |
| 7415 |
Tcl_Obj *CONST objv[]; |
| 7416 |
{ |
| 7417 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7418 |
|
| 7419 |
if (winPtr->parentPtr == NULL) { |
| 7420 |
Tcl_AppendResult(interp, "Cannot capture main window", NULL); |
| 7421 |
return TCL_ERROR; |
| 7422 |
} |
| 7423 |
|
| 7424 |
|
| 7425 |
if ((winPtr->flags & TK_TOP_LEVEL) == 0) { |
| 7426 |
|
| 7427 |
return TCL_OK; |
| 7428 |
} |
| 7429 |
|
| 7430 |
wmPtr->hints.initial_state = WithdrawnState; |
| 7431 |
wmPtr->withdrawn = 1; |
| 7432 |
if (wmPtr->flags & WM_NEVER_MAPPED) { |
| 7433 |
|
| 7434 |
|
| 7435 |
|
| 7436 |
while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) { |
| 7437 |
|
| 7438 |
} |
| 7439 |
} |
| 7440 |
else { |
| 7441 |
if (XWithdrawWindow(winPtr->display, wmPtr->wrapperPtr->window, |
| 7442 |
winPtr->screenNum) != 0) { |
| 7443 |
WaitForMapNotify(winPtr, 0); |
| 7444 |
} |
| 7445 |
} |
| 7446 |
|
| 7447 |
|
| 7448 |
TkWmDeadWindow(winPtr); |
| 7449 |
|
| 7450 |
if (winPtr->window == None) { |
| 7451 |
|
| 7452 |
winPtr->atts.event_mask &= ~StructureNotifyMask; |
| 7453 |
winPtr->flags &= ~TK_TOP_LEVEL; |
| 7454 |
|
| 7455 |
UnmanageGeometry((Tk_Window) winPtr); |
| 7456 |
Tk_DeleteEventHandler((Tk_Window) winPtr, StructureNotifyMask, |
| 7457 |
TopLevelEventProc, (ClientData) winPtr); |
| 7458 |
} |
| 7459 |
else { |
| 7460 |
XEvent event; |
| 7461 |
unsigned long serial; |
| 7462 |
XSetWindowAttributes atts; |
| 7463 |
int i, done1 = 0, done2 = 0, count = 0; |
| 7464 |
TkDisplay *dispPtr = winPtr->dispPtr; |
| 7465 |
|
| 7466 |
|
| 7467 |
|
| 7468 |
|
| 7469 |
|
| 7470 |
|
| 7471 |
static int wmDontReparent = 0; |
| 7472 |
|
| 7473 |
|
| 7474 |
|
| 7475 |
|
| 7476 |
|
| 7477 |
|
| 7478 |
|
| 7479 |
|
| 7480 |
|
| 7481 |
|
| 7482 |
|
| 7483 |
|
| 7484 |
|
| 7485 |
|
| 7486 |
|
| 7487 |
while (done2 == 0) { |
| 7488 |
XUnmapWindow(winPtr->display, winPtr->window); |
| 7489 |
Tk_MakeWindowExist((Tk_Window) winPtr->parentPtr); |
| 7490 |
XReparentWindow(winPtr->display, winPtr->window, |
| 7491 |
winPtr->parentPtr->window, 0, 0); |
| 7492 |
if (wmDontReparent >= 2) { |
| 7493 |
goto done; |
| 7494 |
} |
| 7495 |
|
| 7496 |
do { |
| 7497 |
|
| 7498 |
|
| 7499 |
|
| 7500 |
|
| 7501 |
if (WaitForEvent(winPtr->display, wmPtr, |
| 7502 |
StructureNotifyMask, &event) != TCL_OK) { |
| 7503 |
goto done; |
| 7504 |
} |
| 7505 |
Tk_HandleEvent(&event); |
| 7506 |
} while (event.type != ReparentNotify); |
| 7507 |
|
| 7508 |
if (event.xreparent.parent == winPtr->parentPtr->window) { |
| 7509 |
if (done1 == 1) { |
| 7510 |
done2 = 1; |
| 7511 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 7512 |
printf("tixdebug: done reparenting.\n"); |
| 7513 |
} |
| 7514 |
} |
| 7515 |
else { |
| 7516 |
++count; |
| 7517 |
} |
| 7518 |
} |
| 7519 |
else { |
| 7520 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 7521 |
printf("tixdebug: wm reparenting, retry ...\n"); |
| 7522 |
} |
| 7523 |
done1 = 1; |
| 7524 |
} |
| 7525 |
if (count > 15) { |
| 7526 |
++wmDontReparent; |
| 7527 |
if (dispPtr->flags & TK_DISPLAY_WM_TRACING) { |
| 7528 |
printf("tixdebug: window manager doesn't reparent.\n"); |
| 7529 |
} |
| 7530 |
goto done; |
| 7531 |
} |
| 7532 |
} |
| 7533 |
|
| 7534 |
|
| 7535 |
|
| 7536 |
done: |
| 7537 |
|
| 7538 |
|
| 7539 |
|
| 7540 |
winPtr->flags &= ~TK_TOP_LEVEL; |
| 7541 |
atts.event_mask = winPtr->atts.event_mask; |
| 7542 |
atts.event_mask &= ~StructureNotifyMask; |
| 7543 |
Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWEventMask, &atts); |
| 7544 |
|
| 7545 |
UnmanageGeometry((Tk_Window) winPtr); |
| 7546 |
} |
| 7547 |
return TCL_OK; |
| 7548 |
} |
| 7549 |
|
| 7550 |
static int |
| 7551 |
WmReleaseCmd(tkwin, winPtr, interp, objc, objv) |
| 7552 |
Tk_Window tkwin; |
| 7553 |
TkWindow *winPtr; |
| 7554 |
Tcl_Interp *interp; |
| 7555 |
int objc; |
| 7556 |
Tcl_Obj *CONST objv[]; |
| 7557 |
{ |
| 7558 |
|
| 7559 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7560 |
|
| 7561 |
if (Tk_IsTopLevel(winPtr)) { |
| 7562 |
Tcl_AppendResult(interp, "Already a toplevel window", NULL); |
| 7563 |
return TCL_ERROR; |
| 7564 |
} |
| 7565 |
|
| 7566 |
|
| 7567 |
UnmanageGeometry((Tk_Window) winPtr); |
| 7568 |
|
| 7569 |
if (winPtr->window == None) { |
| 7570 |
|
| 7571 |
|
| 7572 |
|
| 7573 |
winPtr->dirtyAtts |= CWBorderPixel; |
| 7574 |
} |
| 7575 |
else { |
| 7576 |
Window parent; |
| 7577 |
|
| 7578 |
if (winPtr->flags & TK_MAPPED) { |
| 7579 |
Tk_UnmapWindow((Tk_Window) winPtr); |
| 7580 |
} |
| 7581 |
parent = XRootWindow(winPtr->display, winPtr->screenNum); |
| 7582 |
XReparentWindow(winPtr->display, winPtr->window, parent, 0, 0); |
| 7583 |
|
| 7584 |
|
| 7585 |
} |
| 7586 |
|
| 7587 |
winPtr->flags |= TK_TOP_LEVEL; |
| 7588 |
TkWmNewWindow(winPtr); |
| 7589 |
|
| 7590 |
wmPtr = winPtr->wmInfoPtr; |
| 7591 |
wmPtr->hints.initial_state = WithdrawnState; |
| 7592 |
wmPtr->withdrawn = 1; |
| 7593 |
|
| 7594 |
|
| 7595 |
winPtr->reqWidth++; |
| 7596 |
winPtr->reqHeight++; |
| 7597 |
Tk_GeometryRequest((Tk_Window) winPtr, winPtr->reqWidth - 1, |
| 7598 |
winPtr->reqHeight - 1); |
| 7599 |
|
| 7600 |
return TCL_OK; |
| 7601 |
} |
| 7602 |
|
| 7603 |
static int |
| 7604 |
WmWrapperCmd(tkwin, winPtr, interp, objc, objv) |
| 7605 |
Tk_Window tkwin; |
| 7606 |
TkWindow *winPtr; |
| 7607 |
Tcl_Interp *interp; |
| 7608 |
int objc; |
| 7609 |
Tcl_Obj *CONST objv[]; |
| 7610 |
{ |
| 7611 |
register WmInfo *wmPtr = winPtr->wmInfoPtr; |
| 7612 |
|
| 7613 |
if (wmPtr->wrapperPtr == NULL) { |
| 7614 |
CreateWrapper(wmPtr); |
| 7615 |
} |
| 7616 |
Tcl_IntResults(interp,2,0,wmPtr->wrapperPtr->window,wmPtr->menuHeight); |
| 7617 |
return TCL_OK; |
| 7618 |
} |
| 7619 |
|
| 7620 |
|
| 7621 |
|
| 7622 |
|
| 7623 |
|