| 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 "tkOption.h" |
| 21 |
#include "tkOption.m" |
| 22 |
#undef Tk_OptionObjCmd |
| 23 |
|
| 24 |
#if !( defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) |
| 25 |
#include "tkUnixInt.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#define HD_CLEANUP 1 |
| 34 |
#define HD_FOCUS 2 |
| 35 |
#define HD_MAIN_WIN 4 |
| 36 |
#define HD_DESTROY_COUNT 8 |
| 37 |
#define HD_DESTROY_EVENT 0x10 |
| 38 |
|
| 39 |
typedef struct TkHalfdeadWindow { |
| 40 |
int flags; |
| 41 |
struct TkWindow *winPtr; |
| 42 |
struct TkHalfdeadWindow *nextPtr; |
| 43 |
} TkHalfdeadWindow; |
| 44 |
|
| 45 |
|
| 46 |
typedef struct ThreadSpecificData { |
| 47 |
int numMainWindows; |
| 48 |
|
| 49 |
TkMainInfo *mainWindowList; |
| 50 |
|
| 51 |
|
| 52 |
TkHalfdeadWindow *halfdeadWindowList; |
| 53 |
|
| 54 |
|
| 55 |
TkDisplay *displayList; |
| 56 |
|
| 57 |
|
| 58 |
int initialized; |
| 59 |
|
| 60 |
} ThreadSpecificData; |
| 61 |
static Tcl_ThreadDataKey dataKey; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
TCL_DECLARE_MUTEX(windowMutex) |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
static XWindowChanges defChanges = { |
| 76 |
0, 0, 1, 1, 0, 0, Above |
| 77 |
}; |
| 78 |
#define ALL_EVENTS_MASK \ |
| 79 |
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask| \ |
| 80 |
EnterWindowMask|LeaveWindowMask|PointerMotionMask|ExposureMask| \ |
| 81 |
VisibilityChangeMask|PropertyChangeMask|ColormapChangeMask |
| 82 |
static XSetWindowAttributes defAtts= { |
| 83 |
None, |
| 84 |
0, |
| 85 |
CopyFromParent, |
| 86 |
0, |
| 87 |
NorthWestGravity, |
| 88 |
NorthWestGravity, |
| 89 |
NotUseful, |
| 90 |
(unsigned) ~0, |
| 91 |
0, |
| 92 |
False, |
| 93 |
ALL_EVENTS_MASK, |
| 94 |
0, |
| 95 |
False, |
| 96 |
CopyFromParent, |
| 97 |
None |
| 98 |
}; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
typedef struct { |
| 106 |
char *name; |
| 107 |
Tcl_ObjCmdProc *cmdProc; |
| 108 |
Tcl_ObjCmdProc *objProc; |
| 109 |
int isSafe; |
| 110 |
|
| 111 |
|
| 112 |
int passMainWindow; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
} TkCmd; |
| 117 |
|
| 118 |
#ifdef _LANG |
| 119 |
#define LangLoaded(x) NULL |
| 120 |
#else |
| 121 |
#define LangLoaded(x) x |
| 122 |
#endif |
| 123 |
|
| 124 |
static TkCmd commands[] = { |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
{"bell", NULL, Tk_BellObjCmd, 0, 1}, |
| 130 |
{"bind", NULL, Tk_BindObjCmd, 1, 1}, |
| 131 |
{"bindtags", NULL, Tk_BindtagsObjCmd, 1, 1}, |
| 132 |
{"clipboard", NULL, Tk_ClipboardObjCmd, 0, 1}, |
| 133 |
{"destroy", NULL, Tk_DestroyObjCmd, 1, 1}, |
| 134 |
{"event", NULL, Tk_EventObjCmd, 1, 1}, |
| 135 |
{"focus", NULL, Tk_FocusObjCmd, 1, 1}, |
| 136 |
{"font", NULL, Tk_FontObjCmd, 1, 1}, |
| 137 |
{"grab", NULL, Tk_GrabObjCmd, 0, 1}, |
| 138 |
{"grid", NULL, Tk_GridObjCmd, 1, 1}, |
| 139 |
{"image", NULL, Tk_ImageObjCmd, 1, 1}, |
| 140 |
{"lower", NULL, Tk_LowerObjCmd, 1, 1}, |
| 141 |
{"option", NULL, Tk_OptionObjCmd, 1, 1}, |
| 142 |
{"pack", NULL, Tk_PackObjCmd, 1, 1}, |
| 143 |
{"place", NULL, Tk_PlaceObjCmd, 1, 0}, |
| 144 |
{"raise", NULL, Tk_RaiseObjCmd, 1, 1}, |
| 145 |
{"selection", NULL, Tk_SelectionObjCmd, 0, 1}, |
| 146 |
{"tk", NULL, Tk_TkObjCmd, 1, 1}, |
| 147 |
{"tkwait", NULL, Tk_TkwaitObjCmd, 1, 1}, |
| 148 |
#if defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK) |
| 149 |
{"tk_chooseColor", NULL, Tk_ChooseColorObjCmd, 0, 1}, |
| 150 |
{"tk_chooseDirectory", NULL, Tk_ChooseDirectoryObjCmd, 0, 1}, |
| 151 |
{"tk_getOpenFile", NULL, Tk_GetOpenFileObjCmd, 0, 1}, |
| 152 |
{"tk_getSaveFile", NULL, Tk_GetSaveFileObjCmd, 0, 1}, |
| 153 |
#endif |
| 154 |
#ifdef __WIN32__ |
| 155 |
{"tk_messageBox", NULL, Tk_MessageBoxObjCmd, 0, 1}, |
| 156 |
#endif |
| 157 |
{"update", NULL, Tk_UpdateObjCmd, 1, 1}, |
| 158 |
{"winfo", NULL, Tk_WinfoObjCmd, 1, 1}, |
| 159 |
{"wm", NULL, Tk_WmObjCmd, 0, 1}, |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
{"button", NULL, Tk_ButtonObjCmd, 1, 0}, |
| 166 |
{"canvas", NULL, LangLoaded(Tk_CanvasObjCmd), 1, 1}, |
| 167 |
{"checkbutton", NULL, Tk_CheckbuttonObjCmd, 1, 0}, |
| 168 |
{"entry", NULL, LangLoaded(Tk_EntryObjCmd), 1, 0}, |
| 169 |
{"frame", NULL, Tk_FrameObjCmd, 1, 0}, |
| 170 |
{"label", NULL, Tk_LabelObjCmd, 1, 0}, |
| 171 |
{"labelframe", NULL, Tk_LabelframeObjCmd, 1, 0}, |
| 172 |
{"listbox", NULL, LangLoaded(Tk_ListboxObjCmd), 1, 0}, |
| 173 |
{"menubutton", NULL, LangLoaded(Tk_MenubuttonObjCmd), 1, 0}, |
| 174 |
{"message", NULL, Tk_MessageObjCmd, 1, 0}, |
| 175 |
{"panedwindow", NULL, Tk_PanedWindowObjCmd, 1, 0}, |
| 176 |
{"radiobutton", NULL, Tk_RadiobuttonObjCmd, 1, 0}, |
| 177 |
{"scale", NULL, LangLoaded(Tk_ScaleObjCmd), 1, 0}, |
| 178 |
{"scrollbar", LangLoaded(Tk_ScrollbarCmd), NULL, 1, 1}, |
| 179 |
{"spinbox", NULL, LangLoaded(Tk_SpinboxObjCmd), 1, 0}, |
| 180 |
{"text", LangLoaded(Tk_TextCmd), NULL, 1, 1}, |
| 181 |
{"toplevel", NULL, Tk_ToplevelObjCmd, 0, 0}, |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
#if defined(MAC_TCL) || defined(MAC_OSX_TK) |
| 188 |
{"::tk::unsupported::MacWindowStyle", |
| 189 |
TkUnsupported1Cmd, NULL, 1, 1}, |
| 190 |
#endif |
| 191 |
{(char *) NULL, (int (*) _ANSI_ARGS_((ClientData, Tcl_Interp *, int, Tcl_Obj *CONST *))) NULL, NULL, 0} |
| 192 |
}; |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
static int synchronize = 0; |
| 200 |
static Tcl_Obj * name; |
| 201 |
static Tcl_Obj * display; |
| 202 |
static Tcl_Obj * geometry; |
| 203 |
static Tcl_Obj * colormap = NULL; |
| 204 |
static Tcl_Obj * visual = NULL; |
| 205 |
static Tcl_Obj * use = NULL; |
| 206 |
static int rest = 0; |
| 207 |
|
| 208 |
static Tk_ArgvInfo argTable[] = { |
| 209 |
{"-colormap", TK_ARGV_STRING, (char *) NULL, (char *) &colormap, |
| 210 |
"Colormap for main window"}, |
| 211 |
{"-display", TK_ARGV_STRING, (char *) NULL, (char *) &display, |
| 212 |
"Display to use"}, |
| 213 |
{"-geometry", TK_ARGV_STRING, (char *) NULL, (char *) &geometry, |
| 214 |
"Initial geometry for window"}, |
| 215 |
{"-name", TK_ARGV_STRING, (char *) NULL, (char *) &name, |
| 216 |
"Name to use for application"}, |
| 217 |
{"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize, |
| 218 |
"Use synchronous mode for display server"}, |
| 219 |
{"-visual", TK_ARGV_STRING, (char *) NULL, (char *) &visual, |
| 220 |
"Visual for main window"}, |
| 221 |
{"-use", TK_ARGV_STRING, (char *) NULL, (char *) &use, |
| 222 |
"Id of window in which to embed application"}, |
| 223 |
{"--", TK_ARGV_REST, (char *) 1, (char *) &rest, |
| 224 |
"Pass all remaining arguments through to script"}, |
| 225 |
{(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL, |
| 226 |
(char *) NULL} |
| 227 |
}; |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
static Tk_Window CreateTopLevelWindow _ANSI_ARGS_((Tcl_Interp *interp, |
| 234 |
Tk_Window parent, CONST char *name, |
| 235 |
CONST char *screenName, unsigned int flags)); |
| 236 |
static void DeleteWindowsExitProc _ANSI_ARGS_(( |
| 237 |
ClientData clientData)); |
| 238 |
static TkDisplay * GetScreen _ANSI_ARGS_((Tcl_Interp *interp, |
| 239 |
CONST char *screenName, int *screenPtr)); |
| 240 |
static int Initialize _ANSI_ARGS_((Tcl_Interp *interp)); |
| 241 |
static int NameWindow _ANSI_ARGS_((Tcl_Interp *interp, |
| 242 |
TkWindow *winPtr, TkWindow *parentPtr, |
| 243 |
CONST char *name)); |
| 244 |
static void UnlinkWindow _ANSI_ARGS_((TkWindow *winPtr)); |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
static void |
| 264 |
TkCloseDisplay(TkDisplay *dispPtr) |
| 265 |
{ |
| 266 |
TkClipCleanup(dispPtr); |
| 267 |
|
| 268 |
if (dispPtr->name != NULL) { |
| 269 |
ckfree(dispPtr->name); |
| 270 |
} |
| 271 |
|
| 272 |
if (dispPtr->atomInit) { |
| 273 |
Tcl_DeleteHashTable(&dispPtr->nameTable); |
| 274 |
Tcl_DeleteHashTable(&dispPtr->atomTable); |
| 275 |
dispPtr->atomInit = 0; |
| 276 |
} |
| 277 |
|
| 278 |
if (dispPtr->errorPtr != NULL) { |
| 279 |
TkErrorHandler *errorPtr; |
| 280 |
for (errorPtr = dispPtr->errorPtr; |
| 281 |
errorPtr != NULL; |
| 282 |
errorPtr = dispPtr->errorPtr) { |
| 283 |
dispPtr->errorPtr = errorPtr->nextPtr; |
| 284 |
ckfree((char *) errorPtr); |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
TkGCCleanup(dispPtr); |
| 289 |
|
| 290 |
TkpCloseDisplay(dispPtr); |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
Tcl_DeleteHashTable(&dispPtr->winTable); |
| 298 |
|
| 299 |
ckfree((char *) dispPtr); |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
static Tk_Window |
| 329 |
CreateTopLevelWindow(interp, parent, name, screenName, flags) |
| 330 |
Tcl_Interp *interp; |
| 331 |
Tk_Window parent; |
| 332 |
|
| 333 |
|
| 334 |
CONST char *name; |
| 335 |
|
| 336 |
|
| 337 |
CONST char *screenName; |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
unsigned int flags; |
| 343 |
{ |
| 344 |
register TkWindow *winPtr; |
| 345 |
register TkDisplay *dispPtr; |
| 346 |
int screenId; |
| 347 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 348 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 349 |
|
| 350 |
if (!tsdPtr->initialized) { |
| 351 |
tsdPtr->initialized = 1; |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
Tk_CreateImageType(&tkBitmapImageType); |
| 358 |
|
| 359 |
#ifndef _LANG |
| 360 |
Tk_CreateImageType(&tkPhotoImageType); |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
Tk_CreatePhotoImageFormat(&tkImgFmtGIF); |
| 366 |
Tk_CreateOldPhotoImageFormat(&tkImgFmtPPM); |
| 367 |
#endif |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
Tcl_CreateExitHandler(DeleteWindowsExitProc, (ClientData) NULL); |
| 375 |
} |
| 376 |
|
| 377 |
if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) { |
| 378 |
dispPtr = ((TkWindow *) parent)->dispPtr; |
| 379 |
screenId = Tk_ScreenNumber(parent); |
| 380 |
} else { |
| 381 |
dispPtr = GetScreen(interp, screenName, &screenId); |
| 382 |
if (dispPtr == NULL) { |
| 383 |
return (Tk_Window) NULL; |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
winPtr = TkAllocWindow(dispPtr, screenId, (TkWindow *) parent); |
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
winPtr->flags |= flags; |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
winPtr->dirtyAtts |= CWBorderPixel; |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; |
| 411 |
|
| 412 |
if (parent != NULL) { |
| 413 |
if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { |
| 414 |
Tk_DestroyWindow((Tk_Window) winPtr); |
| 415 |
return (Tk_Window) NULL; |
| 416 |
} |
| 417 |
} |
| 418 |
TkWmNewWindow(winPtr); |
| 419 |
|
| 420 |
return (Tk_Window) winPtr; |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
static TkDisplay * |
| 448 |
GetScreen(interp, screenName, screenPtr) |
| 449 |
Tcl_Interp *interp; |
| 450 |
CONST char *screenName; |
| 451 |
|
| 452 |
int *screenPtr; |
| 453 |
{ |
| 454 |
register TkDisplay *dispPtr; |
| 455 |
CONST char *p; |
| 456 |
int screenId; |
| 457 |
size_t length; |
| 458 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 459 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
screenName = TkGetDefaultScreenName(interp, screenName); |
| 469 |
if (screenName == NULL) { |
| 470 |
Tcl_SetResult(interp, |
| 471 |
"no display name and no $DISPLAY environment variable", |
| 472 |
TCL_STATIC); |
| 473 |
return (TkDisplay *) NULL; |
| 474 |
} |
| 475 |
length = strlen(screenName); |
| 476 |
screenId = 0; |
| 477 |
p = screenName+length-1; |
| 478 |
while (isdigit(UCHAR(*p)) && (p != screenName)) { |
| 479 |
p--; |
| 480 |
} |
| 481 |
if ((*p == '.') && (p[1] != '\0')) { |
| 482 |
length = p - screenName; |
| 483 |
screenId = strtoul(p+1, (char **) NULL, 10); |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
for (dispPtr = tsdPtr->displayList; ; dispPtr = dispPtr->nextPtr) { |
| 492 |
if (dispPtr == NULL) { |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
dispPtr = TkpOpenDisplay(screenName); |
| 498 |
if (dispPtr == NULL) { |
| 499 |
Tcl_AppendResult(interp, "couldn't connect to display \"", |
| 500 |
screenName, "\"", (char *) NULL); |
| 501 |
return (TkDisplay *) NULL; |
| 502 |
} |
| 503 |
dispPtr->nextPtr = tsdPtr->displayList; |
| 504 |
tsdPtr->displayList = dispPtr; |
| 505 |
|
| 506 |
dispPtr->lastEventTime = CurrentTime; |
| 507 |
dispPtr->bindInfoStale = 1; |
| 508 |
dispPtr->cursorFont = None; |
| 509 |
dispPtr->warpWindow = None; |
| 510 |
dispPtr->multipleAtom = None; |
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
dispPtr->flags |= TK_DISPLAY_COLLAPSE_MOTION_EVENTS; |
| 516 |
|
| 517 |
#ifdef TK_USE_INPUT_METHODS |
| 518 |
#ifdef X_HAVE_UTF8_STRING |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
dispPtr->flags |= TK_DISPLAY_USE_IM; |
| 523 |
#endif |
| 524 |
#endif |
| 525 |
|
| 526 |
Tcl_InitHashTable(&dispPtr->winTable, TCL_ONE_WORD_KEYS); |
| 527 |
|
| 528 |
dispPtr->name = (char *) ckalloc((unsigned) (length+1)); |
| 529 |
strncpy(dispPtr->name, screenName, length); |
| 530 |
dispPtr->name[length] = '\0'; |
| 531 |
|
| 532 |
TkInitXId(dispPtr); |
| 533 |
break; |
| 534 |
} |
| 535 |
if ((strncmp(dispPtr->name, screenName, length) == 0) |
| 536 |
&& (dispPtr->name[length] == '\0')) { |
| 537 |
break; |
| 538 |
} |
| 539 |
} |
| 540 |
if (screenId >= ScreenCount(dispPtr->display)) { |
| 541 |
char buf[32 + TCL_INTEGER_SPACE]; |
| 542 |
|
| 543 |
sprintf(buf, "bad screen number \"%d\"", screenId); |
| 544 |
Tcl_SetResult(interp, buf, TCL_VOLATILE); |
| 545 |
return (TkDisplay *) NULL; |
| 546 |
} |
| 547 |
*screenPtr = screenId; |
| 548 |
return dispPtr; |
| 549 |
} |
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
TkDisplay * |
| 570 |
TkGetDisplay(display) |
| 571 |
Display *display; |
| 572 |
{ |
| 573 |
TkDisplay *dispPtr; |
| 574 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 575 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 576 |
|
| 577 |
for (dispPtr = tsdPtr->displayList; dispPtr != NULL; |
| 578 |
dispPtr = dispPtr->nextPtr) { |
| 579 |
if (dispPtr->display == display) { |
| 580 |
break; |
| 581 |
} |
| 582 |
} |
| 583 |
return dispPtr; |
| 584 |
} |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
TkDisplay * |
| 604 |
TkGetDisplayList() |
| 605 |
{ |
| 606 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 607 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 608 |
|
| 609 |
return tsdPtr->displayList; |
| 610 |
} |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
TkMainInfo * |
| 631 |
TkGetMainInfoList() |
| 632 |
{ |
| 633 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 634 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 635 |
|
| 636 |
return tsdPtr->mainWindowList; |
| 637 |
} |
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
TkWindow * |
| 656 |
TkAllocWindow(dispPtr, screenNum, parentPtr) |
| 657 |
TkDisplay *dispPtr; |
| 658 |
int screenNum; |
| 659 |
TkWindow *parentPtr; |
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
{ |
| 664 |
register TkWindow *winPtr; |
| 665 |
|
| 666 |
winPtr = (TkWindow *) ckalloc(sizeof(TkWindow)); |
| 667 |
winPtr->display = dispPtr->display; |
| 668 |
winPtr->dispPtr = dispPtr; |
| 669 |
winPtr->screenNum = screenNum; |
| 670 |
if ((parentPtr != NULL) && (parentPtr->display == winPtr->display) |
| 671 |
&& (parentPtr->screenNum == winPtr->screenNum)) { |
| 672 |
winPtr->visual = parentPtr->visual; |
| 673 |
winPtr->depth = parentPtr->depth; |
| 674 |
} else { |
| 675 |
winPtr->visual = DefaultVisual(dispPtr->display, screenNum); |
| 676 |
winPtr->depth = DefaultDepth(dispPtr->display, screenNum); |
| 677 |
} |
| 678 |
winPtr->window = None; |
| 679 |
winPtr->childList = NULL; |
| 680 |
winPtr->lastChildPtr = NULL; |
| 681 |
winPtr->parentPtr = NULL; |
| 682 |
winPtr->nextPtr = NULL; |
| 683 |
winPtr->mainPtr = NULL; |
| 684 |
winPtr->pathName = NULL; |
| 685 |
winPtr->nameUid = NULL; |
| 686 |
winPtr->classUid = NULL; |
| 687 |
winPtr->changes = defChanges; |
| 688 |
winPtr->dirtyChanges = CWX|CWY|CWWidth|CWHeight|CWBorderWidth; |
| 689 |
winPtr->atts = defAtts; |
| 690 |
if ((parentPtr != NULL) && (parentPtr->display == winPtr->display) |
| 691 |
&& (parentPtr->screenNum == winPtr->screenNum)) { |
| 692 |
winPtr->atts.colormap = parentPtr->atts.colormap; |
| 693 |
} else { |
| 694 |
winPtr->atts.colormap = DefaultColormap(dispPtr->display, screenNum); |
| 695 |
} |
| 696 |
winPtr->dirtyAtts = CWEventMask|CWColormap|CWBitGravity; |
| 697 |
winPtr->flags = 0; |
| 698 |
winPtr->handlerList = NULL; |
| 699 |
#ifdef TK_USE_INPUT_METHODS |
| 700 |
winPtr->inputContext = NULL; |
| 701 |
#endif |
| 702 |
winPtr->tagPtr = NULL; |
| 703 |
winPtr->numTags = 0; |
| 704 |
winPtr->optionLevel = -1; |
| 705 |
winPtr->selHandlerList = NULL; |
| 706 |
winPtr->geomMgrPtr = NULL; |
| 707 |
winPtr->geomData = NULL; |
| 708 |
winPtr->reqWidth = winPtr->reqHeight = 1; |
| 709 |
winPtr->internalBorderLeft = 0; |
| 710 |
winPtr->wmInfoPtr = NULL; |
| 711 |
winPtr->classProcsPtr = NULL; |
| 712 |
winPtr->instanceData = NULL; |
| 713 |
winPtr->privatePtr = NULL; |
| 714 |
winPtr->internalBorderRight = 0; |
| 715 |
winPtr->internalBorderTop = 0; |
| 716 |
winPtr->internalBorderBottom = 0; |
| 717 |
winPtr->minReqWidth = 0; |
| 718 |
winPtr->minReqHeight = 0; |
| 719 |
|
| 720 |
return winPtr; |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
static int |
| 742 |
NameWindow(interp, winPtr, parentPtr, name) |
| 743 |
Tcl_Interp *interp; |
| 744 |
register TkWindow *winPtr; |
| 745 |
TkWindow *parentPtr; |
| 746 |
|
| 747 |
CONST char *name; |
| 748 |
|
| 749 |
{ |
| 750 |
#define FIXED_SIZE 200 |
| 751 |
char staticSpace[FIXED_SIZE]; |
| 752 |
char *pathName; |
| 753 |
int new; |
| 754 |
Tcl_HashEntry *hPtr; |
| 755 |
int length1, length2; |
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
winPtr->parentPtr = parentPtr; |
| 764 |
winPtr->nextPtr = NULL; |
| 765 |
if (parentPtr->childList == NULL) { |
| 766 |
parentPtr->childList = winPtr; |
| 767 |
} else { |
| 768 |
parentPtr->lastChildPtr->nextPtr = winPtr; |
| 769 |
} |
| 770 |
parentPtr->lastChildPtr = winPtr; |
| 771 |
winPtr->mainPtr = parentPtr->mainPtr; |
| 772 |
winPtr->mainPtr->refCount++; |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
if (winPtr->flags & TK_ANONYMOUS_WINDOW) { |
| 779 |
return TCL_OK; |
| 780 |
} |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
winPtr->nameUid = Tk_GetUid(name); |
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
if (isupper(UCHAR(name[0]))) { |
| 794 |
Tcl_AppendResult(interp, |
| 795 |
"window name starts with an upper-case letter: \"", |
| 796 |
name, "\"", (char *) NULL); |
| 797 |
return TCL_ERROR; |
| 798 |
} |
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
length1 = strlen(parentPtr->pathName); |
| 808 |
length2 = strlen(name); |
| 809 |
if ((length1+length2+2) <= FIXED_SIZE) { |
| 810 |
pathName = staticSpace; |
| 811 |
} else { |
| 812 |
pathName = (char *) ckalloc((unsigned) (length1+length2+2)); |
| 813 |
} |
| 814 |
if (length1 == 1) { |
| 815 |
pathName[0] = '.'; |
| 816 |
strcpy(pathName+1, name); |
| 817 |
} else { |
| 818 |
strcpy(pathName, parentPtr->pathName); |
| 819 |
pathName[length1] = '.'; |
| 820 |
strcpy(pathName+length1+1, name); |
| 821 |
} |
| 822 |
hPtr = Tcl_CreateHashEntry(&parentPtr->mainPtr->nameTable, pathName, &new); |
| 823 |
if (pathName != staticSpace) { |
| 824 |
ckfree(pathName); |
| 825 |
} |
| 826 |
if (!new) { |
| 827 |
Tcl_AppendResult(interp, "window name \"", name, |
| 828 |
"\" already exists in parent", (char *) NULL); |
| 829 |
return TCL_ERROR; |
| 830 |
} |
| 831 |
Tcl_SetHashValue(hPtr, winPtr); |
| 832 |
winPtr->pathName = Tcl_GetHashKey(&parentPtr->mainPtr->nameTable, hPtr); |
| 833 |
return TCL_OK; |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
Tk_Window |
| 862 |
TkCreateMainWindow(interp, screenName, baseName) |
| 863 |
Tcl_Interp *interp; |
| 864 |
CONST char *screenName; |
| 865 |
|
| 866 |
|
| 867 |
char *baseName; |
| 868 |
|
| 869 |
{ |
| 870 |
Tk_Window tkwin; |
| 871 |
int dummy; |
| 872 |
int isSafe; |
| 873 |
Tcl_HashEntry *hPtr; |
| 874 |
register TkMainInfo *mainPtr; |
| 875 |
register TkWindow *winPtr; |
| 876 |
Var variable; |
| 877 |
char *libDir = LangLibraryDir(); |
| 878 |
static char *argv[] = {(char *) NULL}; |
| 879 |
register TkCmd *cmdPtr; |
| 880 |
ClientData clientData; |
| 881 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 882 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
if (sizeof(TkWindow) != sizeof(Tk_FakeWin)) { |
| 890 |
panic("TkWindow and Tk_FakeWin are not the same size"); |
| 891 |
} |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
tkwin = CreateTopLevelWindow(interp, (Tk_Window) NULL, baseName, |
| 898 |
screenName, 0); |
| 899 |
if (tkwin == NULL) { |
| 900 |
return NULL; |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
winPtr = (TkWindow *) tkwin; |
| 909 |
mainPtr = (TkMainInfo *) ckalloc(sizeof(TkMainInfo)); |
| 910 |
mainPtr->winPtr = winPtr; |
| 911 |
mainPtr->refCount = 1; |
| 912 |
mainPtr->interp = interp; |
| 913 |
Tcl_InitHashTable(&mainPtr->nameTable, TCL_STRING_KEYS); |
| 914 |
mainPtr->deletionEpoch = 0l; |
| 915 |
TkEventInit(); |
| 916 |
TkBindInit(mainPtr); |
| 917 |
TkFontPkgInit(mainPtr); |
| 918 |
TkStylePkgInit(mainPtr); |
| 919 |
mainPtr->tlFocusPtr = NULL; |
| 920 |
mainPtr->displayFocusPtr = NULL; |
| 921 |
mainPtr->optionRootPtr = NULL; |
| 922 |
Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS); |
| 923 |
mainPtr->strictMotif = 0; |
| 924 |
if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif, |
| 925 |
TCL_LINK_BOOLEAN) != TCL_OK) { |
| 926 |
Tcl_ResetResult(interp); |
| 927 |
} |
| 928 |
mainPtr->nextPtr = tsdPtr->mainWindowList; |
| 929 |
tsdPtr->mainWindowList = mainPtr; |
| 930 |
winPtr->mainPtr = mainPtr; |
| 931 |
hPtr = Tcl_CreateHashEntry(&mainPtr->nameTable, ".", &dummy); |
| 932 |
Tcl_SetHashValue(hPtr, winPtr); |
| 933 |
winPtr->pathName = Tcl_GetHashKey(&mainPtr->nameTable, hPtr); |
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
winPtr->dispPtr->refCount++; |
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
winPtr->nameUid = Tk_GetUid(Tk_SetAppName(tkwin, baseName)); |
| 947 |
|
| 948 |
Lang_NewMainWindow(interp, tkwin); |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
isSafe = Tcl_IsSafe(interp); |
| 955 |
for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { |
| 956 |
#ifndef _LANG |
| 957 |
if ((cmdPtr->cmdProc == NULL) && (cmdPtr->objProc == NULL)) { |
| 958 |
panic("TkCreateMainWindow: builtin command with NULL string and object procs"); |
| 959 |
} |
| 960 |
#endif |
| 961 |
if (cmdPtr->passMainWindow) { |
| 962 |
clientData = (ClientData) tkwin; |
| 963 |
} else { |
| 964 |
clientData = (ClientData) NULL; |
| 965 |
} |
| 966 |
if (cmdPtr->cmdProc != NULL) { |
| 967 |
Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->cmdProc, |
| 968 |
clientData, (void (*) _ANSI_ARGS_((ClientData))) NULL); |
| 969 |
} else { |
| 970 |
Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, |
| 971 |
clientData, NULL); |
| 972 |
} |
| 973 |
if (isSafe) { |
| 974 |
if (!(cmdPtr->isSafe)) { |
| 975 |
Tcl_HideCommand(interp, cmdPtr->name, cmdPtr->name); |
| 976 |
} |
| 977 |
} |
| 978 |
} |
| 979 |
|
| 980 |
Tcl_SetVar(interp, "tk_library", libDir, TCL_GLOBAL_ONLY); |
| 981 |
|
| 982 |
TkCreateMenuCmd(interp); |
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
Tcl_SetVar(interp, "tk_patchLevel", TK_PATCH_LEVEL, TCL_GLOBAL_ONLY); |
| 990 |
Tcl_SetVar(interp, "tk_version", TK_VERSION, TCL_GLOBAL_ONLY); |
| 991 |
|
| 992 |
tsdPtr->numMainWindows++; |
| 993 |
return tkwin; |
| 994 |
} |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
Tk_Window |
| 1020 |
Tk_CreateWindow(interp, parent, name, screenName) |
| 1021 |
Tcl_Interp *interp; |
| 1022 |
|
| 1023 |
|
| 1024 |
Tk_Window parent; |
| 1025 |
CONST char *name; |
| 1026 |
|
| 1027 |
CONST char *screenName; |
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
{ |
| 1033 |
TkWindow *parentPtr = (TkWindow *) parent; |
| 1034 |
TkWindow *winPtr; |
| 1035 |
|
| 1036 |
if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { |
| 1037 |
Tcl_AppendResult(interp, |
| 1038 |
"can't create window: parent has been destroyed", |
| 1039 |
(char *) NULL); |
| 1040 |
return NULL; |
| 1041 |
} else if ((parentPtr != NULL) && |
| 1042 |
(parentPtr->flags & TK_CONTAINER)) { |
| 1043 |
Tcl_AppendResult(interp, |
| 1044 |
"can't create window: its parent has -container = yes", |
| 1045 |
(char *) NULL); |
| 1046 |
return NULL; |
| 1047 |
} |
| 1048 |
if (screenName == NULL) { |
| 1049 |
winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, |
| 1050 |
parentPtr); |
| 1051 |
if (NameWindow(interp, winPtr, parentPtr, name) != TCL_OK) { |
| 1052 |
Tk_DestroyWindow((Tk_Window) winPtr); |
| 1053 |
return NULL; |
| 1054 |
} else { |
| 1055 |
return (Tk_Window) winPtr; |
| 1056 |
} |
| 1057 |
} else { |
| 1058 |
return CreateTopLevelWindow(interp, parent, name, screenName, |
| 1059 |
0); |
| 1060 |
} |
| 1061 |
} |
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
Tk_Window |
| 1088 |
Tk_CreateAnonymousWindow(interp, parent, screenName) |
| 1089 |
Tcl_Interp *interp; |
| 1090 |
|
| 1091 |
|
| 1092 |
Tk_Window parent; |
| 1093 |
CONST char *screenName; |
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
{ |
| 1099 |
TkWindow *parentPtr = (TkWindow *) parent; |
| 1100 |
TkWindow *winPtr; |
| 1101 |
|
| 1102 |
if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { |
| 1103 |
Tcl_AppendResult(interp, |
| 1104 |
"can't create window: parent has been destroyed", |
| 1105 |
(char *) NULL); |
| 1106 |
return NULL; |
| 1107 |
} else if ((parentPtr != NULL) && |
| 1108 |
(parentPtr->flags & TK_CONTAINER)) { |
| 1109 |
Tcl_AppendResult(interp, |
| 1110 |
"can't create window: its parent has -container = yes", |
| 1111 |
(char *) NULL); |
| 1112 |
return NULL; |
| 1113 |
} |
| 1114 |
if (screenName == NULL) { |
| 1115 |
winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, |
| 1116 |
parentPtr); |
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
winPtr->flags |= TK_ANONYMOUS_WINDOW; |
| 1123 |
if (NameWindow(interp, winPtr, parentPtr, (char *)NULL) != TCL_OK) { |
| 1124 |
Tk_DestroyWindow((Tk_Window) winPtr); |
| 1125 |
return NULL; |
| 1126 |
} |
| 1127 |
return (Tk_Window) winPtr; |
| 1128 |
} else { |
| 1129 |
return CreateTopLevelWindow(interp, parent, (char *)NULL, screenName, |
| 1130 |
TK_ANONYMOUS_WINDOW); |
| 1131 |
} |
| 1132 |
} |
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
Tk_Window |
| 1159 |
Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) |
| 1160 |
Tcl_Interp *interp; |
| 1161 |
|
| 1162 |
|
| 1163 |
Tk_Window tkwin; |
| 1164 |
|
| 1165 |
CONST char *pathName; |
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
CONST char *screenName; |
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
{ |
| 1175 |
#define FIXED_SPACE 5 |
| 1176 |
char fixedSpace[FIXED_SPACE+1]; |
| 1177 |
char *p; |
| 1178 |
Tk_Window parent; |
| 1179 |
int numChars; |
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
p = strrchr(pathName, '.'); |
| 1191 |
if (p == NULL) { |
| 1192 |
Tcl_AppendResult(interp, "bad window path name \"", pathName, |
| 1193 |
"\"", (char *) NULL); |
| 1194 |
return NULL; |
| 1195 |
} |
| 1196 |
numChars = (int) (p-pathName); |
| 1197 |
if (numChars > FIXED_SPACE) { |
| 1198 |
p = (char *) ckalloc((unsigned) (numChars+1)); |
| 1199 |
} else { |
| 1200 |
p = fixedSpace; |
| 1201 |
} |
| 1202 |
if (numChars == 0) { |
| 1203 |
*p = '.'; |
| 1204 |
p[1] = '\0'; |
| 1205 |
} else { |
| 1206 |
strncpy(p, pathName, (size_t) numChars); |
| 1207 |
p[numChars] = '\0'; |
| 1208 |
} |
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
parent = Tk_NameToWindow(interp, p, tkwin); |
| 1215 |
if (p != fixedSpace) { |
| 1216 |
ckfree(p); |
| 1217 |
} |
| 1218 |
if (parent == NULL) { |
| 1219 |
return NULL; |
| 1220 |
} |
| 1221 |
if (((TkWindow *) parent)->flags & TK_ALREADY_DEAD) { |
| 1222 |
Tcl_AppendResult(interp, |
| 1223 |
"can't create window: parent has been destroyed", (char *) NULL); |
| 1224 |
return NULL; |
| 1225 |
} else if (((TkWindow *) parent)->flags & TK_CONTAINER) { |
| 1226 |
Tcl_AppendResult(interp, |
| 1227 |
"can't create window: its parent has -container = yes", |
| 1228 |
(char *) NULL); |
| 1229 |
return NULL; |
| 1230 |
} |
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
if (screenName == NULL) { |
| 1237 |
TkWindow *parentPtr = (TkWindow *) parent; |
| 1238 |
TkWindow *winPtr; |
| 1239 |
|
| 1240 |
winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, |
| 1241 |
parentPtr); |
| 1242 |
if (NameWindow(interp, winPtr, parentPtr, pathName+numChars+1) |
| 1243 |
!= TCL_OK) { |
| 1244 |
Tk_DestroyWindow((Tk_Window) winPtr); |
| 1245 |
return NULL; |
| 1246 |
} else { |
| 1247 |
return (Tk_Window) winPtr; |
| 1248 |
} |
| 1249 |
} else { |
| 1250 |
return CreateTopLevelWindow(interp, parent, pathName+numChars+1, |
| 1251 |
screenName, 0); |
| 1252 |
} |
| 1253 |
} |
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
void |
| 1276 |
Tk_DestroyWindow(tkwin) |
| 1277 |
Tk_Window tkwin; |
| 1278 |
{ |
| 1279 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 1280 |
TkDisplay *dispPtr = winPtr->dispPtr; |
| 1281 |
XEvent event; |
| 1282 |
TkHalfdeadWindow *halfdeadPtr, *prev_halfdeadPtr; |
| 1283 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 1284 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 1285 |
|
| 1286 |
if (winPtr->flags & TK_ALREADY_DEAD) { |
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
return; |
| 1293 |
} |
| 1294 |
winPtr->flags |= TK_ALREADY_DEAD; |
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
if (tsdPtr->halfdeadWindowList && |
| 1303 |
(tsdPtr->halfdeadWindowList->flags & HD_CLEANUP) && |
| 1304 |
(tsdPtr->halfdeadWindowList->winPtr == winPtr)) { |
| 1305 |
halfdeadPtr = tsdPtr->halfdeadWindowList; |
| 1306 |
} else { |
| 1307 |
halfdeadPtr = (TkHalfdeadWindow *) ckalloc(sizeof(TkHalfdeadWindow)); |
| 1308 |
halfdeadPtr->flags = 0; |
| 1309 |
halfdeadPtr->winPtr = winPtr; |
| 1310 |
halfdeadPtr->nextPtr = tsdPtr->halfdeadWindowList; |
| 1311 |
tsdPtr->halfdeadWindowList = halfdeadPtr; |
| 1312 |
} |
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
if (!(halfdeadPtr->flags & HD_FOCUS)) { |
| 1324 |
halfdeadPtr->flags |= HD_FOCUS; |
| 1325 |
TkFocusDeadWindow(winPtr); |
| 1326 |
} |
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
if (!(halfdeadPtr->flags & HD_MAIN_WIN) && |
| 1343 |
winPtr->mainPtr != NULL && winPtr->mainPtr->winPtr == winPtr) { |
| 1344 |
halfdeadPtr->flags |= HD_MAIN_WIN; |
| 1345 |
dispPtr->refCount--; |
| 1346 |
if (tsdPtr->mainWindowList == winPtr->mainPtr) { |
| 1347 |
tsdPtr->mainWindowList = winPtr->mainPtr->nextPtr; |
| 1348 |
} else { |
| 1349 |
TkMainInfo *prevPtr; |
| 1350 |
|
| 1351 |
for (prevPtr = tsdPtr->mainWindowList; |
| 1352 |
prevPtr->nextPtr != winPtr->mainPtr; |
| 1353 |
prevPtr = prevPtr->nextPtr) { |
| 1354 |
|
| 1355 |
} |
| 1356 |
prevPtr->nextPtr = winPtr->mainPtr->nextPtr; |
| 1357 |
} |
| 1358 |
tsdPtr->numMainWindows--; |
| 1359 |
} |
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
if (!(halfdeadPtr->flags & HD_DESTROY_COUNT)) { |
| 1369 |
halfdeadPtr->flags |= HD_DESTROY_COUNT; |
| 1370 |
dispPtr->destroyCount++; |
| 1371 |
} |
| 1372 |
|
| 1373 |
while (winPtr->childList != NULL) { |
| 1374 |
TkWindow *childPtr; |
| 1375 |
childPtr = winPtr->childList; |
| 1376 |
childPtr->flags |= TK_DONT_DESTROY_WINDOW; |
| 1377 |
Tk_DestroyWindow((Tk_Window) childPtr); |
| 1378 |
if (winPtr->childList == childPtr) { |
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
winPtr->childList = childPtr->nextPtr; |
| 1387 |
childPtr->parentPtr = NULL; |
| 1388 |
} |
| 1389 |
} |
| 1390 |
if ((winPtr->flags & (TK_CONTAINER|TK_BOTH_HALVES)) |
| 1391 |
== (TK_CONTAINER|TK_BOTH_HALVES)) { |
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
TkWindow *childPtr; |
| 1404 |
childPtr = TkpGetOtherWindow(winPtr); |
| 1405 |
if (childPtr != NULL) { |
| 1406 |
childPtr->flags |= TK_DONT_DESTROY_WINDOW; |
| 1407 |
Tk_DestroyWindow((Tk_Window) childPtr); |
| 1408 |
} |
| 1409 |
} |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
if (!(halfdeadPtr->flags & HD_DESTROY_EVENT) && |
| 1425 |
winPtr->pathName != NULL && |
| 1426 |
!(winPtr->flags & TK_ANONYMOUS_WINDOW)) { |
| 1427 |
halfdeadPtr->flags |= HD_DESTROY_EVENT; |
| 1428 |
if (winPtr->window == None) { |
| 1429 |
Tk_MakeWindowExist(tkwin); |
| 1430 |
} |
| 1431 |
event.type = DestroyNotify; |
| 1432 |
event.xdestroywindow.serial = |
| 1433 |
LastKnownRequestProcessed(winPtr->display); |
| 1434 |
event.xdestroywindow.send_event = False; |
| 1435 |
event.xdestroywindow.display = winPtr->display; |
| 1436 |
event.xdestroywindow.event = winPtr->window; |
| 1437 |
event.xdestroywindow.window = winPtr->window; |
| 1438 |
Tk_HandleEvent(&event); |
| 1439 |
} |
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
for (prev_halfdeadPtr = NULL, |
| 1449 |
halfdeadPtr = tsdPtr->halfdeadWindowList; |
| 1450 |
halfdeadPtr != NULL; ) { |
| 1451 |
if (halfdeadPtr->winPtr == winPtr) { |
| 1452 |
if (prev_halfdeadPtr == NULL) |
| 1453 |
tsdPtr->halfdeadWindowList = halfdeadPtr->nextPtr; |
| 1454 |
else |
| 1455 |
prev_halfdeadPtr->nextPtr = halfdeadPtr->nextPtr; |
| 1456 |
ckfree((char *) halfdeadPtr); |
| 1457 |
break; |
| 1458 |
} |
| 1459 |
prev_halfdeadPtr = halfdeadPtr; |
| 1460 |
halfdeadPtr = halfdeadPtr->nextPtr; |
| 1461 |
} |
| 1462 |
if (halfdeadPtr == NULL) |
| 1463 |
panic("window not found on half dead list"); |
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
if (winPtr->flags & TK_WIN_MANAGED) { |
| 1470 |
TkWmDeadWindow(winPtr); |
| 1471 |
} else if (winPtr->flags & TK_WM_COLORMAP_WINDOW) { |
| 1472 |
TkWmRemoveFromColormapWindows(winPtr); |
| 1473 |
} |
| 1474 |
if (winPtr->window != None) { |
| 1475 |
#if defined(MAC_TCL) || defined(MAC_OSX_TK) || defined(__WIN32__) || defined(__PM__) |
| 1476 |
XDestroyWindow(winPtr->display, winPtr->window); |
| 1477 |
#else |
| 1478 |
if ((winPtr->flags & TK_TOP_HIERARCHY) |
| 1479 |
|| !(winPtr->flags & TK_DONT_DESTROY_WINDOW)) { |
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
dispPtr->lastDestroyRequest = NextRequest(winPtr->display); |
| 1489 |
XDestroyWindow(winPtr->display, winPtr->window); |
| 1490 |
} |
| 1491 |
#endif |
| 1492 |
TkFreeWindowId(dispPtr, winPtr->window); |
| 1493 |
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->winTable, |
| 1494 |
(char *) winPtr->window)); |
| 1495 |
winPtr->window = None; |
| 1496 |
} |
| 1497 |
dispPtr->destroyCount--; |
| 1498 |
UnlinkWindow(winPtr); |
| 1499 |
TkEventDeadWindow(winPtr); |
| 1500 |
TkBindDeadWindow(winPtr); |
| 1501 |
#ifdef TK_USE_INPUT_METHODS |
| 1502 |
if (winPtr->inputContext != NULL) { |
| 1503 |
XDestroyIC(winPtr->inputContext); |
| 1504 |
winPtr->inputContext = NULL; |
| 1505 |
} |
| 1506 |
#endif |
| 1507 |
if (winPtr->tagPtr != NULL) { |
| 1508 |
TkFreeBindingTags(winPtr); |
| 1509 |
} |
| 1510 |
TkOptionDeadWindow(winPtr); |
| 1511 |
TkSelDeadWindow(winPtr); |
| 1512 |
TkGrabDeadWindow(winPtr); |
| 1513 |
|
| 1514 |
|
| 1515 |
if (winPtr->mainPtr != NULL) { |
| 1516 |
if (winPtr->pathName != NULL) { |
| 1517 |
Tk_DeleteAllBindings(winPtr->mainPtr->bindingTable, |
| 1518 |
(ClientData) winPtr->pathName); |
| 1519 |
LangDeadWindow(winPtr->mainPtr->interp, (Tk_Window) winPtr); |
| 1520 |
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, |
| 1521 |
winPtr->pathName)); |
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
winPtr->pathName = NULL; |
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
winPtr->mainPtr->deletionEpoch++; |
| 1534 |
} |
| 1535 |
winPtr->mainPtr->refCount--; |
| 1536 |
if (winPtr->mainPtr->refCount == 0) { |
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
#if 1 |
| 1550 |
Lang_DeadMainWindow(winPtr->mainPtr->interp, (Tk_Window) winPtr); |
| 1551 |
Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif"); |
| 1552 |
#else |
| 1553 |
if ((winPtr->mainPtr->interp != NULL) && |
| 1554 |
(!Tcl_InterpDeleted(winPtr->mainPtr->interp))) { |
| 1555 |
for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { |
| 1556 |
Tcl_CreateCommand(winPtr->mainPtr->interp, cmdPtr->name, |
| 1557 |
TkDeadAppCmd, (ClientData) NULL, |
| 1558 |
(void (*) _ANSI_ARGS_((ClientData))) NULL); |
| 1559 |
} |
| 1560 |
Tcl_CreateCommand(winPtr->mainPtr->interp, "send", |
| 1561 |
TkDeadAppCmd, (ClientData) NULL, |
| 1562 |
(void (*) _ANSI_ARGS_((ClientData))) NULL); |
| 1563 |
Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif"); |
| 1564 |
} |
| 1565 |
|
| 1566 |
#endif |
| 1567 |
Tcl_DeleteHashTable(&winPtr->mainPtr->nameTable); |
| 1568 |
TkBindFree(winPtr->mainPtr); |
| 1569 |
|
| 1570 |
TkDeleteAllImages(winPtr->mainPtr); |
| 1571 |
TkFontPkgFree(winPtr->mainPtr); |
| 1572 |
TkFocusFree(winPtr->mainPtr); |
| 1573 |
TkStylePkgFree(winPtr->mainPtr); |
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
if (winPtr->flags & TK_EMBEDDED) { |
| 1583 |
XSync(winPtr->display, False); |
| 1584 |
} |
| 1585 |
ckfree((char *) winPtr->mainPtr); |
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
#if !defined(WIN32) && !defined(MAC_TCL) && defined(NOT_YET) |
| 1593 |
if (dispPtr->refCount <= 0) { |
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
TkDisplay *theDispPtr, *backDispPtr; |
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
|
| 1613 |
|
| 1614 |
for (theDispPtr = tsdPtr->displayList, backDispPtr = NULL; |
| 1615 |
(theDispPtr != winPtr->dispPtr) && |
| 1616 |
(theDispPtr != NULL); |
| 1617 |
theDispPtr = theDispPtr->nextPtr) { |
| 1618 |
backDispPtr = theDispPtr; |
| 1619 |
} |
| 1620 |
if (theDispPtr == NULL) { |
| 1621 |
panic("could not find display to close!"); |
| 1622 |
} |
| 1623 |
if (backDispPtr == NULL) { |
| 1624 |
tsdPtr->displayList = theDispPtr->nextPtr; |
| 1625 |
} else { |
| 1626 |
backDispPtr->nextPtr = theDispPtr->nextPtr; |
| 1627 |
} |
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
TkCloseDisplay(dispPtr); |
| 1640 |
} |
| 1641 |
#endif |
| 1642 |
} |
| 1643 |
} |
| 1644 |
Tcl_EventuallyFree((ClientData) winPtr, TCL_DYNAMIC); |
| 1645 |
} |
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
void |
| 1666 |
Tk_MapWindow(tkwin) |
| 1667 |
Tk_Window tkwin; |
| 1668 |
{ |
| 1669 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 1670 |
XEvent event; |
| 1671 |
|
| 1672 |
if (winPtr->flags & TK_MAPPED) { |
| 1673 |
return; |
| 1674 |
} |
| 1675 |
if (winPtr->window == None) { |
| 1676 |
Tk_MakeWindowExist(tkwin); |
| 1677 |
} |
| 1678 |
if (winPtr->flags & TK_WIN_MANAGED) { |
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
TkWmMapWindow(winPtr); |
| 1685 |
return; |
| 1686 |
} |
| 1687 |
winPtr->flags |= TK_MAPPED; |
| 1688 |
XMapWindow(winPtr->display, winPtr->window); |
| 1689 |
event.type = MapNotify; |
| 1690 |
event.xmap.serial = LastKnownRequestProcessed(winPtr->display); |
| 1691 |
event.xmap.send_event = False; |
| 1692 |
event.xmap.display = winPtr->display; |
| 1693 |
event.xmap.event = winPtr->window; |
| 1694 |
event.xmap.window = winPtr->window; |
| 1695 |
event.xmap.override_redirect = winPtr->atts.override_redirect; |
| 1696 |
Tk_HandleEvent(&event); |
| 1697 |
} |
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
void |
| 1721 |
Tk_MakeWindowExist(tkwin) |
| 1722 |
Tk_Window tkwin; |
| 1723 |
{ |
| 1724 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1725 |
TkWindow *winPtr2; |
| 1726 |
Window parent; |
| 1727 |
Tcl_HashEntry *hPtr; |
| 1728 |
Tk_ClassCreateProc *createProc; |
| 1729 |
int new; |
| 1730 |
|
| 1731 |
if (winPtr->window != None) { |
| 1732 |
return; |
| 1733 |
} |
| 1734 |
|
| 1735 |
if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_HIERARCHY)) { |
| 1736 |
parent = XRootWindow(winPtr->display, winPtr->screenNum); |
| 1737 |
} else { |
| 1738 |
if (winPtr->parentPtr->window == None) { |
| 1739 |
Tk_MakeWindowExist((Tk_Window) winPtr->parentPtr); |
| 1740 |
} |
| 1741 |
parent = winPtr->parentPtr->window; |
| 1742 |
} |
| 1743 |
|
| 1744 |
createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc); |
| 1745 |
if (createProc != NULL) { |
| 1746 |
winPtr->window = (*createProc)(tkwin, parent, winPtr->instanceData); |
| 1747 |
} else { |
| 1748 |
winPtr->window = TkpMakeWindow(winPtr, parent); |
| 1749 |
} |
| 1750 |
|
| 1751 |
hPtr = Tcl_CreateHashEntry(&winPtr->dispPtr->winTable, |
| 1752 |
(char *) winPtr->window, &new); |
| 1753 |
Tcl_SetHashValue(hPtr, winPtr); |
| 1754 |
winPtr->dirtyAtts = 0; |
| 1755 |
winPtr->dirtyChanges = 0; |
| 1756 |
|
| 1757 |
if (!(winPtr->flags & TK_TOP_HIERARCHY)) { |
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; |
| 1770 |
winPtr2 = winPtr2->nextPtr) { |
| 1771 |
if ((winPtr2->window != None) |
| 1772 |
&& !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { |
| 1773 |
XWindowChanges changes; |
| 1774 |
changes.sibling = winPtr2->window; |
| 1775 |
changes.stack_mode = Below; |
| 1776 |
XConfigureWindow(winPtr->display, winPtr->window, |
| 1777 |
CWSibling|CWStackMode, &changes); |
| 1778 |
break; |
| 1779 |
} |
| 1780 |
} |
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
if ((winPtr->parentPtr != NULL) && |
| 1788 |
(winPtr->atts.colormap != winPtr->parentPtr->atts.colormap)) { |
| 1789 |
TkWmAddToColormapWindows(winPtr); |
| 1790 |
winPtr->flags |= TK_WM_COLORMAP_WINDOW; |
| 1791 |
} |
| 1792 |
} |
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
if ((winPtr->flags & TK_NEED_CONFIG_NOTIFY) |
| 1802 |
&& !(winPtr->flags & TK_ALREADY_DEAD)) { |
| 1803 |
winPtr->flags &= ~TK_NEED_CONFIG_NOTIFY; |
| 1804 |
TkDoConfigureNotify(winPtr); |
| 1805 |
} |
| 1806 |
} |
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
void |
| 1830 |
Tk_UnmapWindow(tkwin) |
| 1831 |
Tk_Window tkwin; |
| 1832 |
{ |
| 1833 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1834 |
|
| 1835 |
if (!(winPtr->flags & TK_MAPPED) || (winPtr->flags & TK_ALREADY_DEAD)) { |
| 1836 |
return; |
| 1837 |
} |
| 1838 |
if (winPtr->flags & TK_WIN_MANAGED) { |
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
TkWmUnmapWindow(winPtr); |
| 1845 |
return; |
| 1846 |
} |
| 1847 |
winPtr->flags &= ~TK_MAPPED; |
| 1848 |
XUnmapWindow(winPtr->display, winPtr->window); |
| 1849 |
if (!(winPtr->flags & TK_TOP_HIERARCHY)) { |
| 1850 |
XEvent event; |
| 1851 |
|
| 1852 |
event.type = UnmapNotify; |
| 1853 |
event.xunmap.serial = LastKnownRequestProcessed(winPtr->display); |
| 1854 |
event.xunmap.send_event = False; |
| 1855 |
event.xunmap.display = winPtr->display; |
| 1856 |
event.xunmap.event = winPtr->window; |
| 1857 |
event.xunmap.window = winPtr->window; |
| 1858 |
event.xunmap.from_configure = False; |
| 1859 |
Tk_HandleEvent(&event); |
| 1860 |
} |
| 1861 |
} |
| 1862 |
|
| 1863 |
void |
| 1864 |
Tk_ConfigureWindow(tkwin, valueMask, valuePtr) |
| 1865 |
Tk_Window tkwin; |
| 1866 |
unsigned int valueMask; |
| 1867 |
|
| 1868 |
XWindowChanges *valuePtr; |
| 1869 |
{ |
| 1870 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1871 |
|
| 1872 |
if (valueMask & CWX) { |
| 1873 |
winPtr->changes.x = valuePtr->x; |
| 1874 |
} |
| 1875 |
if (valueMask & CWY) { |
| 1876 |
winPtr->changes.y = valuePtr->y; |
| 1877 |
} |
| 1878 |
if (valueMask & CWWidth) { |
| 1879 |
winPtr->changes.width = valuePtr->width; |
| 1880 |
} |
| 1881 |
if (valueMask & CWHeight) { |
| 1882 |
winPtr->changes.height = valuePtr->height; |
| 1883 |
} |
| 1884 |
if (valueMask & CWBorderWidth) { |
| 1885 |
winPtr->changes.border_width = valuePtr->border_width; |
| 1886 |
} |
| 1887 |
if (valueMask & (CWSibling|CWStackMode)) { |
| 1888 |
panic("Can't set sibling or stack mode from Tk_ConfigureWindow."); |
| 1889 |
} |
| 1890 |
|
| 1891 |
if (winPtr->window != None) { |
| 1892 |
XConfigureWindow(winPtr->display, winPtr->window, |
| 1893 |
valueMask, valuePtr); |
| 1894 |
TkDoConfigureNotify(winPtr); |
| 1895 |
} else { |
| 1896 |
winPtr->dirtyChanges |= valueMask; |
| 1897 |
winPtr->flags |= TK_NEED_CONFIG_NOTIFY; |
| 1898 |
} |
| 1899 |
} |
| 1900 |
|
| 1901 |
void |
| 1902 |
Tk_MoveWindow(tkwin, x, y) |
| 1903 |
Tk_Window tkwin; |
| 1904 |
int x, y; |
| 1905 |
|
| 1906 |
{ |
| 1907 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1908 |
|
| 1909 |
winPtr->changes.x = x; |
| 1910 |
winPtr->changes.y = y; |
| 1911 |
if (winPtr->window != None) { |
| 1912 |
XMoveWindow(winPtr->display, winPtr->window, x, y); |
| 1913 |
TkDoConfigureNotify(winPtr); |
| 1914 |
} else { |
| 1915 |
winPtr->dirtyChanges |= CWX|CWY; |
| 1916 |
winPtr->flags |= TK_NEED_CONFIG_NOTIFY; |
| 1917 |
} |
| 1918 |
} |
| 1919 |
|
| 1920 |
void |
| 1921 |
Tk_ResizeWindow(tkwin, width, height) |
| 1922 |
Tk_Window tkwin; |
| 1923 |
int width, height; |
| 1924 |
{ |
| 1925 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1926 |
|
| 1927 |
winPtr->changes.width = (unsigned) width; |
| 1928 |
winPtr->changes.height = (unsigned) height; |
| 1929 |
if (winPtr->window != None) { |
| 1930 |
XResizeWindow(winPtr->display, winPtr->window, (unsigned) width, |
| 1931 |
(unsigned) height); |
| 1932 |
TkDoConfigureNotify(winPtr); |
| 1933 |
} else { |
| 1934 |
winPtr->dirtyChanges |= CWWidth|CWHeight; |
| 1935 |
winPtr->flags |= TK_NEED_CONFIG_NOTIFY; |
| 1936 |
} |
| 1937 |
} |
| 1938 |
|
| 1939 |
void |
| 1940 |
Tk_MoveResizeWindow(tkwin, x, y, width, height) |
| 1941 |
Tk_Window tkwin; |
| 1942 |
int x, y; |
| 1943 |
|
| 1944 |
int width, height; |
| 1945 |
{ |
| 1946 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1947 |
|
| 1948 |
winPtr->changes.x = x; |
| 1949 |
winPtr->changes.y = y; |
| 1950 |
winPtr->changes.width = (unsigned) width; |
| 1951 |
winPtr->changes.height = (unsigned) height; |
| 1952 |
if (winPtr->window != None) { |
| 1953 |
XMoveResizeWindow(winPtr->display, winPtr->window, x, y, |
| 1954 |
(unsigned) width, (unsigned) height); |
| 1955 |
TkDoConfigureNotify(winPtr); |
| 1956 |
} else { |
| 1957 |
winPtr->dirtyChanges |= CWX|CWY|CWWidth|CWHeight; |
| 1958 |
winPtr->flags |= TK_NEED_CONFIG_NOTIFY; |
| 1959 |
} |
| 1960 |
} |
| 1961 |
|
| 1962 |
void |
| 1963 |
Tk_SetWindowBorderWidth(tkwin, width) |
| 1964 |
Tk_Window tkwin; |
| 1965 |
int width; |
| 1966 |
{ |
| 1967 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1968 |
|
| 1969 |
winPtr->changes.border_width = width; |
| 1970 |
if (winPtr->window != None) { |
| 1971 |
XSetWindowBorderWidth(winPtr->display, winPtr->window, |
| 1972 |
(unsigned) width); |
| 1973 |
TkDoConfigureNotify(winPtr); |
| 1974 |
} else { |
| 1975 |
winPtr->dirtyChanges |= CWBorderWidth; |
| 1976 |
winPtr->flags |= TK_NEED_CONFIG_NOTIFY; |
| 1977 |
} |
| 1978 |
} |
| 1979 |
|
| 1980 |
void |
| 1981 |
Tk_ChangeWindowAttributes(tkwin, valueMask, attsPtr) |
| 1982 |
Tk_Window tkwin; |
| 1983 |
unsigned long valueMask; |
| 1984 |
|
| 1985 |
|
| 1986 |
register XSetWindowAttributes *attsPtr; |
| 1987 |
|
| 1988 |
{ |
| 1989 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 1990 |
|
| 1991 |
if (valueMask & CWBackPixmap) { |
| 1992 |
winPtr->atts.background_pixmap = attsPtr->background_pixmap; |
| 1993 |
} |
| 1994 |
if (valueMask & CWBackPixel) { |
| 1995 |
winPtr->atts.background_pixel = attsPtr->background_pixel; |
| 1996 |
} |
| 1997 |
if (valueMask & CWBorderPixmap) { |
| 1998 |
winPtr->atts.border_pixmap = attsPtr->border_pixmap; |
| 1999 |
} |
| 2000 |
if (valueMask & CWBorderPixel) { |
| 2001 |
winPtr->atts.border_pixel = attsPtr->border_pixel; |
| 2002 |
} |
| 2003 |
if (valueMask & CWBitGravity) { |
| 2004 |
winPtr->atts.bit_gravity = attsPtr->bit_gravity; |
| 2005 |
} |
| 2006 |
if (valueMask & CWWinGravity) { |
| 2007 |
winPtr->atts.win_gravity = attsPtr->win_gravity; |
| 2008 |
} |
| 2009 |
if (valueMask & CWBackingStore) { |
| 2010 |
winPtr->atts.backing_store = attsPtr->backing_store; |
| 2011 |
} |
| 2012 |
if (valueMask & CWBackingPlanes) { |
| 2013 |
winPtr->atts.backing_planes = attsPtr->backing_planes; |
| 2014 |
} |
| 2015 |
if (valueMask & CWBackingPixel) { |
| 2016 |
winPtr->atts.backing_pixel = attsPtr->backing_pixel; |
| 2017 |
} |
| 2018 |
if (valueMask & CWOverrideRedirect) { |
| 2019 |
winPtr->atts.override_redirect = attsPtr->override_redirect; |
| 2020 |
} |
| 2021 |
if (valueMask & CWSaveUnder) { |
| 2022 |
winPtr->atts.save_under = attsPtr->save_under; |
| 2023 |
} |
| 2024 |
if (valueMask & CWEventMask) { |
| 2025 |
winPtr->atts.event_mask = attsPtr->event_mask; |
| 2026 |
} |
| 2027 |
if (valueMask & CWDontPropagate) { |
| 2028 |
winPtr->atts.do_not_propagate_mask |
| 2029 |
= attsPtr->do_not_propagate_mask; |
| 2030 |
} |
| 2031 |
if (valueMask & CWColormap) { |
| 2032 |
winPtr->atts.colormap = attsPtr->colormap; |
| 2033 |
} |
| 2034 |
if (valueMask & CWCursor) { |
| 2035 |
winPtr->atts.cursor = attsPtr->cursor; |
| 2036 |
} |
| 2037 |
|
| 2038 |
if (winPtr->window != None) { |
| 2039 |
XChangeWindowAttributes(winPtr->display, winPtr->window, |
| 2040 |
valueMask, attsPtr); |
| 2041 |
} else { |
| 2042 |
winPtr->dirtyAtts |= valueMask; |
| 2043 |
} |
| 2044 |
} |
| 2045 |
|
| 2046 |
void |
| 2047 |
Tk_SetWindowBackground(tkwin, pixel) |
| 2048 |
Tk_Window tkwin; |
| 2049 |
unsigned long pixel; |
| 2050 |
|
| 2051 |
{ |
| 2052 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2053 |
|
| 2054 |
winPtr->atts.background_pixel = pixel; |
| 2055 |
|
| 2056 |
if (winPtr->window != None) { |
| 2057 |
XSetWindowBackground(winPtr->display, winPtr->window, pixel); |
| 2058 |
} else { |
| 2059 |
winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBackPixmap) |
| 2060 |
| CWBackPixel; |
| 2061 |
} |
| 2062 |
} |
| 2063 |
|
| 2064 |
void |
| 2065 |
Tk_SetWindowBackgroundPixmap(tkwin, pixmap) |
| 2066 |
Tk_Window tkwin; |
| 2067 |
Pixmap pixmap; |
| 2068 |
|
| 2069 |
{ |
| 2070 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2071 |
|
| 2072 |
winPtr->atts.background_pixmap = pixmap; |
| 2073 |
|
| 2074 |
if (winPtr->window != None) { |
| 2075 |
XSetWindowBackgroundPixmap(winPtr->display, |
| 2076 |
winPtr->window, pixmap); |
| 2077 |
} else { |
| 2078 |
winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBackPixel) |
| 2079 |
| CWBackPixmap; |
| 2080 |
} |
| 2081 |
} |
| 2082 |
|
| 2083 |
void |
| 2084 |
Tk_SetWindowBorder(tkwin, pixel) |
| 2085 |
Tk_Window tkwin; |
| 2086 |
unsigned long pixel; |
| 2087 |
|
| 2088 |
{ |
| 2089 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2090 |
|
| 2091 |
winPtr->atts.border_pixel = pixel; |
| 2092 |
|
| 2093 |
if (winPtr->window != None) { |
| 2094 |
XSetWindowBorder(winPtr->display, winPtr->window, pixel); |
| 2095 |
} else { |
| 2096 |
winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBorderPixmap) |
| 2097 |
| CWBorderPixel; |
| 2098 |
} |
| 2099 |
} |
| 2100 |
|
| 2101 |
void |
| 2102 |
Tk_SetWindowBorderPixmap(tkwin, pixmap) |
| 2103 |
Tk_Window tkwin; |
| 2104 |
Pixmap pixmap; |
| 2105 |
|
| 2106 |
{ |
| 2107 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2108 |
|
| 2109 |
winPtr->atts.border_pixmap = pixmap; |
| 2110 |
|
| 2111 |
if (winPtr->window != None) { |
| 2112 |
XSetWindowBorderPixmap(winPtr->display, |
| 2113 |
winPtr->window, pixmap); |
| 2114 |
} else { |
| 2115 |
winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBorderPixel) |
| 2116 |
| CWBorderPixmap; |
| 2117 |
} |
| 2118 |
} |
| 2119 |
|
| 2120 |
void |
| 2121 |
Tk_DefineCursor(tkwin, cursor) |
| 2122 |
Tk_Window tkwin; |
| 2123 |
Tk_Cursor cursor; |
| 2124 |
{ |
| 2125 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2126 |
|
| 2127 |
#if defined(MAC_TCL) || defined(MAC_OSX_TK) |
| 2128 |
winPtr->atts.cursor = (XCursor) cursor; |
| 2129 |
#else |
| 2130 |
winPtr->atts.cursor = (Cursor) cursor; |
| 2131 |
#endif |
| 2132 |
|
| 2133 |
if (winPtr->window != None) { |
| 2134 |
XDefineCursor(winPtr->display, winPtr->window, winPtr->atts.cursor); |
| 2135 |
} else { |
| 2136 |
winPtr->dirtyAtts = winPtr->dirtyAtts | CWCursor; |
| 2137 |
} |
| 2138 |
} |
| 2139 |
|
| 2140 |
void |
| 2141 |
Tk_UndefineCursor(tkwin) |
| 2142 |
Tk_Window tkwin; |
| 2143 |
{ |
| 2144 |
Tk_DefineCursor(tkwin, None); |
| 2145 |
} |
| 2146 |
|
| 2147 |
void |
| 2148 |
Tk_SetWindowColormap(tkwin, colormap) |
| 2149 |
Tk_Window tkwin; |
| 2150 |
Colormap colormap; |
| 2151 |
{ |
| 2152 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2153 |
|
| 2154 |
winPtr->atts.colormap = colormap; |
| 2155 |
|
| 2156 |
if (winPtr->window != None) { |
| 2157 |
XSetWindowColormap(winPtr->display, winPtr->window, colormap); |
| 2158 |
if (!(winPtr->flags & TK_WIN_MANAGED)) { |
| 2159 |
TkWmAddToColormapWindows(winPtr); |
| 2160 |
winPtr->flags |= TK_WM_COLORMAP_WINDOW; |
| 2161 |
} |
| 2162 |
} else { |
| 2163 |
winPtr->dirtyAtts |= CWColormap; |
| 2164 |
} |
| 2165 |
} |
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
|
| 2178 |
|
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
|
| 2183 |
|
| 2184 |
|
| 2185 |
|
| 2186 |
|
| 2187 |
int |
| 2188 |
Tk_SetWindowVisual(tkwin, visual, depth, colormap) |
| 2189 |
Tk_Window tkwin; |
| 2190 |
Visual *visual; |
| 2191 |
int depth; |
| 2192 |
Colormap colormap; |
| 2193 |
{ |
| 2194 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2195 |
|
| 2196 |
if( winPtr->window != None ){ |
| 2197 |
|
| 2198 |
return 0; |
| 2199 |
} |
| 2200 |
|
| 2201 |
winPtr->visual = visual; |
| 2202 |
winPtr->depth = depth; |
| 2203 |
winPtr->atts.colormap = colormap; |
| 2204 |
winPtr->dirtyAtts |= CWColormap; |
| 2205 |
|
| 2206 |
|
| 2207 |
|
| 2208 |
|
| 2209 |
|
| 2210 |
|
| 2211 |
|
| 2212 |
if (!(winPtr->dirtyAtts & CWBorderPixmap)) { |
| 2213 |
winPtr->dirtyAtts |= CWBorderPixel; |
| 2214 |
} |
| 2215 |
return 1; |
| 2216 |
} |
| 2217 |
|
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
void |
| 2236 |
TkDoConfigureNotify(winPtr) |
| 2237 |
register TkWindow *winPtr; |
| 2238 |
|
| 2239 |
{ |
| 2240 |
XEvent event; |
| 2241 |
|
| 2242 |
event.type = ConfigureNotify; |
| 2243 |
event.xconfigure.serial = LastKnownRequestProcessed(winPtr->display); |
| 2244 |
event.xconfigure.send_event = False; |
| 2245 |
event.xconfigure.display = winPtr->display; |
| 2246 |
event.xconfigure.event = winPtr->window; |
| 2247 |
event.xconfigure.window = winPtr->window; |
| 2248 |
event.xconfigure.x = winPtr->changes.x; |
| 2249 |
event.xconfigure.y = winPtr->changes.y; |
| 2250 |
event.xconfigure.width = winPtr->changes.width; |
| 2251 |
event.xconfigure.height = winPtr->changes.height; |
| 2252 |
event.xconfigure.border_width = winPtr->changes.border_width; |
| 2253 |
if (winPtr->changes.stack_mode == Above) { |
| 2254 |
event.xconfigure.above = winPtr->changes.sibling; |
| 2255 |
} else { |
| 2256 |
event.xconfigure.above = None; |
| 2257 |
} |
| 2258 |
event.xconfigure.override_redirect = winPtr->atts.override_redirect; |
| 2259 |
Tk_HandleEvent(&event); |
| 2260 |
} |
| 2261 |
|
| 2262 |
|
| 2263 |
|
| 2264 |
|
| 2265 |
|
| 2266 |
|
| 2267 |
|
| 2268 |
|
| 2269 |
|
| 2270 |
|
| 2271 |
|
| 2272 |
|
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
|
| 2277 |
|
| 2278 |
|
| 2279 |
void |
| 2280 |
Tk_SetClass(tkwin, className) |
| 2281 |
Tk_Window tkwin; |
| 2282 |
CONST char *className; |
| 2283 |
{ |
| 2284 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2285 |
|
| 2286 |
winPtr->classUid = Tk_GetUid(className); |
| 2287 |
if (winPtr->flags & TK_WIN_MANAGED) { |
| 2288 |
TkWmSetClass(winPtr); |
| 2289 |
} |
| 2290 |
TkOptionClassChanged(winPtr); |
| 2291 |
} |
| 2292 |
|
| 2293 |
|
| 2294 |
|
| 2295 |
|
| 2296 |
|
| 2297 |
|
| 2298 |
|
| 2299 |
|
| 2300 |
|
| 2301 |
|
| 2302 |
|
| 2303 |
|
| 2304 |
|
| 2305 |
|
| 2306 |
|
| 2307 |
|
| 2308 |
|
| 2309 |
|
| 2310 |
|
| 2311 |
void |
| 2312 |
Tk_SetClassProcs(tkwin, procs, instanceData) |
| 2313 |
Tk_Window tkwin; |
| 2314 |
Tk_ClassProcs *procs; |
| 2315 |
ClientData instanceData; |
| 2316 |
{ |
| 2317 |
register TkWindow *winPtr = (TkWindow *) tkwin; |
| 2318 |
|
| 2319 |
winPtr->classProcsPtr = procs; |
| 2320 |
winPtr->instanceData = instanceData; |
| 2321 |
} |
| 2322 |
|
| 2323 |
|
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
|
| 2329 |
|
| 2330 |
|
| 2331 |
|
| 2332 |
|
| 2333 |
|
| 2334 |
|
| 2335 |
|
| 2336 |
|
| 2337 |
|
| 2338 |
|
| 2339 |
|
| 2340 |
|
| 2341 |
|
| 2342 |
|
| 2343 |
Tk_Window |
| 2344 |
Tk_NameToWindow(interp, pathName, tkwin) |
| 2345 |
Tcl_Interp *interp; |
| 2346 |
CONST char *pathName; |
| 2347 |
Tk_Window tkwin; |
| 2348 |
|
| 2349 |
{ |
| 2350 |
Tcl_HashEntry *hPtr; |
| 2351 |
|
| 2352 |
if (tkwin == NULL) { |
| 2353 |
|
| 2354 |
|
| 2355 |
|
| 2356 |
|
| 2357 |
Tcl_AppendResult(interp, "NULL main window", (char *)NULL); |
| 2358 |
return NULL; |
| 2359 |
} |
| 2360 |
|
| 2361 |
hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->nameTable, |
| 2362 |
pathName); |
| 2363 |
if (hPtr == NULL) { |
| 2364 |
Tcl_AppendResult(interp, "bad window path name \"", |
| 2365 |
pathName, "\"", (char *) NULL); |
| 2366 |
return NULL; |
| 2367 |
} |
| 2368 |
return (Tk_Window) Tcl_GetHashValue(hPtr); |
| 2369 |
} |
| 2370 |
|
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
|
| 2377 |
|
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
|
| 2388 |
|
| 2389 |
|
| 2390 |
|
| 2391 |
Tk_Window |
| 2392 |
Tk_IdToWindow(display, window) |
| 2393 |
Display *display; |
| 2394 |
Window window; |
| 2395 |
{ |
| 2396 |
TkDisplay *dispPtr; |
| 2397 |
Tcl_HashEntry *hPtr; |
| 2398 |
|
| 2399 |
for (dispPtr = TkGetDisplayList(); ; dispPtr = dispPtr->nextPtr) { |
| 2400 |
if (dispPtr == NULL) { |
| 2401 |
return NULL; |
| 2402 |
} |
| 2403 |
if (dispPtr->display == display) { |
| 2404 |
break; |
| 2405 |
} |
| 2406 |
} |
| 2407 |
|
| 2408 |
hPtr = Tcl_FindHashEntry(&dispPtr->winTable, (char *) window); |
| 2409 |
if (hPtr == NULL) { |
| 2410 |
return NULL; |
| 2411 |
} |
| 2412 |
return (Tk_Window) Tcl_GetHashValue(hPtr); |
| 2413 |
} |
| 2414 |
|
| 2415 |
|
| 2416 |
|
| 2417 |
|
| 2418 |
|
| 2419 |
|
| 2420 |
|
| 2421 |
|
| 2422 |
|
| 2423 |
|
| 2424 |
|
| 2425 |
|
| 2426 |
|
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
|
| 2431 |
|
| 2432 |
CONST char * |
| 2433 |
Tk_DisplayName(tkwin) |
| 2434 |
Tk_Window tkwin; |
| 2435 |
{ |
| 2436 |
return ((TkWindow *) tkwin)->dispPtr->name; |
| 2437 |
} |
| 2438 |
|
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
|
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
static void |
| 2457 |
UnlinkWindow(winPtr) |
| 2458 |
TkWindow *winPtr; |
| 2459 |
{ |
| 2460 |
TkWindow *prevPtr; |
| 2461 |
|
| 2462 |
if (winPtr->parentPtr == NULL) { |
| 2463 |
return; |
| 2464 |
} |
| 2465 |
prevPtr = winPtr->parentPtr->childList; |
| 2466 |
if (prevPtr == winPtr) { |
| 2467 |
winPtr->parentPtr->childList = winPtr->nextPtr; |
| 2468 |
if (winPtr->nextPtr == NULL) { |
| 2469 |
winPtr->parentPtr->lastChildPtr = NULL; |
| 2470 |
} |
| 2471 |
} else { |
| 2472 |
while (prevPtr->nextPtr != winPtr) { |
| 2473 |
prevPtr = prevPtr->nextPtr; |
| 2474 |
if (prevPtr == NULL) { |
| 2475 |
panic("UnlinkWindow couldn't find child in parent"); |
| 2476 |
} |
| 2477 |
} |
| 2478 |
prevPtr->nextPtr = winPtr->nextPtr; |
| 2479 |
if (winPtr->nextPtr == NULL) { |
| 2480 |
winPtr->parentPtr->lastChildPtr = prevPtr; |
| 2481 |
} |
| 2482 |
} |
| 2483 |
} |
| 2484 |
|
| 2485 |
|
| 2486 |
|
| 2487 |
|
| 2488 |
|
| 2489 |
|
| 2490 |
|
| 2491 |
|
| 2492 |
|
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
|
| 2501 |
|
| 2502 |
|
| 2503 |
int |
| 2504 |
Tk_RestackWindow(tkwin, aboveBelow, other) |
| 2505 |
Tk_Window tkwin; |
| 2506 |
|
| 2507 |
int aboveBelow; |
| 2508 |
|
| 2509 |
Tk_Window other; |
| 2510 |
|
| 2511 |
|
| 2512 |
|
| 2513 |
{ |
| 2514 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 2515 |
TkWindow *otherPtr = (TkWindow *) other; |
| 2516 |
|
| 2517 |
|
| 2518 |
|
| 2519 |
|
| 2520 |
|
| 2521 |
|
| 2522 |
|
| 2523 |
if (winPtr->flags & TK_WIN_MANAGED) { |
| 2524 |
while ((otherPtr != NULL) && !(otherPtr->flags & TK_TOP_HIERARCHY)) { |
| 2525 |
otherPtr = otherPtr->parentPtr; |
| 2526 |
} |
| 2527 |
TkWmRestackToplevel(winPtr, aboveBelow, otherPtr); |
| 2528 |
return TCL_OK; |
| 2529 |
} |
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
if (winPtr->parentPtr == NULL) { |
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
|
| 2540 |
return TCL_OK; |
| 2541 |
} |
| 2542 |
if (otherPtr == NULL) { |
| 2543 |
if (aboveBelow == Above) { |
| 2544 |
otherPtr = winPtr->parentPtr->lastChildPtr; |
| 2545 |
} else { |
| 2546 |
otherPtr = winPtr->parentPtr->childList; |
| 2547 |
} |
| 2548 |
} else { |
| 2549 |
while (winPtr->parentPtr != otherPtr->parentPtr) { |
| 2550 |
if ((otherPtr == NULL) || (otherPtr->flags & TK_TOP_HIERARCHY)) { |
| 2551 |
return TCL_ERROR; |
| 2552 |
} |
| 2553 |
otherPtr = otherPtr->parentPtr; |
| 2554 |
} |
| 2555 |
} |
| 2556 |
if (otherPtr == winPtr) { |
| 2557 |
return TCL_OK; |
| 2558 |
} |
| 2559 |
|
| 2560 |
|
| 2561 |
|
| 2562 |
|
| 2563 |
|
| 2564 |
UnlinkWindow(winPtr); |
| 2565 |
if (aboveBelow == Above) { |
| 2566 |
winPtr->nextPtr = otherPtr->nextPtr; |
| 2567 |
if (winPtr->nextPtr == NULL) { |
| 2568 |
winPtr->parentPtr->lastChildPtr = winPtr; |
| 2569 |
} |
| 2570 |
otherPtr->nextPtr = winPtr; |
| 2571 |
} else { |
| 2572 |
TkWindow *prevPtr; |
| 2573 |
|
| 2574 |
prevPtr = winPtr->parentPtr->childList; |
| 2575 |
if (prevPtr == otherPtr) { |
| 2576 |
winPtr->parentPtr->childList = winPtr; |
| 2577 |
} else { |
| 2578 |
while (prevPtr->nextPtr != otherPtr) { |
| 2579 |
prevPtr = prevPtr->nextPtr; |
| 2580 |
} |
| 2581 |
prevPtr->nextPtr = winPtr; |
| 2582 |
} |
| 2583 |
winPtr->nextPtr = otherPtr; |
| 2584 |
} |
| 2585 |
|
| 2586 |
|
| 2587 |
|
| 2588 |
|
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
if (winPtr->window != None) { |
| 2594 |
XWindowChanges changes; |
| 2595 |
unsigned int mask; |
| 2596 |
|
| 2597 |
mask = CWStackMode; |
| 2598 |
changes.stack_mode = Above; |
| 2599 |
for (otherPtr = winPtr->nextPtr; otherPtr != NULL; |
| 2600 |
otherPtr = otherPtr->nextPtr) { |
| 2601 |
if ((otherPtr->window != None) |
| 2602 |
&& !(otherPtr->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))){ |
| 2603 |
changes.sibling = otherPtr->window; |
| 2604 |
changes.stack_mode = Below; |
| 2605 |
mask = CWStackMode|CWSibling; |
| 2606 |
break; |
| 2607 |
} |
| 2608 |
} |
| 2609 |
XConfigureWindow(winPtr->display, winPtr->window, mask, &changes); |
| 2610 |
} |
| 2611 |
return TCL_OK; |
| 2612 |
} |
| 2613 |
|
| 2614 |
|
| 2615 |
#if 0 |
| 2616 |
|
| 2617 |
|
| 2618 |
|
| 2619 |
|
| 2620 |
|
| 2621 |
|
| 2622 |
|
| 2623 |
|
| 2624 |
|
| 2625 |
|
| 2626 |
|
| 2627 |
|
| 2628 |
|
| 2629 |
|
| 2630 |
|
| 2631 |
|
| 2632 |
|
| 2633 |
|
| 2634 |
|
| 2635 |
|
| 2636 |
int |
| 2637 |
Tk_Init(interp) |
| 2638 |
Tcl_Interp *interp; |
| 2639 |
{ |
| 2640 |
static char initCmd[] = |
| 2641 |
"if [file exists $tk_library/tk.tcl] {\n\ |
| 2642 |
source $tk_library/tk.tcl\n\ |
| 2643 |
} else {\n\ |
| 2644 |
set msg \"can't find $tk_library/tk.tcl; perhaps you \"\n\ |
| 2645 |
append msg \"need to\\ninstall Tk or set your TK_LIBRARY \"\n\ |
| 2646 |
append msg \"environment variable?\"\n\ |
| 2647 |
error $msg\n\ |
| 2648 |
}"; |
| 2649 |
|
| 2650 |
return Tcl_Eval(interp, initCmd); |
| 2651 |
} |
| 2652 |
|
| 2653 |
|
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
Tk_Window |
| 2672 |
Tk_MainWindow(interp) |
| 2673 |
Tcl_Interp *interp; |
| 2674 |
|
| 2675 |
|
| 2676 |
{ |
| 2677 |
TkMainInfo *mainPtr; |
| 2678 |
ThreadSpecificData *tsdPtr; |
| 2679 |
|
| 2680 |
if (interp == NULL) { |
| 2681 |
return NULL; |
| 2682 |
} |
| 2683 |
#ifdef USE_TCL_STUBS |
| 2684 |
if (tclStubsPtr == NULL) { |
| 2685 |
return NULL; |
| 2686 |
} |
| 2687 |
#endif |
| 2688 |
tsdPtr = (ThreadSpecificData *) |
| 2689 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 2690 |
|
| 2691 |
for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL; |
| 2692 |
mainPtr = mainPtr->nextPtr) { |
| 2693 |
if (mainPtr->interp == interp) { |
| 2694 |
return (Tk_Window) mainPtr->winPtr; |
| 2695 |
} |
| 2696 |
} |
| 2697 |
Tcl_SetResult(interp, "this isn't a Tk application", TCL_STATIC); |
| 2698 |
return NULL; |
| 2699 |
} |
| 2700 |
|
| 2701 |
#endif |
| 2702 |
|
| 2703 |
|
| 2704 |
|
| 2705 |
|
| 2706 |
|
| 2707 |
|
| 2708 |
|
| 2709 |
|
| 2710 |
|
| 2711 |
|
| 2712 |
|
| 2713 |
|
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
|
| 2719 |
|
| 2720 |
|
| 2721 |
|
| 2722 |
|
| 2723 |
int |
| 2724 |
Tk_StrictMotif(tkwin) |
| 2725 |
Tk_Window tkwin; |
| 2726 |
|
| 2727 |
{ |
| 2728 |
return ((TkWindow *) tkwin)->mainPtr->strictMotif; |
| 2729 |
} |
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
|
| 2739 |
|
| 2740 |
|
| 2741 |
|
| 2742 |
|
| 2743 |
|
| 2744 |
|
| 2745 |
|
| 2746 |
|
| 2747 |
|
| 2748 |
int |
| 2749 |
Tk_GetNumMainWindows() |
| 2750 |
{ |
| 2751 |
ThreadSpecificData *tsdPtr; |
| 2752 |
|
| 2753 |
#ifdef USE_TCL_STUBS |
| 2754 |
if (tclStubsPtr == NULL) { |
| 2755 |
return 0; |
| 2756 |
} |
| 2757 |
#endif |
| 2758 |
|
| 2759 |
tsdPtr = (ThreadSpecificData *) |
| 2760 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 2761 |
|
| 2762 |
return tsdPtr->numMainWindows; |
| 2763 |
} |
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
|
| 2769 |
|
| 2770 |
|
| 2771 |
|
| 2772 |
|
| 2773 |
|
| 2774 |
|
| 2775 |
|
| 2776 |
|
| 2777 |
|
| 2778 |
|
| 2779 |
|
| 2780 |
|
| 2781 |
|
| 2782 |
|
| 2783 |
|
| 2784 |
|
| 2785 |
static void |
| 2786 |
DeleteWindowsExitProc(clientData) |
| 2787 |
ClientData clientData; |
| 2788 |
{ |
| 2789 |
TkDisplay *dispPtr, *nextPtr; |
| 2790 |
Tcl_Interp *interp; |
| 2791 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 2792 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 2793 |
|
| 2794 |
|
| 2795 |
|
| 2796 |
|
| 2797 |
|
| 2798 |
|
| 2799 |
|
| 2800 |
|
| 2801 |
|
| 2802 |
|
| 2803 |
|
| 2804 |
while (tsdPtr->halfdeadWindowList != NULL) { |
| 2805 |
interp = tsdPtr->halfdeadWindowList->winPtr->mainPtr->interp; |
| 2806 |
Tcl_Preserve((ClientData) interp); |
| 2807 |
tsdPtr->halfdeadWindowList->flags |= HD_CLEANUP; |
| 2808 |
tsdPtr->halfdeadWindowList->winPtr->flags &= ~TK_ALREADY_DEAD; |
| 2809 |
Tk_DestroyWindow((Tk_Window) tsdPtr->halfdeadWindowList->winPtr); |
| 2810 |
Tcl_Release((ClientData) interp); |
| 2811 |
} |
| 2812 |
|
| 2813 |
|
| 2814 |
|
| 2815 |
|
| 2816 |
|
| 2817 |
while (tsdPtr->mainWindowList != NULL) { |
| 2818 |
interp = tsdPtr->mainWindowList->interp; |
| 2819 |
Tcl_Preserve((ClientData) interp); |
| 2820 |
Tk_DestroyWindow((Tk_Window) tsdPtr->mainWindowList->winPtr); |
| 2821 |
Tcl_Release((ClientData) interp); |
| 2822 |
} |
| 2823 |
|
| 2824 |
|
| 2825 |
|
| 2826 |
|
| 2827 |
|
| 2828 |
|
| 2829 |
|
| 2830 |
|
| 2831 |
for (dispPtr = tsdPtr->displayList; |
| 2832 |
dispPtr != NULL; |
| 2833 |
dispPtr = tsdPtr->displayList) { |
| 2834 |
|
| 2835 |
|
| 2836 |
|
| 2837 |
|
| 2838 |
|
| 2839 |
|
| 2840 |
|
| 2841 |
|
| 2842 |
|
| 2843 |
for (tsdPtr->displayList = NULL; dispPtr != NULL; |
| 2844 |
dispPtr = nextPtr) { |
| 2845 |
nextPtr = dispPtr->nextPtr; |
| 2846 |
TkCloseDisplay(dispPtr); |
| 2847 |
} |
| 2848 |
} |
| 2849 |
|
| 2850 |
tsdPtr->numMainWindows = 0; |
| 2851 |
tsdPtr->mainWindowList = NULL; |
| 2852 |
tsdPtr->initialized = 0; |
| 2853 |
} |
| 2854 |
|
| 2855 |
#if 0 |
| 2856 |
|
| 2857 |
|
| 2858 |
|
| 2859 |
|
| 2860 |
|
| 2861 |
|
| 2862 |
|
| 2863 |
|
| 2864 |
|
| 2865 |
|
| 2866 |
|
| 2867 |
|
| 2868 |
|
| 2869 |
|
| 2870 |
|
| 2871 |
|
| 2872 |
|
| 2873 |
|
| 2874 |
|
| 2875 |
|
| 2876 |
|
| 2877 |
|
| 2878 |
|
| 2879 |
|
| 2880 |
int |
| 2881 |
Tk_Init(interp) |
| 2882 |
Tcl_Interp *interp; |
| 2883 |
{ |
| 2884 |
return Initialize(interp); |
| 2885 |
} |
| 2886 |
|
| 2887 |
|
| 2888 |
|
| 2889 |
|
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
|
| 2895 |
|
| 2896 |
|
| 2897 |
|
| 2898 |
|
| 2899 |
|
| 2900 |
|
| 2901 |
|
| 2902 |
|
| 2903 |
|
| 2904 |
|
| 2905 |
int |
| 2906 |
Tk_SafeInit(interp) |
| 2907 |
Tcl_Interp *interp; |
| 2908 |
{ |
| 2909 |
|
| 2910 |
|
| 2911 |
|
| 2912 |
|
| 2913 |
|
| 2914 |
|
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
|
| 2926 |
|
| 2927 |
|
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
|
| 2933 |
|
| 2934 |
|
| 2935 |
|
| 2936 |
|
| 2937 |
|
| 2938 |
|
| 2939 |
|
| 2940 |
|
| 2941 |
|
| 2942 |
|
| 2943 |
|
| 2944 |
|
| 2945 |
|
| 2946 |
return Initialize(interp); |
| 2947 |
} |
| 2948 |
|
| 2949 |
|
| 2950 |
extern TkStubs tkStubs; |
| 2951 |
|
| 2952 |
|
| 2953 |
|
| 2954 |
|
| 2955 |
|
| 2956 |
|
| 2957 |
|
| 2958 |
|
| 2959 |
|
| 2960 |
|
| 2961 |
|
| 2962 |
|
| 2963 |
|
| 2964 |
|
| 2965 |
|
| 2966 |
|
| 2967 |
|
| 2968 |
static int |
| 2969 |
Initialize(interp) |
| 2970 |
Tcl_Interp *interp; |
| 2971 |
{ |
| 2972 |
Var p; |
| 2973 |
int argc, code; |
| 2974 |
CONST char **argv; |
| 2975 |
char *args[20]; |
| 2976 |
CONST char *argString = NULL; |
| 2977 |
Tcl_DString class; |
| 2978 |
ThreadSpecificData *tsdPtr; |
| 2979 |
|
| 2980 |
|
| 2981 |
|
| 2982 |
|
| 2983 |
|
| 2984 |
|
| 2985 |
if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) { |
| 2986 |
return TCL_ERROR; |
| 2987 |
} |
| 2988 |
|
| 2989 |
|
| 2990 |
|
| 2991 |
|
| 2992 |
TkRegisterObjTypes(); |
| 2993 |
|
| 2994 |
tsdPtr = (ThreadSpecificData *) |
| 2995 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 2996 |
|
| 2997 |
|
| 2998 |
|
| 2999 |
|
| 3000 |
|
| 3001 |
|
| 3002 |
|
| 3003 |
Tcl_MutexLock(&windowMutex); |
| 3004 |
synchronize = 0; |
| 3005 |
name = NULL; |
| 3006 |
display = NULL; |
| 3007 |
geometry = NULL; |
| 3008 |
colormap = NULL; |
| 3009 |
use = NULL; |
| 3010 |
visual = NULL; |
| 3011 |
rest = 0; |
| 3012 |
|
| 3013 |
|
| 3014 |
|
| 3015 |
|
| 3016 |
Tcl_ResetResult(interp); |
| 3017 |
|
| 3018 |
if (Tcl_IsSafe(interp)) { |
| 3019 |
|
| 3020 |
|
| 3021 |
|
| 3022 |
|
| 3023 |
Tcl_DString ds; |
| 3024 |
|
| 3025 |
|
| 3026 |
|
| 3027 |
|
| 3028 |
|
| 3029 |
|
| 3030 |
|
| 3031 |
Tcl_Interp *master = interp; |
| 3032 |
|
| 3033 |
while (1) { |
| 3034 |
master = Tcl_GetMaster(master); |
| 3035 |
if (master == NULL) { |
| 3036 |
Tcl_AppendResult(interp, "NULL master", (char *) NULL); |
| 3037 |
Tcl_MutexUnlock(&windowMutex); |
| 3038 |
return TCL_ERROR; |
| 3039 |
} |
| 3040 |
if (!Tcl_IsSafe(master)) { |
| 3041 |
|
| 3042 |
break; |
| 3043 |
} |
| 3044 |
} |
| 3045 |
|
| 3046 |
|
| 3047 |
|
| 3048 |
if (Tcl_GetInterpPath(master, interp) != TCL_OK) { |
| 3049 |
Tcl_AppendResult(interp, "error in Tcl_GetInterpPath", |
| 3050 |
(char *) NULL); |
| 3051 |
Tcl_MutexUnlock(&windowMutex); |
| 3052 |
return TCL_ERROR; |
| 3053 |
} |
| 3054 |
|
| 3055 |
|
| 3056 |
|
| 3057 |
Tcl_DStringInit(&ds); |
| 3058 |
Tcl_DStringAppendElement(&ds, "::safe::TkInit"); |
| 3059 |
Tcl_DStringAppendElement(&ds, Tcl_GetStringResult(master)); |
| 3060 |
|
| 3061 |
|
| 3062 |
|
| 3063 |
|
| 3064 |
|
| 3065 |
|
| 3066 |
if (Tcl_Eval(master, Tcl_DStringValue(&ds)) != TCL_OK) { |
| 3067 |
|
| 3068 |
|
| 3069 |
|
| 3070 |
|
| 3071 |
Tcl_DStringFree(&ds); |
| 3072 |
Tcl_AppendResult(interp, |
| 3073 |
"not allowed to start Tk by master's safe::TkInit", |
| 3074 |
(char *) NULL); |
| 3075 |
Tcl_MutexUnlock(&windowMutex); |
| 3076 |
return TCL_ERROR; |
| 3077 |
} |
| 3078 |
Tcl_DStringFree(&ds); |
| 3079 |
|
| 3080 |
|
| 3081 |
|
| 3082 |
|
| 3083 |
|
| 3084 |
|
| 3085 |
argString = Tcl_GetStringResult(master); |
| 3086 |
} else { |
| 3087 |
|
| 3088 |
|
| 3089 |
|
| 3090 |
|
| 3091 |
|
| 3092 |
|
| 3093 |
argString = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY); |
| 3094 |
} |
| 3095 |
argv = NULL; |
| 3096 |
if (argString != NULL) { |
| 3097 |
char buffer[TCL_INTEGER_SPACE]; |
| 3098 |
|
| 3099 |
if (Tcl_SplitList(interp, argString, &argc, &argv) != TCL_OK) { |
| 3100 |
argError: |
| 3101 |
Tcl_AddErrorInfo(interp, |
| 3102 |
"\n (processing arguments in argv variable)"); |
| 3103 |
Tcl_MutexUnlock(&windowMutex); |
| 3104 |
return TCL_ERROR; |
| 3105 |
} |
| 3106 |
if (Tk_ParseArgv(interp, (Tk_Window) NULL, &argc, argv, |
| 3107 |
argTable, TK_ARGV_DONT_SKIP_FIRST_ARG|TK_ARGV_NO_DEFAULTS) |
| 3108 |
!= TCL_OK) { |
| 3109 |
ckfree((char *) argv); |
| 3110 |
goto argError; |
| 3111 |
} |
| 3112 |
p = Tcl_Merge(argc, argv); |
| 3113 |
Tcl_SetVar2(interp, "argv", (char *) NULL, p, TCL_GLOBAL_ONLY); |
| 3114 |
sprintf(buffer, "%d", argc); |
| 3115 |
Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY); |
| 3116 |
ckfree(p); |
| 3117 |
} |
| 3118 |
|
| 3119 |
|
| 3120 |
|
| 3121 |
|
| 3122 |
|
| 3123 |
Tcl_DStringInit(&class); |
| 3124 |
if (name == NULL) { |
| 3125 |
int offset; |
| 3126 |
TkpGetAppName(interp, &class); |
| 3127 |
offset = Tcl_DStringLength(&class)+1; |
| 3128 |
Tcl_DStringSetLength(&class, offset); |
| 3129 |
Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1); |
| 3130 |
name = Tcl_DStringValue(&class) + offset; |
| 3131 |
} else { |
| 3132 |
Tcl_DStringAppend(&class, name, -1); |
| 3133 |
} |
| 3134 |
|
| 3135 |
p = Tcl_DStringValue(&class); |
| 3136 |
if (*p) { |
| 3137 |
Tcl_UtfToTitle(p); |
| 3138 |
} |
| 3139 |
|
| 3140 |
|
| 3141 |
|
| 3142 |
|
| 3143 |
|
| 3144 |
|
| 3145 |
argvt[0] = "toplevel"; |
| 3146 |
argvt[1] = "."; |
| 3147 |
argvt[2] = "-class"; |
| 3148 |
argvt[3] = Tcl_DStringValue(&class); |
| 3149 |
argc = 4; |
| 3150 |
if (display != NULL) { |
| 3151 |
argvt[argc] = "-screen"; |
| 3152 |
argvt[argc+1] = display; |
| 3153 |
argc += 2; |
| 3154 |
|
| 3155 |
|
| 3156 |
|
| 3157 |
|
| 3158 |
|
| 3159 |
|
| 3160 |
|
| 3161 |
if (tsdPtr->numMainWindows == 0) { |
| 3162 |
Tcl_SetVar2(interp, "env", "DISPLAY", display, TCL_GLOBAL_ONLY); |
| 3163 |
} |
| 3164 |
} |
| 3165 |
if (colormap != NULL) { |
| 3166 |
argvt[argc] = "-colormap"; |
| 3167 |
argvt[argc+1] = colormap; |
| 3168 |
argc += 2; |
| 3169 |
colormap = NULL; |
| 3170 |
} |
| 3171 |
if (use != NULL) { |
| 3172 |
argvt[argc] = "-use"; |
| 3173 |
argvt[argc+1] = use; |
| 3174 |
argc += 2; |
| 3175 |
use = NULL; |
| 3176 |
} |
| 3177 |
if (visual != NULL) { |
| 3178 |
argvt[argc] = "-visual"; |
| 3179 |
argvt[argc+1] = visual; |
| 3180 |
argc += 2; |
| 3181 |
visual = NULL; |
| 3182 |
} |
| 3183 |
argvt[argc] = NULL; |
| 3184 |
code = TkCreateFrame((ClientData) NULL, interp, argc, argvt, 1, name); |
| 3185 |
|
| 3186 |
Tcl_DStringFree(&class); |
| 3187 |
if (code != TCL_OK) { |
| 3188 |
goto done; |
| 3189 |
} |
| 3190 |
Tcl_ResetResult(interp); |
| 3191 |
if (synchronize) { |
| 3192 |
XSynchronize(Tk_Display(Tk_MainWindow(interp)), True); |
| 3193 |
} |
| 3194 |
|
| 3195 |
|
| 3196 |
|
| 3197 |
|
| 3198 |
|
| 3199 |
|
| 3200 |
if (geometry != NULL) { |
| 3201 |
Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY); |
| 3202 |
code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL); |
| 3203 |
if (code != TCL_OK) { |
| 3204 |
goto done; |
| 3205 |
} |
| 3206 |
geometry = NULL; |
| 3207 |
} |
| 3208 |
Tcl_MutexUnlock(&windowMutex); |
| 3209 |
|
| 3210 |
if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) { |
| 3211 |
code = TCL_ERROR; |
| 3212 |
goto done; |
| 3213 |
} |
| 3214 |
|
| 3215 |
|
| 3216 |
|
| 3217 |
|
| 3218 |
|
| 3219 |
code = Tcl_PkgProvideEx(interp, "Tk", TK_VERSION, (ClientData) &tkStubs); |
| 3220 |
if (code != TCL_OK) { |
| 3221 |
goto done; |
| 3222 |
} else { |
| 3223 |
|
| 3224 |
|
| 3225 |
|
| 3226 |
|
| 3227 |
|
| 3228 |
|
| 3229 |
|
| 3230 |
|
| 3231 |
Tcl_SetMainLoop(Tk_MainLoop); |
| 3232 |
} |
| 3233 |
|
| 3234 |
#ifdef Tk_InitStubs |
| 3235 |
#undef Tk_InitStubs |
| 3236 |
#endif |
| 3237 |
|
| 3238 |
Tk_InitStubs(interp, TK_VERSION, 1); |
| 3239 |
|
| 3240 |
|
| 3241 |
|
| 3242 |
|
| 3243 |
|
| 3244 |
code = TkpInit(interp); |
| 3245 |
|
| 3246 |
done: |
| 3247 |
if (argv != NULL) { |
| 3248 |
ckfree((char *) argv); |
| 3249 |
} |
| 3250 |
return code; |
| 3251 |
} |
| 3252 |
#endif |
| 3253 |
|
| 3254 |
|
| 3255 |
|