| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#include "tkInt.h" |
| 18 |
#include "tkUnixInt.h" |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
typedef struct Container { |
| 27 |
Window parent; |
| 28 |
|
| 29 |
Window parentRoot; |
| 30 |
|
| 31 |
TkWindow *parentPtr; |
| 32 |
|
| 33 |
|
| 34 |
Window wrapper; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
TkWindow *embeddedPtr; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
struct Container *nextPtr; |
| 46 |
|
| 47 |
} Container; |
| 48 |
|
| 49 |
typedef struct ThreadSpecificData { |
| 50 |
Container *firstContainerPtr; |
| 51 |
|
| 52 |
} ThreadSpecificData; |
| 53 |
static Tcl_ThreadDataKey dataKey; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
static void ContainerEventProc _ANSI_ARGS_(( |
| 60 |
ClientData clientData, XEvent *eventPtr)); |
| 61 |
static void EmbeddedEventProc _ANSI_ARGS_(( |
| 62 |
ClientData clientData, XEvent *eventPtr)); |
| 63 |
static int EmbedErrorProc _ANSI_ARGS_((ClientData clientData, |
| 64 |
XErrorEvent *errEventPtr)); |
| 65 |
static void EmbedFocusProc _ANSI_ARGS_((ClientData clientData, |
| 66 |
XEvent *eventPtr)); |
| 67 |
static void EmbedGeometryRequest _ANSI_ARGS_(( |
| 68 |
Container * containerPtr, int width, int height)); |
| 69 |
static void EmbedSendConfigure _ANSI_ARGS_(( |
| 70 |
Container *containerPtr)); |
| 71 |
static void EmbedStructureProc _ANSI_ARGS_((ClientData clientData, |
| 72 |
XEvent *eventPtr)); |
| 73 |
static void EmbedWindowDeleted _ANSI_ARGS_((TkWindow *winPtr)); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
int |
| 99 |
TkpUseWindow(interp, tkwin, string) |
| 100 |
Tcl_Interp *interp; |
| 101 |
|
| 102 |
Tk_Window tkwin; |
| 103 |
|
| 104 |
Tcl_Obj *string; |
| 105 |
|
| 106 |
{ |
| 107 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 108 |
TkWindow *usePtr; |
| 109 |
int id, anyError; |
| 110 |
Window parent; |
| 111 |
Tk_ErrorHandler handler; |
| 112 |
Container *containerPtr; |
| 113 |
XWindowAttributes parentAtts; |
| 114 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 115 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 116 |
|
| 117 |
if (winPtr->window != None) { |
| 118 |
panic("TkUseWindow: X window already assigned"); |
| 119 |
} |
| 120 |
if (Tcl_GetIntFromObj(interp, string, &id) != TCL_OK) { |
| 121 |
char *s = Tcl_GetString(string); |
| 122 |
char *e = NULL; |
| 123 |
id = strtoul(s,&e,0); |
| 124 |
if (!e || *e) |
| 125 |
return TCL_ERROR; |
| 126 |
} |
| 127 |
parent = (Window) id; |
| 128 |
|
| 129 |
usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, parent); |
| 130 |
if (usePtr != NULL) { |
| 131 |
if (!(usePtr->flags & TK_CONTAINER)) { |
| 132 |
Tcl_AppendResult(interp, "window \"", usePtr->pathName, |
| 133 |
"\" doesn't have -container option set", (char *) NULL); |
| 134 |
return TCL_ERROR; |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
anyError = 0; |
| 146 |
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, |
| 147 |
EmbedErrorProc, (ClientData) &anyError); |
| 148 |
if (!XGetWindowAttributes(winPtr->display, parent, &parentAtts)) { |
| 149 |
anyError = 1; |
| 150 |
} |
| 151 |
XSync(winPtr->display, False); |
| 152 |
Tk_DeleteErrorHandler(handler); |
| 153 |
if (anyError) { |
| 154 |
if (interp != NULL) { |
| 155 |
Tcl_AppendResult(interp, "couldn't create child of window \"", |
| 156 |
Tcl_GetString(string), "\"", (char *) NULL); |
| 157 |
} |
| 158 |
return TCL_ERROR; |
| 159 |
} |
| 160 |
Tk_SetWindowVisual(tkwin, parentAtts.visual, parentAtts.depth, |
| 161 |
parentAtts.colormap); |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc, |
| 169 |
(ClientData) winPtr); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; |
| 179 |
containerPtr = containerPtr->nextPtr) { |
| 180 |
if (containerPtr->parent == parent) { |
| 181 |
winPtr->flags |= TK_BOTH_HALVES; |
| 182 |
containerPtr->parentPtr->flags |= TK_BOTH_HALVES; |
| 183 |
break; |
| 184 |
} |
| 185 |
} |
| 186 |
if (containerPtr == NULL) { |
| 187 |
containerPtr = (Container *) ckalloc(sizeof(Container)); |
| 188 |
containerPtr->parent = parent; |
| 189 |
containerPtr->parentRoot = parentAtts.root; |
| 190 |
containerPtr->parentPtr = NULL; |
| 191 |
containerPtr->wrapper = None; |
| 192 |
containerPtr->nextPtr = tsdPtr->firstContainerPtr; |
| 193 |
tsdPtr->firstContainerPtr = containerPtr; |
| 194 |
} |
| 195 |
containerPtr->embeddedPtr = winPtr; |
| 196 |
winPtr->flags |= TK_EMBEDDED; |
| 197 |
return TCL_OK; |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
Window |
| 218 |
TkpMakeWindow(winPtr, parent) |
| 219 |
TkWindow *winPtr; |
| 220 |
|
| 221 |
Window parent; |
| 222 |
|
| 223 |
{ |
| 224 |
Container *containerPtr; |
| 225 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 226 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 227 |
|
| 228 |
if (winPtr->flags & TK_EMBEDDED) { |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
for (containerPtr = tsdPtr->firstContainerPtr; ; |
| 237 |
containerPtr = containerPtr->nextPtr) { |
| 238 |
if (containerPtr == NULL) { |
| 239 |
panic("TkMakeWindow couldn't find container for window"); |
| 240 |
} |
| 241 |
if (containerPtr->embeddedPtr == winPtr) { |
| 242 |
break; |
| 243 |
} |
| 244 |
} |
| 245 |
parent = containerPtr->parentRoot; |
| 246 |
} |
| 247 |
|
| 248 |
#ifdef __PM__ |
| 249 |
return TkMakeWindow(winPtr, parent); |
| 250 |
#else |
| 251 |
return XCreateWindow(winPtr->display, parent, winPtr->changes.x, |
| 252 |
winPtr->changes.y, (unsigned) winPtr->changes.width, |
| 253 |
(unsigned) winPtr->changes.height, |
| 254 |
(unsigned) winPtr->changes.border_width, winPtr->depth, |
| 255 |
InputOutput, winPtr->visual, winPtr->dirtyAtts, |
| 256 |
&winPtr->atts); |
| 257 |
#endif |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
void |
| 280 |
TkpMakeContainer(tkwin) |
| 281 |
Tk_Window tkwin; |
| 282 |
|
| 283 |
{ |
| 284 |
TkWindow *winPtr = (TkWindow *) tkwin; |
| 285 |
Container *containerPtr; |
| 286 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 287 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
Tk_MakeWindowExist(tkwin); |
| 295 |
containerPtr = (Container *) ckalloc(sizeof(Container)); |
| 296 |
containerPtr->parent = Tk_WindowId(tkwin); |
| 297 |
containerPtr->parentRoot = RootWindowOfScreen(Tk_Screen(tkwin)); |
| 298 |
containerPtr->parentPtr = winPtr; |
| 299 |
containerPtr->wrapper = None; |
| 300 |
containerPtr->embeddedPtr = NULL; |
| 301 |
containerPtr->nextPtr = tsdPtr->firstContainerPtr; |
| 302 |
tsdPtr->firstContainerPtr = containerPtr; |
| 303 |
winPtr->flags |= TK_CONTAINER; |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
winPtr->atts.event_mask |= SubstructureRedirectMask|SubstructureNotifyMask; |
| 313 |
XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask); |
| 314 |
Tk_CreateEventHandler(tkwin, |
| 315 |
SubstructureNotifyMask|SubstructureRedirectMask, |
| 316 |
ContainerEventProc, (ClientData) winPtr); |
| 317 |
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbedStructureProc, |
| 318 |
(ClientData) containerPtr); |
| 319 |
Tk_CreateEventHandler(tkwin, FocusChangeMask, EmbedFocusProc, |
| 320 |
(ClientData) containerPtr); |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
static int |
| 342 |
EmbedErrorProc(clientData, errEventPtr) |
| 343 |
ClientData clientData; |
| 344 |
XErrorEvent *errEventPtr; |
| 345 |
|
| 346 |
{ |
| 347 |
int *iPtr = (int *) clientData; |
| 348 |
|
| 349 |
*iPtr = 1; |
| 350 |
return 0; |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
static void |
| 373 |
EmbeddedEventProc(clientData, eventPtr) |
| 374 |
ClientData clientData; |
| 375 |
XEvent *eventPtr; |
| 376 |
{ |
| 377 |
TkWindow *winPtr = (TkWindow *) clientData; |
| 378 |
|
| 379 |
if (eventPtr->type == DestroyNotify) { |
| 380 |
EmbedWindowDeleted(winPtr); |
| 381 |
} |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
static void |
| 405 |
ContainerEventProc(clientData, eventPtr) |
| 406 |
ClientData clientData; |
| 407 |
XEvent *eventPtr; |
| 408 |
{ |
| 409 |
TkWindow *winPtr = (TkWindow *) clientData; |
| 410 |
Container *containerPtr; |
| 411 |
Tk_ErrorHandler errHandler; |
| 412 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 413 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1, |
| 422 |
-1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL); |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
for (containerPtr = tsdPtr->firstContainerPtr; |
| 429 |
containerPtr->parent != eventPtr->xmaprequest.parent; |
| 430 |
containerPtr = containerPtr->nextPtr) { |
| 431 |
if (containerPtr == NULL) { |
| 432 |
panic("ContainerEventProc couldn't find Container record"); |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
if (eventPtr->type == CreateNotify) { |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
containerPtr->wrapper = eventPtr->xcreatewindow.window; |
| 445 |
XMoveResizeWindow(eventPtr->xcreatewindow.display, |
| 446 |
containerPtr->wrapper, 0, 0, |
| 447 |
(unsigned int) Tk_Width( |
| 448 |
(Tk_Window) containerPtr->parentPtr), |
| 449 |
(unsigned int) Tk_Height( |
| 450 |
(Tk_Window) containerPtr->parentPtr)); |
| 451 |
} else if (eventPtr->type == ConfigureRequest) { |
| 452 |
if ((eventPtr->xconfigurerequest.x != 0) |
| 453 |
|| (eventPtr->xconfigurerequest.y != 0)) { |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
if ((eventPtr->xconfigurerequest.width == winPtr->changes.width) |
| 466 |
&& (eventPtr->xconfigurerequest.height |
| 467 |
== winPtr->changes.height)) { |
| 468 |
EmbedSendConfigure(containerPtr); |
| 469 |
} |
| 470 |
} |
| 471 |
EmbedGeometryRequest(containerPtr, |
| 472 |
eventPtr->xconfigurerequest.width, |
| 473 |
eventPtr->xconfigurerequest.height); |
| 474 |
} else if (eventPtr->type == MapRequest) { |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
XMapWindow(eventPtr->xmaprequest.display, |
| 482 |
eventPtr->xmaprequest.window); |
| 483 |
} else if (eventPtr->type == DestroyNotify) { |
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
Tk_DestroyWindow((Tk_Window) winPtr); |
| 489 |
} |
| 490 |
Tk_DeleteErrorHandler(errHandler); |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
static void |
| 514 |
EmbedStructureProc(clientData, eventPtr) |
| 515 |
ClientData clientData; |
| 516 |
XEvent *eventPtr; |
| 517 |
{ |
| 518 |
Container *containerPtr = (Container *) clientData; |
| 519 |
Tk_ErrorHandler errHandler; |
| 520 |
|
| 521 |
if (eventPtr->type == ConfigureNotify) { |
| 522 |
if (containerPtr->wrapper != None) { |
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1, |
| 529 |
-1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL); |
| 530 |
XMoveResizeWindow(eventPtr->xconfigure.display, |
| 531 |
containerPtr->wrapper, 0, 0, |
| 532 |
(unsigned int) Tk_Width( |
| 533 |
(Tk_Window) containerPtr->parentPtr), |
| 534 |
(unsigned int) Tk_Height( |
| 535 |
(Tk_Window) containerPtr->parentPtr)); |
| 536 |
Tk_DeleteErrorHandler(errHandler); |
| 537 |
} |
| 538 |
} else if (eventPtr->type == DestroyNotify) { |
| 539 |
EmbedWindowDeleted(containerPtr->parentPtr); |
| 540 |
} |
| 541 |
} |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
static void |
| 564 |
EmbedFocusProc(clientData, eventPtr) |
| 565 |
ClientData clientData; |
| 566 |
XEvent *eventPtr; |
| 567 |
{ |
| 568 |
Container *containerPtr = (Container *) clientData; |
| 569 |
Tk_ErrorHandler errHandler; |
| 570 |
Display *display; |
| 571 |
|
| 572 |
display = Tk_Display(containerPtr->parentPtr); |
| 573 |
if (eventPtr->type == FocusIn) { |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
if (containerPtr->wrapper != None) { |
| 582 |
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1, |
| 583 |
-1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL); |
| 584 |
XSetInputFocus(display, containerPtr->wrapper, RevertToParent, |
| 585 |
CurrentTime); |
| 586 |
Tk_DeleteErrorHandler(errHandler); |
| 587 |
} |
| 588 |
} |
| 589 |
} |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
static void |
| 614 |
EmbedGeometryRequest(containerPtr, width, height) |
| 615 |
Container *containerPtr; |
| 616 |
int width, height; |
| 617 |
{ |
| 618 |
TkWindow *winPtr = containerPtr->parentPtr; |
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
Tk_GeometryRequest((Tk_Window) winPtr, width, height); |
| 631 |
while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) { |
| 632 |
|
| 633 |
} |
| 634 |
if ((winPtr->changes.width != width) |
| 635 |
|| (winPtr->changes.height != height)) { |
| 636 |
EmbedSendConfigure(containerPtr); |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
static void |
| 661 |
EmbedSendConfigure(containerPtr) |
| 662 |
Container *containerPtr; |
| 663 |
{ |
| 664 |
TkWindow *winPtr = containerPtr->parentPtr; |
| 665 |
XEvent event; |
| 666 |
|
| 667 |
event.xconfigure.type = ConfigureNotify; |
| 668 |
event.xconfigure.serial = |
| 669 |
LastKnownRequestProcessed(winPtr->display); |
| 670 |
event.xconfigure.send_event = True; |
| 671 |
event.xconfigure.display = winPtr->display; |
| 672 |
event.xconfigure.event = containerPtr->wrapper; |
| 673 |
event.xconfigure.window = containerPtr->wrapper; |
| 674 |
event.xconfigure.x = 0; |
| 675 |
event.xconfigure.y = 0; |
| 676 |
event.xconfigure.width = winPtr->changes.width; |
| 677 |
event.xconfigure.height = winPtr->changes.height; |
| 678 |
event.xconfigure.above = None; |
| 679 |
event.xconfigure.override_redirect = False; |
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
XSendEvent(winPtr->display, containerPtr->wrapper, False, |
| 689 |
0, &event); |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
if (containerPtr->embeddedPtr == NULL) { |
| 697 |
XMoveResizeWindow(winPtr->display, containerPtr->wrapper, 0, 0, |
| 698 |
(unsigned int) winPtr->changes.width, |
| 699 |
(unsigned int) winPtr->changes.height); |
| 700 |
} |
| 701 |
} |
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
TkWindow * |
| 723 |
TkpGetOtherWindow(winPtr) |
| 724 |
TkWindow *winPtr; |
| 725 |
|
| 726 |
{ |
| 727 |
Container *containerPtr; |
| 728 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 729 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 730 |
|
| 731 |
for (containerPtr = tsdPtr->firstContainerPtr; |
| 732 |
containerPtr != NULL; |
| 733 |
containerPtr = containerPtr->nextPtr) { |
| 734 |
if (containerPtr->embeddedPtr == winPtr) { |
| 735 |
return containerPtr->parentPtr; |
| 736 |
} else if (containerPtr->parentPtr == winPtr) { |
| 737 |
return containerPtr->embeddedPtr; |
| 738 |
} |
| 739 |
} |
| 740 |
panic("TkpGetOtherWindow couldn't find window"); |
| 741 |
return NULL; |
| 742 |
} |
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
void |
| 767 |
TkpRedirectKeyEvent(winPtr, eventPtr) |
| 768 |
TkWindow *winPtr; |
| 769 |
|
| 770 |
XEvent *eventPtr; |
| 771 |
|
| 772 |
{ |
| 773 |
Container *containerPtr; |
| 774 |
Window saved; |
| 775 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 776 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
while (1) { |
| 783 |
if (winPtr == NULL) { |
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
return; |
| 790 |
} |
| 791 |
if (winPtr->flags & TK_TOP_HIERARCHY) { |
| 792 |
break; |
| 793 |
} |
| 794 |
winPtr = winPtr->parentPtr; |
| 795 |
} |
| 796 |
|
| 797 |
if (winPtr->flags & TK_EMBEDDED) { |
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
for (containerPtr = tsdPtr->firstContainerPtr; |
| 806 |
containerPtr->embeddedPtr != winPtr; |
| 807 |
containerPtr = containerPtr->nextPtr) { |
| 808 |
|
| 809 |
} |
| 810 |
saved = eventPtr->xkey.window; |
| 811 |
eventPtr->xkey.window = containerPtr->parent; |
| 812 |
XSendEvent(eventPtr->xkey.display, eventPtr->xkey.window, False, |
| 813 |
KeyPressMask|KeyReleaseMask, eventPtr); |
| 814 |
eventPtr->xkey.window = saved; |
| 815 |
} |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
void |
| 838 |
TkpClaimFocus(topLevelPtr, force) |
| 839 |
TkWindow *topLevelPtr; |
| 840 |
|
| 841 |
int force; |
| 842 |
|
| 843 |
|
| 844 |
{ |
| 845 |
XEvent event; |
| 846 |
Container *containerPtr; |
| 847 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 848 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 849 |
|
| 850 |
if (!(topLevelPtr->flags & TK_EMBEDDED)) { |
| 851 |
return; |
| 852 |
} |
| 853 |
|
| 854 |
for (containerPtr = tsdPtr->firstContainerPtr; |
| 855 |
containerPtr->embeddedPtr != topLevelPtr; |
| 856 |
containerPtr = containerPtr->nextPtr) { |
| 857 |
|
| 858 |
} |
| 859 |
|
| 860 |
event.xfocus.type = FocusIn; |
| 861 |
event.xfocus.serial = LastKnownRequestProcessed(topLevelPtr->display); |
| 862 |
event.xfocus.send_event = 1; |
| 863 |
event.xfocus.display = topLevelPtr->display; |
| 864 |
event.xfocus.window = containerPtr->parent; |
| 865 |
event.xfocus.mode = EMBEDDED_APP_WANTS_FOCUS; |
| 866 |
event.xfocus.detail = force; |
| 867 |
XSendEvent(event.xfocus.display, event.xfocus.window, False, 0, &event); |
| 868 |
} |
| 869 |
|
| 870 |
#if 0 |
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
int |
| 890 |
TkpTestembedCmd(clientData, interp, argc, argv) |
| 891 |
ClientData clientData; |
| 892 |
Tcl_Interp *interp; |
| 893 |
int argc; |
| 894 |
CONST char **argv; |
| 895 |
{ |
| 896 |
int all; |
| 897 |
Container *containerPtr; |
| 898 |
Tcl_DString dString; |
| 899 |
char buffer[50]; |
| 900 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 901 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 902 |
|
| 903 |
if ((argc > 1) && (strcmp(argv[1], "all") == 0)) { |
| 904 |
all = 1; |
| 905 |
} else { |
| 906 |
all = 0; |
| 907 |
} |
| 908 |
Tcl_DStringInit(&dString); |
| 909 |
for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; |
| 910 |
containerPtr = containerPtr->nextPtr) { |
| 911 |
Tcl_DStringStartSublist(&dString); |
| 912 |
if (containerPtr->parent == None) { |
| 913 |
Tcl_DStringAppendElement(&dString, ""); |
| 914 |
} else { |
| 915 |
if (all) { |
| 916 |
sprintf(buffer, "0x%x", (int) containerPtr->parent); |
| 917 |
Tcl_DStringAppendElement(&dString, buffer); |
| 918 |
} else { |
| 919 |
Tcl_DStringAppendElement(&dString, "XXX"); |
| 920 |
} |
| 921 |
} |
| 922 |
if (containerPtr->parentPtr == NULL) { |
| 923 |
Tcl_DStringAppendElement(&dString, ""); |
| 924 |
} else { |
| 925 |
Tcl_DStringAppendElement(&dString, |
| 926 |
containerPtr->parentPtr->pathName); |
| 927 |
} |
| 928 |
if (containerPtr->wrapper == None) { |
| 929 |
Tcl_DStringAppendElement(&dString, ""); |
| 930 |
} else { |
| 931 |
if (all) { |
| 932 |
sprintf(buffer, "0x%x", (int) containerPtr->wrapper); |
| 933 |
Tcl_DStringAppendElement(&dString, buffer); |
| 934 |
} else { |
| 935 |
Tcl_DStringAppendElement(&dString, "XXX"); |
| 936 |
} |
| 937 |
} |
| 938 |
if (containerPtr->embeddedPtr == NULL) { |
| 939 |
Tcl_DStringAppendElement(&dString, ""); |
| 940 |
} else { |
| 941 |
Tcl_DStringAppendElement(&dString, |
| 942 |
containerPtr->embeddedPtr->pathName); |
| 943 |
} |
| 944 |
Tcl_DStringEndSublist(&dString); |
| 945 |
} |
| 946 |
Tcl_DStringResult(interp, &dString); |
| 947 |
return TCL_OK; |
| 948 |
} |
| 949 |
|
| 950 |
#endif |
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
static void |
| 971 |
EmbedWindowDeleted(winPtr) |
| 972 |
TkWindow *winPtr; |
| 973 |
|
| 974 |
{ |
| 975 |
Container *containerPtr, *prevPtr; |
| 976 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 977 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
prevPtr = NULL; |
| 986 |
containerPtr = tsdPtr->firstContainerPtr; |
| 987 |
while (1) { |
| 988 |
if (containerPtr->embeddedPtr == winPtr) { |
| 989 |
containerPtr->wrapper = None; |
| 990 |
containerPtr->embeddedPtr = NULL; |
| 991 |
break; |
| 992 |
} |
| 993 |
if (containerPtr->parentPtr == winPtr) { |
| 994 |
containerPtr->parentPtr = NULL; |
| 995 |
break; |
| 996 |
} |
| 997 |
prevPtr = containerPtr; |
| 998 |
containerPtr = containerPtr->nextPtr; |
| 999 |
} |
| 1000 |
if ((containerPtr->embeddedPtr == NULL) |
| 1001 |
&& (containerPtr->parentPtr == NULL)) { |
| 1002 |
if (prevPtr == NULL) { |
| 1003 |
tsdPtr->firstContainerPtr = containerPtr->nextPtr; |
| 1004 |
} else { |
| 1005 |
prevPtr->nextPtr = containerPtr->nextPtr; |
| 1006 |
} |
| 1007 |
ckfree((char *) containerPtr); |
| 1008 |
} |
| 1009 |
} |
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
Window |
| 1030 |
TkUnixContainerId(winPtr) |
| 1031 |
TkWindow *winPtr; |
| 1032 |
{ |
| 1033 |
Container *containerPtr; |
| 1034 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 1035 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 1036 |
|
| 1037 |
for (containerPtr = tsdPtr->firstContainerPtr; |
| 1038 |
containerPtr != NULL; containerPtr = containerPtr->nextPtr) { |
| 1039 |
if (containerPtr->embeddedPtr == winPtr) { |
| 1040 |
return containerPtr->parent; |
| 1041 |
} |
| 1042 |
} |
| 1043 |
panic("TkUnixContainerId couldn't find window"); |
| 1044 |
return None; |
| 1045 |
} |
| 1046 |
|
| 1047 |
|
| 1048 |
|