1/* 2 * tkInt.h -- 3 * 4 * Declarations for things used internally by the Tk 5 * procedures but not exported outside the module. 6 * 7 * Copyright (c) 1990-1994 The Regents of the University of California. 8 * Copyright (c) 1994-1997 Sun Microsystems, Inc. 9 * Copyright (c) 1998 by Scriptics Corporation. 10 * 11 * See the file "license.terms" for information on usage and redistribution 12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 13 * 14 * RCS: $Id: tkInt.h,v 1.56.2.9 2006/09/06 22:01:25 hobbs Exp $ 15 */ 16 17#ifndef _TKINT 18#define _TKINT 19 20#ifndef _TK 21#include "tk.h" 22#endif 23#ifndef _TCL 24#include "tcl.h" 25#endif 26#ifndef _TKPORT 27#include "tkPort.h" 28#endif 29 30/* 31 * Ensure WORDS_BIGENDIAN is defined correcly: 32 * Needs to happen here in addition to configure to work with fat compiles on 33 * Darwin (where configure runs only once for multiple architectures). 34 */ 35 36#ifdef HAVE_SYS_TYPES_H 37# include <sys/types.h> 38#endif 39#ifdef HAVE_SYS_PARAM_H 40# include <sys/param.h> 41#endif 42#ifdef BYTE_ORDER 43# ifdef BIG_ENDIAN 44# if BYTE_ORDER == BIG_ENDIAN 45# undef WORDS_BIGENDIAN 46# define WORDS_BIGENDIAN 47# endif 48# endif 49# ifdef LITTLE_ENDIAN 50# if BYTE_ORDER == LITTLE_ENDIAN 51# undef WORDS_BIGENDIAN 52# endif 53# endif 54#endif 55 56/* 57 * Used to tag functions that are only to be visible within the module being 58 * built and not outside it (where this is supported by the linker). 59 */ 60 61#ifndef MODULE_SCOPE 62# ifdef __cplusplus 63# define MODULE_SCOPE extern "C" 64# else 65# define MODULE_SCOPE extern 66# endif 67#endif 68 69/* 70 * Opaque type declarations: 71 */ 72 73typedef struct TkColormap TkColormap; 74typedef struct TkGrabEvent TkGrabEvent; 75typedef struct TkpCursor_ *TkpCursor; 76typedef struct TkRegion_ *TkRegion; 77typedef struct TkStressedCmap TkStressedCmap; 78typedef struct TkBindInfo_ *TkBindInfo; 79 80/* 81 * Procedure types. 82 */ 83 84typedef int (TkBindEvalProc) _ANSI_ARGS_((ClientData clientData, 85 Tcl_Interp *interp, XEvent *eventPtr, Tk_Window tkwin, 86 KeySym keySym)); 87typedef void (TkBindFreeProc) _ANSI_ARGS_((ClientData clientData)); 88 89/* 90 * One of the following structures is maintained for each cursor in 91 * use in the system. This structure is used by tkCursor.c and the 92 * various system specific cursor files. 93 */ 94 95typedef struct TkCursor { 96 Tk_Cursor cursor; /* System specific identifier for cursor. */ 97 Display *display; /* Display containing cursor. Needed for 98 * disposal and retrieval of cursors. */ 99 int resourceRefCount; /* Number of active uses of this cursor (each 100 * active use corresponds to a call to 101 * Tk_AllocPreserveFromObj or Tk_Preserve). 102 * If this count is 0, then this structure 103 * is no longer valid and it isn't present 104 * in a hash table: it is being kept around 105 * only because there are objects referring 106 * to it. The structure is freed when 107 * resourceRefCount and objRefCount are 108 * both 0. */ 109 int objRefCount; /* Number of Tcl objects that reference 110 * this structure.. */ 111 Tcl_HashTable *otherTable; /* Second table (other than idTable) used 112 * to index this entry. */ 113 Tcl_HashEntry *hashPtr; /* Entry in otherTable for this structure 114 * (needed when deleting). */ 115 Tcl_HashEntry *idHashPtr; /* Entry in idTable for this structure 116 * (needed when deleting). */ 117 struct TkCursor *nextPtr; /* Points to the next TkCursor structure with 118 * the same name. Cursors with the same 119 * name but different displays are chained 120 * together off a single hash table entry. */ 121} TkCursor; 122 123/* 124 * This defines whether we should try to use XIM over-the-spot style 125 * input. Allow users to override it. It is a much more elegant use 126 * of XIM, but uses a bit more memory. 127 */ 128 129#ifndef TK_XIM_SPOT 130# define TK_XIM_SPOT 1 131#endif 132 133/* 134 * The following structure is kept one-per-TkDisplay to maintain information 135 * about the caret (cursor location) on this display. This is used to 136 * dictate global focus location (Windows Accessibility guidelines) and to 137 * position the IME or XIM over-the-spot window. 138 */ 139 140typedef struct TkCaret { 141 struct TkWindow *winPtr; /* the window on which we requested caret 142 * placement */ 143 int x; /* relative x coord of the caret */ 144 int y; /* relative y coord of the caret */ 145 int height; /* specified height of the window */ 146} TkCaret; 147 148/* 149 * One of the following structures is maintained for each display 150 * containing a window managed by Tk. In part, the structure is 151 * used to store thread-specific data, since each thread will have 152 * its own TkDisplay structure. 153 */ 154 155typedef struct TkDisplay { 156 Display *display; /* Xlib's info about display. */ 157 struct TkDisplay *nextPtr; /* Next in list of all displays. */ 158 char *name; /* Name of display (with any screen 159 * identifier removed). Malloc-ed. */ 160 Time lastEventTime; /* Time of last event received for this 161 * display. */ 162 163 /* 164 * Information used primarily by tk3d.c: 165 */ 166 167 int borderInit; /* 0 means borderTable needs initializing. */ 168 Tcl_HashTable borderTable; /* Maps from color name to TkBorder 169 * structure. */ 170 171 /* 172 * Information used by tkAtom.c only: 173 */ 174 175 int atomInit; /* 0 means stuff below hasn't been 176 * initialized yet. */ 177 Tcl_HashTable nameTable; /* Maps from names to Atom's. */ 178 Tcl_HashTable atomTable; /* Maps from Atom's back to names. */ 179 180 /* 181 * Information used primarily by tkBind.c: 182 */ 183 184 int bindInfoStale; /* Non-zero means the variables in this 185 * part of the structure are potentially 186 * incorrect and should be recomputed. */ 187 unsigned int modeModMask; /* Has one bit set to indicate the modifier 188 * corresponding to "mode shift". If no 189 * such modifier, than this is zero. */ 190 unsigned int metaModMask; /* Has one bit set to indicate the modifier 191 * corresponding to the "Meta" key. If no 192 * such modifier, then this is zero. */ 193 unsigned int altModMask; /* Has one bit set to indicate the modifier 194 * corresponding to the "Meta" key. If no 195 * such modifier, then this is zero. */ 196 enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage; 197 /* Indicates how to interpret lock modifier. */ 198 int numModKeyCodes; /* Number of entries in modKeyCodes array 199 * below. */ 200 KeyCode *modKeyCodes; /* Pointer to an array giving keycodes for 201 * all of the keys that have modifiers 202 * associated with them. Malloc'ed, but 203 * may be NULL. */ 204 205 /* 206 * Information used by tkBitmap.c only: 207 */ 208 209 int bitmapInit; /* 0 means tables above need initializing. */ 210 int bitmapAutoNumber; /* Used to number bitmaps. */ 211 Tcl_HashTable bitmapNameTable; 212 /* Maps from name of bitmap to the first 213 * TkBitmap record for that name. */ 214 Tcl_HashTable bitmapIdTable;/* Maps from bitmap id to the TkBitmap 215 * structure for the bitmap. */ 216 Tcl_HashTable bitmapDataTable; 217 /* Used by Tk_GetBitmapFromData to map from 218 * a collection of in-core data about a 219 * bitmap to a reference giving an auto- 220 * matically-generated name for the bitmap. */ 221 222 /* 223 * Information used by tkCanvas.c only: 224 */ 225 226 int numIdSearches; 227 int numSlowSearches; 228 229 /* 230 * Used by tkColor.c only: 231 */ 232 233 int colorInit; /* 0 means color module needs initializing. */ 234 TkStressedCmap *stressPtr; /* First in list of colormaps that have 235 * filled up, so we have to pick an 236 * approximate color. */ 237 Tcl_HashTable colorNameTable; 238 /* Maps from color name to TkColor structure 239 * for that color. */ 240 Tcl_HashTable colorValueTable; 241 /* Maps from integer RGB values to TkColor 242 * structures. */ 243 244 /* 245 * Used by tkCursor.c only: 246 */ 247 248 int cursorInit; /* 0 means cursor module need initializing. */ 249 Tcl_HashTable cursorNameTable; 250 /* Maps from a string name to a cursor to the 251 * TkCursor record for the cursor. */ 252 Tcl_HashTable cursorDataTable; 253 /* Maps from a collection of in-core data 254 * about a cursor to a TkCursor structure. */ 255 Tcl_HashTable cursorIdTable; 256 /* Maps from a cursor id to the TkCursor 257 * structure for the cursor. */ 258 char cursorString[20]; /* Used to store a cursor id string. */ 259 Font cursorFont; /* Font to use for standard cursors. 260 * None means font not loaded yet. */ 261 262 /* 263 * Information used by tkError.c only: 264 */ 265 266 struct TkErrorHandler *errorPtr; 267 /* First in list of error handlers 268 * for this display. NULL means 269 * no handlers exist at present. */ 270 int deleteCount; /* Counts # of handlers deleted since 271 * last time inactive handlers were 272 * garbage-collected. When this number 273 * gets big, handlers get cleaned up. */ 274 275 /* 276 * Used by tkEvent.c only: 277 */ 278 279 struct TkWindowEvent *delayedMotionPtr; 280 /* Points to a malloc-ed motion event 281 * whose processing has been delayed in 282 * the hopes that another motion event 283 * will come along right away and we can 284 * merge the two of them together. NULL 285 * means that there is no delayed motion 286 * event. */ 287 288 /* 289 * Information used by tkFocus.c only: 290 */ 291 292 int focusDebug; /* 1 means collect focus debugging 293 * statistics. */ 294 struct TkWindow *implicitWinPtr; 295 /* If the focus arrived at a toplevel window 296 * implicitly via an Enter event (rather 297 * than via a FocusIn event), this points 298 * to the toplevel window. Otherwise it is 299 * NULL. */ 300 struct TkWindow *focusPtr; /* Points to the window on this display that 301 * should be receiving keyboard events. When 302 * multiple applications on the display have 303 * the focus, this will refer to the 304 * innermost window in the innermost 305 * application. This information isn't used 306 * under Unix or Windows, but it's needed on 307 * the Macintosh. */ 308 309 /* 310 * Information used by tkGC.c only: 311 */ 312 313 Tcl_HashTable gcValueTable; /* Maps from a GC's values to a TkGC structure 314 * describing a GC with those values. */ 315 Tcl_HashTable gcIdTable; /* Maps from a GC to a TkGC. */ 316 int gcInit; /* 0 means the tables below need 317 * initializing. */ 318 319 /* 320 * Information used by tkGeometry.c only: 321 */ 322 323 Tcl_HashTable maintainHashTable; 324 /* Hash table that maps from a master's 325 * Tk_Window token to a list of slaves 326 * managed by that master. */ 327 int geomInit; 328 329 /* 330 * Information used by tkGet.c only: 331 */ 332 333 Tcl_HashTable uidTable; /* Stores all Tk_Uid used in a thread. */ 334 int uidInit; /* 0 means uidTable needs initializing. */ 335 336 /* 337 * Information used by tkGrab.c only: 338 */ 339 340 struct TkWindow *grabWinPtr; 341 /* Window in which the pointer is currently 342 * grabbed, or NULL if none. */ 343 struct TkWindow *eventualGrabWinPtr; 344 /* Value that grabWinPtr will have once the 345 * grab event queue (below) has been 346 * completely emptied. */ 347 struct TkWindow *buttonWinPtr; 348 /* Window in which first mouse button was 349 * pressed while grab was in effect, or NULL 350 * if no such press in effect. */ 351 struct TkWindow *serverWinPtr; 352 /* If no application contains the pointer then 353 * this is NULL. Otherwise it contains the 354 * last window for which we've gotten an 355 * Enter or Leave event from the server (i.e. 356 * the last window known to have contained 357 * the pointer). Doesn't reflect events 358 * that were synthesized in tkGrab.c. */ 359 TkGrabEvent *firstGrabEventPtr; 360 /* First in list of enter/leave events 361 * synthesized by grab code. These events 362 * must be processed in order before any other 363 * events are processed. NULL means no such 364 * events. */ 365 TkGrabEvent *lastGrabEventPtr; 366 /* Last in list of synthesized events, or NULL 367 * if list is empty. */ 368 int grabFlags; /* Miscellaneous flag values. See definitions 369 * in tkGrab.c. */ 370 371 /* 372 * Information used by tkGrid.c only: 373 */ 374 375 int gridInit; /* 0 means table below needs initializing. */ 376 Tcl_HashTable gridHashTable;/* Maps from Tk_Window tokens to 377 * corresponding Grid structures. */ 378 379 /* 380 * Information used by tkImage.c only: 381 */ 382 383 int imageId; /* Value used to number image ids. */ 384 385 /* 386 * Information used by tkMacWinMenu.c only: 387 */ 388 389 int postCommandGeneration; 390 391 /* 392 * Information used by tkOption.c only. 393 */ 394 395 396 397 /* 398 * Information used by tkPack.c only. 399 */ 400 401 int packInit; /* 0 means table below needs initializing. */ 402 Tcl_HashTable packerHashTable; 403 /* Maps from Tk_Window tokens to 404 * corresponding Packer structures. */ 405 406 407 /* 408 * Information used by tkPlace.c only. 409 */ 410 411 int placeInit; /* 0 means tables below need initializing. */ 412 Tcl_HashTable masterTable; /* Maps from Tk_Window toke to the Master 413 * structure for the window, if it exists. */ 414 Tcl_HashTable slaveTable; /* Maps from Tk_Window toke to the Slave 415 * structure for the window, if it exists. */ 416 417 /* 418 * Information used by tkSelect.c and tkClipboard.c only: 419 */ 420 421 struct TkSelectionInfo *selectionInfoPtr; 422 /* First in list of selection information 423 * records. Each entry contains information 424 * about the current owner of a particular 425 * selection on this display. */ 426 Atom multipleAtom; /* Atom for MULTIPLE. None means 427 * selection stuff isn't initialized. */ 428 Atom incrAtom; /* Atom for INCR. */ 429 Atom targetsAtom; /* Atom for TARGETS. */ 430 Atom timestampAtom; /* Atom for TIMESTAMP. */ 431 Atom textAtom; /* Atom for TEXT. */ 432 Atom compoundTextAtom; /* Atom for COMPOUND_TEXT. */ 433 Atom applicationAtom; /* Atom for TK_APPLICATION. */ 434 Atom windowAtom; /* Atom for TK_WINDOW. */ 435 Atom clipboardAtom; /* Atom for CLIPBOARD. */ 436 Atom utf8Atom; /* Atom for UTF8_STRING. */ 437 438 Tk_Window clipWindow; /* Window used for clipboard ownership and to 439 * retrieve selections between processes. NULL 440 * means clipboard info hasn't been 441 * initialized. */ 442 int clipboardActive; /* 1 means we currently own the clipboard 443 * selection, 0 means we don't. */ 444 struct TkMainInfo *clipboardAppPtr; 445 /* Last application that owned clipboard. */ 446 struct TkClipboardTarget *clipTargetPtr; 447 /* First in list of clipboard type information 448 * records. Each entry contains information 449 * about the buffers for a given selection 450 * target. */ 451 452 /* 453 * Information used by tkSend.c only: 454 */ 455 456 Tk_Window commTkwin; /* Window used for communication 457 * between interpreters during "send" 458 * commands. NULL means send info hasn't 459 * been initialized yet. */ 460 Atom commProperty; /* X's name for comm property. */ 461 Atom registryProperty; /* X's name for property containing 462 * registry of interpreter names. */ 463 Atom appNameProperty; /* X's name for property used to hold the 464 * application name on each comm window. */ 465 466 /* 467 * Information used by tkXId.c only: 468 */ 469 470 struct TkIdStack *idStackPtr; 471 /* First in list of chunks of free resource 472 * identifiers, or NULL if there are no free 473 * resources. */ 474 XID (*defaultAllocProc) _ANSI_ARGS_((Display *display)); 475 /* Default resource allocator for display. */ 476 struct TkIdStack *windowStackPtr; 477 /* First in list of chunks of window 478 * identifers that can't be reused right 479 * now. */ 480 Tcl_TimerToken idCleanupScheduled; 481 /* If set, it means a call to WindowIdCleanup 482 * has already been scheduled, 0 means it 483 * hasn't. */ 484 485 /* 486 * Information used by tkUnixWm.c and tkWinWm.c only: 487 */ 488 489 struct TkWmInfo *firstWmPtr; /* Points to first top-level window. */ 490 struct TkWmInfo *foregroundWmPtr; 491 /* Points to the foreground window. */ 492 493 /* 494 * Information maintained by tkWindow.c for use later on by tkXId.c: 495 */ 496 497 498 int destroyCount; /* Number of Tk_DestroyWindow operations 499 * in progress. */ 500 unsigned long lastDestroyRequest; 501 /* Id of most recent XDestroyWindow request; 502 * can re-use ids in windowStackPtr when 503 * server has seen this request and event 504 * queue is empty. */ 505 506 /* 507 * Information used by tkVisual.c only: 508 */ 509 510 TkColormap *cmapPtr; /* First in list of all non-default colormaps 511 * allocated for this display. */ 512 513 /* 514 * Miscellaneous information: 515 */ 516 517#ifdef TK_USE_INPUT_METHODS 518 XIM inputMethod; /* Input method for this display */ 519#if TK_XIM_SPOT 520 XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ 521#endif 522#endif /* TK_USE_INPUT_METHODS */ 523 Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ 524 525 int refCount; /* Reference count of how many Tk applications 526 * are using this display. Used to clean up 527 * the display when we no longer have any 528 * Tk applications using it. 529 */ 530 /* 531 * The following field were all added for Tk8.3 532 */ 533 int mouseButtonState; /* current mouse button state for this 534 * display */ 535 Window mouseButtonWindow; /* Window the button state was set in, 536 * added in Tk 8.4. */ 537 Window warpWindow; 538 int warpX; 539 int warpY; 540 541 /* 542 * The following field(s) were all added for Tk8.4 543 */ 544 unsigned int flags; /* Various flag values: these are all 545 * defined in below. */ 546 TkCaret caret; /* information about the caret for this 547 * display. This is not a pointer. */ 548 549 int iconDataSize; /* size of default iconphoto image data */ 550 unsigned char *iconDataPtr; /* default iconphoto image data, if set */ 551} TkDisplay; 552 553/* 554 * Flag values for TkDisplay flags. 555 * TK_DISPLAY_COLLAPSE_MOTION_EVENTS: (default on) 556 * Indicates that we should collapse motion events on this display 557 * TK_DISPLAY_USE_IM: (default on, set via tk.tcl) 558 * Whether to use input methods for this display 559 * TK_DISPLAY_XIM_SPOT: (default off) 560 * Indicates that we should use over-the-spot XIM on this display 561 * TK_DISPLAY_WM_TRACING: (default off) 562 * Whether we should do wm tracing on this display. 563 * TK_DISPLAY_IN_WARP: (default off) 564 * Indicates that we are in a pointer warp 565 */ 566 567#define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) 568#define TK_DISPLAY_USE_IM (1 << 1) 569#define TK_DISPLAY_XIM_SPOT (1 << 2) 570#define TK_DISPLAY_WM_TRACING (1 << 3) 571#define TK_DISPLAY_IN_WARP (1 << 4) 572 573/* 574 * One of the following structures exists for each error handler 575 * created by a call to Tk_CreateErrorHandler. The structure 576 * is managed by tkError.c. 577 */ 578 579typedef struct TkErrorHandler { 580 TkDisplay *dispPtr; /* Display to which handler applies. */ 581 unsigned long firstRequest; /* Only errors with serial numbers 582 * >= to this are considered. */ 583 unsigned long lastRequest; /* Only errors with serial numbers 584 * <= to this are considered. This 585 * field is filled in when XUnhandle 586 * is called. -1 means XUnhandle 587 * hasn't been called yet. */ 588 int error; /* Consider only errors with this 589 * error_code (-1 means consider 590 * all errors). */ 591 int request; /* Consider only errors with this 592 * major request code (-1 means 593 * consider all major codes). */ 594 int minorCode; /* Consider only errors with this 595 * minor request code (-1 means 596 * consider all minor codes). */ 597 Tk_ErrorProc *errorProc; /* Procedure to invoke when a matching 598 * error occurs. NULL means just ignore 599 * errors. */ 600 ClientData clientData; /* Arbitrary value to pass to 601 * errorProc. */ 602 struct TkErrorHandler *nextPtr; 603 /* Pointer to next older handler for 604 * this display, or NULL for end of 605 * list. */ 606} TkErrorHandler; 607 608 609/* 610 * One of the following structures exists for each event handler 611 * created by calling Tk_CreateEventHandler. This information 612 * is used by tkEvent.c only. 613 */ 614 615typedef struct TkEventHandler { 616 unsigned long mask; /* Events for which to invoke 617 * proc. */ 618 Tk_EventProc *proc; /* Procedure to invoke when an event 619 * in mask occurs. */ 620 ClientData clientData; /* Argument to pass to proc. */ 621 struct TkEventHandler *nextPtr; 622 /* Next in list of handlers 623 * associated with window (NULL means 624 * end of list). */ 625} TkEventHandler; 626 627/* 628 * Tk keeps one of the following data structures for each main 629 * window (created by a call to TkCreateMainWindow). It stores 630 * information that is shared by all of the windows associated 631 * with a particular main window. 632 */ 633 634typedef struct TkMainInfo { 635 int refCount; /* Number of windows whose "mainPtr" fields 636 * point here. When this becomes zero, can 637 * free up the structure (the reference 638 * count is zero because windows can get 639 * deleted in almost any order; the main 640 * window isn't necessarily the last one 641 * deleted). */ 642 struct TkWindow *winPtr; /* Pointer to main window. */ 643 Tcl_Interp *interp; /* Interpreter associated with application. */ 644 Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow 645 * structs for all windows related to this 646 * main window. Managed by tkWindow.c. */ 647 long deletionEpoch; /* Incremented by window deletions */ 648 Tk_BindingTable bindingTable; 649 /* Used in conjunction with "bind" command 650 * to bind events to Tcl commands. */ 651 TkBindInfo bindInfo; /* Information used by tkBind.c on a per 652 * application basis. */ 653 struct TkFontInfo *fontInfoPtr; 654 /* Information used by tkFont.c on a per 655 * application basis. */ 656 657 /* 658 * Information used only by tkFocus.c and tk*Embed.c: 659 */ 660 661 struct TkToplevelFocusInfo *tlFocusPtr; 662 /* First in list of records containing focus 663 * information for each top-level in the 664 * application. Used only by tkFocus.c. */ 665 struct TkDisplayFocusInfo *displayFocusPtr; 666 /* First in list of records containing focus 667 * information for each display that this 668 * application has ever used. Used only 669 * by tkFocus.c. */ 670 671 struct ElArray *optionRootPtr; 672 /* Top level of option hierarchy for this 673 * main window. NULL means uninitialized. 674 * Managed by tkOption.c. */ 675 Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageMaster 676 * structures. Managed by tkImage.c. */ 677 int strictMotif; /* This is linked to the tk_strictMotif 678 * global variable. */ 679 int alwaysShowSelection; /* This is linked to the 680 * ::tk::AlwaysShowSelection variable. */ 681 struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by 682 * this process. */ 683} TkMainInfo; 684 685/* 686 * Tk keeps the following data structure for each of it's builtin 687 * bitmaps. This structure is only used by tkBitmap.c and other 688 * platform specific bitmap files. 689 */ 690 691typedef struct { 692 CONST char *source; /* Bits for bitmap. */ 693 int width, height; /* Dimensions of bitmap. */ 694 int native; /* 0 means generic (X style) bitmap, 695 * 1 means native style bitmap. */ 696} TkPredefBitmap; 697 698/* 699 * Tk keeps one of the following structures for each window. 700 * Some of the information (like size and location) is a shadow 701 * of information managed by the X server, and some is special 702 * information used here, such as event and geometry management 703 * information. This information is (mostly) managed by tkWindow.c. 704 * WARNING: the declaration below must be kept consistent with the 705 * Tk_FakeWin structure in tk.h. If you change one, be sure to 706 * change the other!! 707 */ 708 709typedef struct TkWindow { 710 711 /* 712 * Structural information: 713 */ 714 715 Display *display; /* Display containing window. */ 716 TkDisplay *dispPtr; /* Tk's information about display 717 * for window. */ 718 int screenNum; /* Index of screen for window, among all 719 * those for dispPtr. */ 720 Visual *visual; /* Visual to use for window. If not default, 721 * MUST be set before X window is created. */ 722 int depth; /* Number of bits/pixel. */ 723 Window window; /* X's id for window. NULL means window 724 * hasn't actually been created yet, or it's 725 * been deleted. */ 726 struct TkWindow *childList; /* First in list of child windows, 727 * or NULL if no children. List is in 728 * stacking order, lowest window first.*/ 729 struct TkWindow *lastChildPtr; 730 /* Last in list of child windows (highest 731 * in stacking order), or NULL if no 732 * children. */ 733 struct TkWindow *parentPtr; /* Pointer to parent window (logical 734 * parent, not necessarily X parent). NULL 735 * means either this is the main window, or 736 * the window's parent has already been 737 * deleted. */ 738 struct TkWindow *nextPtr; /* Next higher sibling (in stacking order) 739 * in list of children with same parent. NULL 740 * means end of list. */ 741 TkMainInfo *mainPtr; /* Information shared by all windows 742 * associated with a particular main 743 * window. NULL means this window is 744 * a rogue that isn't associated with 745 * any application (at present, this 746 * only happens for the dummy windows 747 * used for "send" communication). */ 748 749 /* 750 * Name and type information for the window: 751 */ 752 753 char *pathName; /* Path name of window (concatenation 754 * of all names between this window and 755 * its top-level ancestor). This is a 756 * pointer into an entry in 757 * mainPtr->nameTable. NULL means that 758 * the window hasn't been completely 759 * created yet. */ 760 Tk_Uid nameUid; /* Name of the window within its parent 761 * (unique within the parent). */ 762 Tk_Uid classUid; /* Class of the window. NULL means window 763 * hasn't been given a class yet. */ 764 765 /* 766 * Geometry and other attributes of window. This information 767 * may not be updated on the server immediately; stuff that 768 * hasn't been reflected in the server yet is called "dirty". 769 * At present, information can be dirty only if the window 770 * hasn't yet been created. 771 */ 772 773 XWindowChanges changes; /* Geometry and other info about 774 * window. */ 775 unsigned int dirtyChanges; /* Bits indicate fields of "changes" 776 * that are dirty. */ 777 XSetWindowAttributes atts; /* Current attributes of window. */ 778 unsigned long dirtyAtts; /* Bits indicate fields of "atts" 779 * that are dirty. */ 780 781 unsigned int flags; /* Various flag values: these are all 782 * defined in tk.h (confusing, but they're 783 * needed there for some query macros). */ 784 785 /* 786 * Information kept by the event manager (tkEvent.c): 787 */ 788 789 TkEventHandler *handlerList;/* First in list of event handlers 790 * declared for this window, or 791 * NULL if none. */ 792#ifdef TK_USE_INPUT_METHODS 793 XIC inputContext; /* XIM input context. */ 794#endif /* TK_USE_INPUT_METHODS */ 795 796 /* 797 * Information used for event bindings (see "bind" and "bindtags" 798 * commands in tkCmds.c): 799 */ 800 801 ClientData *tagPtr; /* Points to array of tags used for bindings 802 * on this window. Each tag is a Tk_Uid. 803 * Malloc'ed. NULL means no tags. */ 804 int numTags; /* Number of tags at *tagPtr. */ 805 806 /* 807 * Information used by tkOption.c to manage options for the 808 * window. 809 */ 810 811 int optionLevel; /* -1 means no option information is 812 * currently cached for this window. 813 * Otherwise this gives the level in 814 * the option stack at which info is 815 * cached. */ 816 /* 817 * Information used by tkSelect.c to manage the selection. 818 */ 819 820 struct TkSelHandler *selHandlerList; 821 /* First in list of handlers for 822 * returning the selection in various 823 * forms. */ 824 825 /* 826 * Information used by tkGeometry.c for geometry management. 827 */ 828 829 Tk_GeomMgr *geomMgrPtr; /* Information about geometry manager for 830 * this window. */ 831 ClientData geomData; /* Argument for geometry manager procedures. */ 832 int reqWidth, reqHeight; /* Arguments from last call to 833 * Tk_GeometryRequest, or 0's if 834 * Tk_GeometryRequest hasn't been 835 * called. */ 836 int internalBorderLeft; /* Width of internal border of window 837 * (0 means no internal border). Geometry 838 * managers should not normally place children 839 * on top of the border. 840 * Fields for the other three sides are found 841 * below. */ 842 843 /* 844 * Information maintained by tkWm.c for window manager communication. 845 */ 846 847 struct TkWmInfo *wmInfoPtr; /* For top-level windows (and also 848 * for special Unix menubar and wrapper 849 * windows), points to structure with 850 * wm-related info (see tkWm.c). For 851 * other windows, this is NULL. */ 852 853 /* 854 * Information used by widget classes. 855 */ 856 857 Tk_ClassProcs *classProcsPtr; 858 ClientData instanceData; 859 860 /* 861 * Platform specific information private to each port. 862 */ 863 864 struct TkWindowPrivate *privatePtr; 865 866 /* 867 * More information used by tkGeometry.c for geometry management. 868 */ 869 870 /* The remaining fields of internal border. */ 871 int internalBorderRight; 872 int internalBorderTop; 873 int internalBorderBottom; 874 875 int minReqWidth; /* Minimum requested width. */ 876 int minReqHeight; /* Minimum requested height. */ 877} TkWindow; 878 879/* 880 * The following structure is used as a two way map between integers 881 * and strings, usually to map between an internal C representation 882 * and the strings used in Tcl. 883 */ 884 885typedef struct TkStateMap { 886 int numKey; /* Integer representation of a value. */ 887 char *strKey; /* String representation of a value. */ 888} TkStateMap; 889 890/* 891 * This structure is used by the Mac and Window porting layers as 892 * the internal representation of a clip_mask in a GC. 893 */ 894 895typedef struct TkpClipMask { 896 int type; /* One of TKP_CLIP_PIXMAP or TKP_CLIP_REGION */ 897 union { 898 Pixmap pixmap; 899 TkRegion region; 900 } value; 901} TkpClipMask; 902 903#define TKP_CLIP_PIXMAP 0 904#define TKP_CLIP_REGION 1 905 906/* 907 * Pointer to first entry in list of all displays currently known. 908 */ 909 910extern TkDisplay *tkDisplayList; 911 912/* 913 * Return values from TkGrabState: 914 */ 915 916#define TK_GRAB_NONE 0 917#define TK_GRAB_IN_TREE 1 918#define TK_GRAB_ANCESTOR 2 919#define TK_GRAB_EXCLUDED 3 920 921/* 922 * The macro below is used to modify a "char" value (e.g. by casting 923 * it to an unsigned character) so that it can be used safely with 924 * macros such as isspace. 925 */ 926 927#define UCHAR(c) ((unsigned char) (c)) 928 929/* 930 * The following symbol is used in the mode field of FocusIn events 931 * generated by an embedded application to request the input focus from 932 * its container. 933 */ 934 935#define EMBEDDED_APP_WANTS_FOCUS (NotifyNormal + 20) 936 937/* 938 * The following special modifier mask bits are defined, to indicate 939 * logical modifiers such as Meta and Alt that may float among the 940 * actual modifier bits. 941 */ 942 943#define META_MASK (AnyModifier<<1) 944#define ALT_MASK (AnyModifier<<2) 945 946/* 947 * Object types not declared in tkObj.c need to be mentioned here so 948 * they can be properly registered with Tcl: 949 */ 950 951extern Tcl_ObjType tkBorderObjType; 952extern Tcl_ObjType tkBitmapObjType; 953extern Tcl_ObjType tkColorObjType; 954extern Tcl_ObjType tkCursorObjType; 955extern Tcl_ObjType tkFontObjType; 956extern Tcl_ObjType tkOptionObjType; 957extern Tcl_ObjType tkStateKeyObjType; 958 959/* 960 * Miscellaneous variables shared among Tk modules but not exported 961 * to the outside world: 962 */ 963 964extern Tk_SmoothMethod tkBezierSmoothMethod; 965extern Tk_ImageType tkBitmapImageType; 966extern Tk_PhotoImageFormat tkImgFmtGIF; 967extern void (*tkHandleEventProc) _ANSI_ARGS_(( 968 XEvent* eventPtr)); 969extern Tk_PhotoImageFormat tkImgFmtPPM; 970extern TkMainInfo *tkMainWindowList; 971extern Tk_ImageType tkPhotoImageType; 972extern Tcl_HashTable tkPredefBitmapTable; 973extern int tkSendSerial; 974 975#include "tkIntDecls.h" 976 977#ifdef BUILD_tk 978# undef TCL_STORAGE_CLASS 979# define TCL_STORAGE_CLASS DLLEXPORT 980#endif 981 982/* 983 * Internal procedures shared among Tk modules but not exported 984 * to the outside world: 985 */ 986 987EXTERN int Tk_BellObjCmd _ANSI_ARGS_((ClientData clientData, 988 Tcl_Interp *interp, int objc, 989 Tcl_Obj *CONST objv[])); 990EXTERN int Tk_BindObjCmd _ANSI_ARGS_((ClientData clientData, 991 Tcl_Interp *interp, int objc, 992 Tcl_Obj *CONST objv[])); 993EXTERN int Tk_BindtagsObjCmd _ANSI_ARGS_((ClientData clientData, 994 Tcl_Interp *interp, int objc, 995 Tcl_Obj *CONST objv[])); 996EXTERN int Tk_ButtonObjCmd _ANSI_ARGS_((ClientData clientData, 997 Tcl_Interp *interp, int objc, 998 Tcl_Obj *CONST objv[])); 999EXTERN int Tk_CanvasObjCmd _ANSI_ARGS_((ClientData clientData, 1000 Tcl_Interp *interp, int argc, 1001 Tcl_Obj *CONST objv[])); 1002EXTERN int Tk_CheckbuttonObjCmd _ANSI_ARGS_(( 1003 ClientData clientData, 1004 Tcl_Interp *interp, int objc, 1005 Tcl_Obj *CONST objv[])); 1006EXTERN int Tk_ClipboardObjCmd _ANSI_ARGS_(( 1007 ClientData clientData, Tcl_Interp *interp, 1008 int objc, Tcl_Obj *CONST objv[])); 1009EXTERN int Tk_ChooseColorObjCmd _ANSI_ARGS_(( 1010 ClientData clientData, Tcl_Interp *interp, 1011 int objc, Tcl_Obj *CONST objv[])); 1012EXTERN int Tk_ChooseDirectoryObjCmd _ANSI_ARGS_(( 1013 ClientData clientData, Tcl_Interp *interp, 1014 int objc, Tcl_Obj *CONST objv[])); 1015EXTERN int Tk_ChooseFontObjCmd _ANSI_ARGS_((ClientData clientData, 1016 Tcl_Interp *interp, int objc, 1017 Tcl_Obj *CONST objv[])); 1018EXTERN int Tk_DestroyObjCmd _ANSI_ARGS_((ClientData clientData, 1019 Tcl_Interp *interp, int objc, 1020 Tcl_Obj *CONST objv[])); 1021EXTERN int Tk_EntryObjCmd _ANSI_ARGS_((ClientData clientData, 1022 Tcl_Interp *interp, int objc, 1023 Tcl_Obj *CONST objv[])); 1024EXTERN int Tk_EventObjCmd _ANSI_ARGS_((ClientData clientData, 1025 Tcl_Interp *interp, int objc, 1026 Tcl_Obj *CONST objv[])); 1027EXTERN int Tk_FileeventCmd _ANSI_ARGS_((ClientData clientData, 1028 Tcl_Interp *interp, int argc, char **argv)); 1029EXTERN int Tk_FrameObjCmd _ANSI_ARGS_((ClientData clientData, 1030 Tcl_Interp *interp, int objc, 1031 Tcl_Obj *CONST objv[])); 1032EXTERN int Tk_FocusObjCmd _ANSI_ARGS_((ClientData clientData, 1033 Tcl_Interp *interp, int objc, 1034 Tcl_Obj *CONST objv[])); 1035EXTERN int Tk_FontObjCmd _ANSI_ARGS_((ClientData clientData, 1036 Tcl_Interp *interp, int objc, 1037 Tcl_Obj *CONST objv[])); 1038EXTERN int Tk_GetOpenFileObjCmd _ANSI_ARGS_(( 1039 ClientData clientData, 1040 Tcl_Interp *interp, int objc, 1041 Tcl_Obj *CONST objv[])); 1042EXTERN int Tk_GetSaveFileObjCmd _ANSI_ARGS_(( 1043 ClientData clientData, 1044 Tcl_Interp *interp, int objc, 1045 Tcl_Obj *CONST objv[])); 1046EXTERN int Tk_GrabObjCmd _ANSI_ARGS_((ClientData clientData, 1047 Tcl_Interp *interp, int objc, 1048 Tcl_Obj *CONST objv[])); 1049EXTERN int Tk_GridObjCmd _ANSI_ARGS_((ClientData clientData, 1050 Tcl_Interp *interp, int objc, 1051 Tcl_Obj *CONST objv[])); 1052EXTERN int Tk_ImageObjCmd _ANSI_ARGS_((ClientData clientData, 1053 Tcl_Interp *interp, int objc, 1054 Tcl_Obj *CONST objv[])); 1055EXTERN int Tk_LabelObjCmd _ANSI_ARGS_((ClientData clientData, 1056 Tcl_Interp *interp, int objc, 1057 Tcl_Obj *CONST objv[])); 1058EXTERN int Tk_LabelframeObjCmd _ANSI_ARGS_((ClientData clientData, 1059 Tcl_Interp *interp, int objc, 1060 Tcl_Obj *CONST objv[])); 1061EXTERN int Tk_ListboxObjCmd _ANSI_ARGS_((ClientData clientData, 1062 Tcl_Interp *interp, int objc, 1063 Tcl_Obj *CONST objv[])); 1064EXTERN int Tk_LowerObjCmd _ANSI_ARGS_((ClientData clientData, 1065 Tcl_Interp *interp, int objc, 1066 Tcl_Obj *CONST objv[])); 1067EXTERN int Tk_MenubuttonObjCmd _ANSI_ARGS_((ClientData clientData, 1068 Tcl_Interp *interp, int objc, 1069 Tcl_Obj *CONST objv[])); 1070EXTERN int Tk_MessageBoxObjCmd _ANSI_ARGS_((ClientData clientData, 1071 Tcl_Interp *interp, int objc, 1072 Tcl_Obj *CONST objv[])); 1073EXTERN int Tk_MessageObjCmd _ANSI_ARGS_((ClientData clientData, 1074 Tcl_Interp *interp, int objc, 1075 Tcl_Obj *CONST objv[])); 1076EXTERN int Tk_PanedWindowObjCmd _ANSI_ARGS_(( 1077 ClientData clientData, 1078 Tcl_Interp *interp, int objc, 1079 Tcl_Obj *CONST objv[])); 1080EXTERN int Tk_OptionObjCmd _ANSI_ARGS_((ClientData clientData, 1081 Tcl_Interp *interp, int objc, 1082 Tcl_Obj *CONST objv[])); 1083EXTERN int Tk_PackObjCmd _ANSI_ARGS_((ClientData clientData, 1084 Tcl_Interp *interp, int objc, 1085 Tcl_Obj *CONST objv[])); 1086EXTERN int Tk_PlaceObjCmd _ANSI_ARGS_((ClientData clientData, 1087 Tcl_Interp *interp, int objc, 1088 Tcl_Obj *CONST objv[])); 1089EXTERN int Tk_RadiobuttonObjCmd _ANSI_ARGS_(( 1090 ClientData clientData, 1091 Tcl_Interp *interp, int objc, 1092 Tcl_Obj *CONST objv[])); 1093EXTERN int Tk_RaiseObjCmd _ANSI_ARGS_((ClientData clientData, 1094 Tcl_Interp *interp, int objc, 1095 Tcl_Obj *CONST objv[])); 1096EXTERN int Tk_ScaleObjCmd _ANSI_ARGS_((ClientData clientData, 1097 Tcl_Interp *interp, int objc, 1098 Tcl_Obj *CONST objv[])); 1099EXTERN int Tk_ScrollbarCmd _ANSI_ARGS_((ClientData clientData, 1100 Tcl_Interp *interp, int argc, CONST char **argv)); 1101EXTERN int Tk_SelectionObjCmd _ANSI_ARGS_((ClientData clientData, 1102 Tcl_Interp *interp, int objc, 1103 Tcl_Obj *CONST objv[])); 1104EXTERN int Tk_SendCmd _ANSI_ARGS_((ClientData clientData, 1105 Tcl_Interp *interp, int argc, CONST char **argv)); 1106EXTERN int Tk_SendObjCmd _ANSI_ARGS_((ClientData clientData, 1107 Tcl_Interp *interp, int objc, 1108 Tcl_Obj *CONST objv[])); 1109EXTERN int Tk_SpinboxObjCmd _ANSI_ARGS_((ClientData clientData, 1110 Tcl_Interp *interp, int objc, 1111 Tcl_Obj *CONST objv[])); 1112EXTERN int Tk_TextCmd _ANSI_ARGS_((ClientData clientData, 1113 Tcl_Interp *interp, int argc, CONST char **argv)); 1114EXTERN int Tk_TkObjCmd _ANSI_ARGS_((ClientData clientData, 1115 Tcl_Interp *interp, int objc, 1116 Tcl_Obj *CONST objv[])); 1117EXTERN int Tk_TkwaitObjCmd _ANSI_ARGS_((ClientData clientData, 1118 Tcl_Interp *interp, int objc, 1119 Tcl_Obj *CONST objv[])); 1120EXTERN int Tk_ToplevelObjCmd _ANSI_ARGS_((ClientData clientData, 1121 Tcl_Interp *interp, int objc, 1122 Tcl_Obj *CONST objv[])); 1123EXTERN int Tk_UpdateObjCmd _ANSI_ARGS_((ClientData clientData, 1124 Tcl_Interp *interp, int objc, 1125 Tcl_Obj *CONST objv[])); 1126EXTERN int Tk_WinfoObjCmd _ANSI_ARGS_((ClientData clientData, 1127 Tcl_Interp *interp, int objc, 1128 Tcl_Obj *CONST objv[])); 1129EXTERN int Tk_WmObjCmd _ANSI_ARGS_((ClientData clientData, 1130 Tcl_Interp *interp, int objc, 1131 Tcl_Obj *CONST objv[])); 1132 1133EXTERN void TkEventInit _ANSI_ARGS_((void)); 1134 1135EXTERN void TkRegisterObjTypes _ANSI_ARGS_((void)); 1136 1137EXTERN int TkCreateMenuCmd _ANSI_ARGS_((Tcl_Interp *interp)); 1138EXTERN int TkDeadAppCmd _ANSI_ARGS_((ClientData clientData, 1139 Tcl_Interp *interp, int argc, CONST char **argv)); 1140 1141EXTERN int TkpTestembedCmd _ANSI_ARGS_((ClientData clientData, 1142 Tcl_Interp *interp, int argc, CONST char **argv)); 1143EXTERN int TkCanvasGetCoordObj _ANSI_ARGS_((Tcl_Interp *interp, 1144 Tk_Canvas canvas, Tcl_Obj *obj, 1145 double *doublePtr)); 1146EXTERN int TkCanvasDashParseProc _ANSI_ARGS_(( 1147 ClientData clientData, Tcl_Interp *interp, 1148 Tk_Window tkwin, CONST char *value, char *widgRec, 1149 int offset)); 1150EXTERN char * TkCanvasDashPrintProc _ANSI_ARGS_(( 1151 ClientData clientData, Tk_Window tkwin, 1152 char *widgRec, int offset, 1153 Tcl_FreeProc **freeProcPtr)); 1154EXTERN int TkGetDoublePixels _ANSI_ARGS_((Tcl_Interp *interp, 1155 Tk_Window tkwin, CONST char *string, 1156 double *doublePtr)); 1157EXTERN int TkOffsetParseProc _ANSI_ARGS_(( 1158 ClientData clientData, Tcl_Interp *interp, 1159 Tk_Window tkwin, CONST char *value, char *widgRec, 1160 int offset)); 1161EXTERN char * TkOffsetPrintProc _ANSI_ARGS_(( 1162 ClientData clientData, Tk_Window tkwin, 1163 char *widgRec, int offset, 1164 Tcl_FreeProc **freeProcPtr)); 1165EXTERN int TkOrientParseProc _ANSI_ARGS_(( 1166 ClientData clientData, Tcl_Interp *interp, 1167 Tk_Window tkwin, CONST char *value, 1168 char *widgRec, int offset)); 1169EXTERN char * TkOrientPrintProc _ANSI_ARGS_(( 1170 ClientData clientData, Tk_Window tkwin, 1171 char *widgRec, int offset, 1172 Tcl_FreeProc **freeProcPtr)); 1173EXTERN int TkPixelParseProc _ANSI_ARGS_(( 1174 ClientData clientData, Tcl_Interp *interp, 1175 Tk_Window tkwin, CONST char *value, char *widgRec, 1176 int offset)); 1177EXTERN char * TkPixelPrintProc _ANSI_ARGS_(( 1178 ClientData clientData, Tk_Window tkwin, 1179 char *widgRec, int offset, 1180 Tcl_FreeProc **freeProcPtr)); 1181EXTERN int TkPostscriptImage _ANSI_ARGS_((Tcl_Interp *interp, 1182 Tk_Window tkwin, Tk_PostscriptInfo psInfo, 1183 XImage *ximage, int x, int y, int width, 1184 int height)); 1185EXTERN int TkSmoothParseProc _ANSI_ARGS_((ClientData clientData, 1186 Tcl_Interp *interp, Tk_Window tkwin, 1187 CONST char *value, char *recordPtr, int offset)); 1188EXTERN char * TkSmoothPrintProc _ANSI_ARGS_((ClientData clientData, 1189 Tk_Window tkwin, char *recordPtr, int offset, 1190 Tcl_FreeProc **freeProcPtr)); 1191EXTERN int TkStateParseProc _ANSI_ARGS_(( 1192 ClientData clientData, Tcl_Interp *interp, 1193 Tk_Window tkwin, CONST char *value, 1194 char *widgRec, int offset)); 1195EXTERN char * TkStatePrintProc _ANSI_ARGS_(( 1196 ClientData clientData, Tk_Window tkwin, 1197 char *widgRec, int offset, 1198 Tcl_FreeProc **freeProcPtr)); 1199EXTERN int TkTileParseProc _ANSI_ARGS_(( 1200 ClientData clientData, Tcl_Interp *interp, 1201 Tk_Window tkwin, CONST char *value, char *widgRec, 1202 int offset)); 1203EXTERN char * TkTilePrintProc _ANSI_ARGS_(( 1204 ClientData clientData, Tk_Window tkwin, 1205 char *widgRec, int offset, 1206 Tcl_FreeProc **freeProcPtr)); 1207EXTERN void TkCreateExitHandler _ANSI_ARGS_((Tcl_ExitProc *proc, 1208 ClientData clientData)); 1209EXTERN void TkDeleteExitHandler _ANSI_ARGS_((Tcl_ExitProc *proc, 1210 ClientData clientData)); 1211EXTERN Tcl_ExitProc TkFinalize; 1212EXTERN void TkPrintPadAmount _ANSI_ARGS_((Tcl_Interp *interp, 1213 char *buffer, int pad1, int pad2)); 1214EXTERN int TkParsePadAmount _ANSI_ARGS_((Tcl_Interp *interp, 1215 Tk_Window tkwin, Tcl_Obj *objPtr, 1216 int *pad1Ptr, int *pad2Ptr)); 1217EXTERN int TkpAlwaysShowSelection _ANSI_ARGS_((Tk_Window tkwin)); 1218 1219/* 1220 * Unsupported commands. 1221 */ 1222EXTERN int TkUnsupported1ObjCmd _ANSI_ARGS_(( 1223 ClientData clientData, Tcl_Interp *interp, 1224 int objc, Tcl_Obj *CONST objv[])); 1225 1226# undef TCL_STORAGE_CLASS 1227# define TCL_STORAGE_CLASS DLLIMPORT 1228 1229#endif /* _TKINT */ 1230