4 * Declarations for things used internally by the Tk
5 * procedures but not exported outside the module.
7 * Copyright 1990-1992 Regents of the University of California.
8 * Permission to use, copy, modify, and distribute this
9 * software and its documentation for any purpose and without
10 * fee is hereby granted, provided that the above copyright
11 * notice appear in all copies. The University of California
12 * makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without
14 * express or implied warranty.
16 * $Header: /user6/ouster/wish/RCS/tkInt.h,v 1.65 92/08/21 11:42:27 ouster Exp $ SPRITE (Berkeley)
25 #include <X11/Xlibint.h>
29 #include <X11/Xutil.h>
41 #define META_MASK (AnyModifier<<1)
42 #define ALT_MASK (AnyModifier<<2)
45 (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
48 * One of the following structures is maintained for each display
49 * containing a window managed by Tk:
52 typedef struct TkDisplay
{
53 Display
*display
; /* Xlib's info about display. */
54 struct TkDisplay
*nextPtr
; /* Next in list of all displays. */
55 char *name
; /* Name of display (with any screen
56 * identifier removed). Malloc-ed. */
57 Time lastEventTime
; /* Time of last event received for this
61 * Information used by tkEvent.c only:
64 struct TkWindow
*mouseMainPtr
;
65 /* Pointer to the main window of this
66 * display that currently contains the
67 * mouse pointer. NULL means the pointer
68 * isn't in a main window managed by
72 * Information used by tkBind.c only:
75 int firstKeycode
; /* First keycode supported by
77 int lastKeycode
; /* Last keycode supported by
79 int symsPerCode
; /* Number of KeySyms in "keySyms"
80 * for each keycode. 0 means the
81 * keysym information hasn't been
82 * retrieved from the server yet. */
83 KeySym
*keySyms
; /* Array of KeySyms, returned by
84 * XGetKeyboardMapping. */
85 unsigned int modeModMask
;
86 unsigned int metaModMask
;
87 unsigned int altModMask
;
90 * Information used by tkError.c only:
93 struct TkErrorHandler
*errorPtr
;
94 /* First in list of error handlers
95 * for this display. NULL means
96 * no handlers exist at present. */
97 int deleteCount
; /* Counts # of handlers deleted since
98 * last time inactive handlers were
99 * garbage-collected. When this number
100 * gets big, handlers get cleaned up. */
103 * Information used by tkSend.c only:
106 Tk_Window commWindow
; /* Window used for communication
107 * between interpreters during "send"
108 * commands. NULL means send info hasn't
109 * been initialized yet. */
110 Atom commProperty
; /* X's name for comm property. */
111 Atom registryProperty
; /* X's name for property containing
112 * registry of interpreter names. */
115 * Information used by tkSelect.c only:
118 Tk_Window selectionOwner
; /* Current owner of selection, or
119 * NULL if selection isn't owned by
120 * a window in this process. */
121 int selectionSerial
; /* Serial number of last XSelectionSetOwner
122 * request we made to server (used to
123 * filter out redundant SelectionClear
125 Time selectionTime
; /* Timestamp used to acquire selection. */
126 Atom multipleAtom
; /* Atom for MULTIPLE. None means
127 * selection stuff isn't initialized. */
128 Atom incrAtom
; /* Atom for INCR. */
129 Atom targetsAtom
; /* Atom for TARGETS. */
130 Atom timestampAtom
; /* Atom for TIMESTAMP. */
131 Atom textAtom
; /* Atom for TEXT. */
132 Atom compoundTextAtom
; /* Atom for COMPOUND_TEXT. */
135 * Information used by tkAtom.c only:
138 int atomInit
; /* 0 means stuff below hasn't been
139 * initialized yet. */
140 Tcl_HashTable nameTable
; /* Maps from names to Atom's. */
141 Tcl_HashTable atomTable
; /* Maps from Atom's back to names. */
144 * Information used by tkCursor.c only:
147 Font cursorFont
; /* Font to use for standard cursors.
148 * None means font not loaded yet. */
151 * Information used by tkGrab.c only:
154 struct TkWindow
*grabWinPtr
;
155 /* Window in which the pointer is currently
156 * grabbed, or NULL if none. */
157 struct TkWindow
*ungrabWinPtr
;
158 /* Window to which pointer should be returned
159 * when the current grab ends (i.e. the
160 * window that the mouse is really on top
162 struct TkWindow
*buttonWinPtr
;
163 /* Window in which first mouse button was
164 * pressed while grab was in effect, or NULL
165 * if no such press in effect. */
166 struct TkWindow
*pointerWinPtr
;
167 /* The window that officially contains the
168 * pointer, as far as this application is
169 * concerned. If a grab is in effect then
170 * this may not be the window that's underneath
171 * the pointer. NULL means the application
172 * doesn't consider the pointer to be in any
174 struct TkWindow
*serverWinPtr
;
175 /* The window that contains the pointer, as
176 * far as the X server is concerned. This
177 * field gets set on every Enter or Leave
178 * event even if the grab code eventually
179 * discards the event. NULL means the server
180 * thinks the pointer is outside any window
181 * of any application on this screen. */
182 int grabFlags
; /* Miscellaneous flag values. See definitions
185 struct TkWindow
*focusPtr
; /* Identifies window that currently has the
186 * focus (or that will get the focus the next
187 * time the pointer enters any of the top-level
188 * windows associated with this display).
189 * NULL means nobody has the focus.
190 * Managed by tkEvent.c. */
194 * One of the following structures exists for each error handler
195 * created by a call to Tk_CreateErrorHandler. The structure
196 * is managed by tkError.c.
199 typedef struct TkErrorHandler
{
200 TkDisplay
*dispPtr
; /* Display to which handler applies. */
201 unsigned long firstRequest
; /* Only errors with serial numbers
202 * >= to this are considered. */
203 unsigned long lastRequest
; /* Only errors with serial numbers
204 * <= to this are considered. This
205 * field is filled in when XUnhandle
206 * is called. -1 means XUnhandle
207 * hasn't been called yet. */
208 int error
; /* Consider only errors with this
209 * error_code (-1 means consider
211 int request
; /* Consider only errors with this
212 * major request code (-1 means
213 * consider all major codes). */
214 int minorCode
; /* Consider only errors with this
215 * minor request code (-1 means
216 * consider all minor codes). */
217 Tk_ErrorProc
*errorProc
; /* Procedure to invoke when a matching
218 * error occurs. NULL means just ignore
220 ClientData clientData
; /* Arbitrary value to pass to
222 struct TkErrorHandler
*nextPtr
;
223 /* Pointer to next older handler for
224 * this display, or NULL for end of
229 * One of the following structures exists for each event handler
230 * created by calling Tk_CreateEventHandler. This information
231 * is used by tkEvent.c only.
234 typedef struct TkEventHandler
{
235 unsigned long mask
; /* Events for which to invoke
237 Tk_EventProc
*proc
; /* Procedure to invoke when an event
239 ClientData clientData
; /* Argument to pass to proc. */
240 struct TkEventHandler
*nextPtr
;
241 /* Next in list of handlers
242 * associated with window (NULL means
247 * One of the following structures exists for each selection
248 * handler created by calling Tk_CreateSelHandler. This
249 * information is used by tkSelect.c only.
252 typedef struct TkSelHandler
{
253 Atom target
; /* Target type for selection
254 * conversion, such as TARGETS or
256 Atom format
; /* Format in which selection
257 * info will be returned, such
258 * as STRING or ATOM. */
259 Tk_SelectionProc
*proc
; /* Procedure to generate selection
261 ClientData clientData
; /* Argument to pass to proc. */
262 int size
; /* Size of units returned by proc
263 * (8 for STRING, 32 for almost
265 struct TkSelHandler
*nextPtr
;
266 /* Next selection handler associated
267 * with same window (NULL for end of
272 * Tk keeps one of the following data structures for each main
273 * window (created by a call to Tk_CreateMainWindow). It stores
274 * information that is shared by all of the windows associated
275 * with a particular main window.
278 typedef struct TkMainInfo
{
279 struct TkWindow
*winPtr
; /* Pointer to main window. */
280 Tcl_Interp
*interp
; /* Interpreter associated with application. */
281 Tcl_HashTable nameTable
; /* Hash table mapping path names to TkWindow
282 * structs for all windows related to this
283 * main window. Managed by tkWindow.c. */
284 Tk_BindingTable bindingTable
;
285 /* Used in conjunction with "bind" command
286 * to bind events to Tcl commands. */
288 /* struct TkWindow *focusPtr; */ /* Identifies window that currently has the
289 * focus (or that will get the focus the next
290 * time the pointer enters any of the top-level
291 * windows associated with this display).
292 * NULL means nobody has the focus.
293 * Managed by tkEvent.c. */
294 struct ElArray
*optionRootPtr
;
295 /* Top level of option hierarchy for this
296 * main window. NULL means uninitialized.
297 * Managed by tkOption.c. */
301 * Tk keeps one of the following structures for each window.
302 * Some of the information (like size and location) is a shadow
303 * of information managed by the X server, and some is special
304 * information used here, such as event and geometry management
305 * information. This information is (mostly) managed by tkWindow.c.
306 * WARNING: the declaration below must be kept consistent with the
307 * Tk_ClientWindow structure in tk.h. If you change one, be sure to
311 typedef struct TkWindow
{
314 * Structural information:
317 Display
*display
; /* Display containing window. */
318 TkDisplay
*dispPtr
; /* Tk's information about display
320 int screenNum
; /* Index of screen for window, among all
321 * those for dispPtr. */
322 Window window
; /* X's id for window. NULL means window
323 * hasn't actually been created yet, or it's
325 struct TkWindow
*childList
; /* First in list of child windows,
326 * or NULL if no children. */
327 struct TkWindow
*parentPtr
; /* Pointer to parent window (logical
328 * parent, not necessarily X parent), or
329 * NULL if this is a main window. */
330 struct TkWindow
*nextPtr
; /* Next in list of children with
331 * same parent (NULL if end of
333 TkMainInfo
*mainPtr
; /* Information shared by all windows
334 * associated with a particular main
335 * window. NULL means this window is
336 * a rogue that isn't associated with
337 * any application (at present, there
338 * should never be any rogues). */
341 * Name and type information for the window:
344 char *pathName
; /* Path name of window (concatenation
345 * of all names between this window and
346 * its top-level ancestor). This is a
347 * pointer into an entry in
348 * mainPtr->nameTable or NULL if mainPtr
350 Tk_Uid nameUid
; /* Name of the window within its parent
351 * (unique within the parent). */
352 Tk_Uid classUid
; /* Class of the window. NULL means window
353 * hasn't been given a class yet. */
356 * Geometry and other attributes of window. This information
357 * may not be updated on the server immediately; stuff that
358 * hasn't been reflected in the server yet is called "dirty".
359 * At present, information can be dirty only if the window
360 * hasn't yet been created.
363 XWindowChanges changes
; /* Geometry and other info about
365 unsigned int dirtyChanges
; /* Bits indicate fields of "changes"
367 XSetWindowAttributes atts
; /* Current attributes of window. */
368 unsigned long dirtyAtts
; /* Bits indicate fields of "atts"
371 unsigned int flags
; /* Various flag values: these are all
372 * defined in tk.h (confusing, but they're
373 * needed there for some query macros). */
376 * Information kept by the event manager (tkEvent.c):
379 TkEventHandler
*handlerList
;/* First in list of event handlers
380 * declared for this window, or
383 * Information related to input focussing (tkEvent.c):
386 Tk_FocusProc
*focusProc
; /* Procedure to invoke when this window
387 * gets or loses the input focus. NULL
388 * means this window is not prepared to
389 * receive the focus. */
390 ClientData focusData
; /* Arbitrary value to pass to focusProc. */
393 * Information used by tkOption.c to manage options for the
397 int optionLevel
; /* -1 means no option information is
398 * currently cached for this window.
399 * Otherwise this gives the level in
400 * the option stack at which info is
403 * Information used by tkSelect.c to manage the selection.
406 TkSelHandler
*selHandlerList
;
407 /* First in list of handlers for
408 * returning the selection in various
410 Tk_LostSelProc
*selClearProc
;
411 ClientData selClearData
; /* Info to pass to selClearProc. */
414 * Information used by tkGeometry.c for geometry management.
417 Tk_GeometryProc
*geomProc
; /* Procedure to handle geometry
418 * requests (NULL means no window is
420 ClientData geomData
; /* Argument for geomProc. */
421 int reqWidth
, reqHeight
; /* Arguments from last call to
422 * Tk_GeometryRequest, or 0's if
423 * Tk_GeometryRequest hasn't been
425 int internalBorderWidth
; /* Width of internal border of window
426 * (0 means no internal border). Geom.
427 * mgr. should not place children on top
431 * Information maintained by tkWm.c for window manager communication.
434 struct TkWmInfo
*wmInfoPtr
; /* For top-level windows, points to
435 * structure with wm-related info (see
436 * tkWm.c). For other windows, this
441 * The context below is used to map from an X window id to
442 * the TkWindow structure associated with the window.
445 extern XContext tkWindowContext
;
448 * Pointer to first entry in list of all displays currently known.
451 extern TkDisplay
*tkDisplayList
;
454 * Flags passed to TkMeasureChars:
457 #define TK_WHOLE_WORDS 1
458 #define TK_AT_LEAST_ONE 2
459 #define TK_PARTIAL_OK 4
460 #define TK_NEWLINES_NOT_SPECIAL 8
463 * Location of library directory containing Tk scripts. This value
464 * is put in the $tkLibrary variable for each application.
469 #define TK_LIBRARY "res/tk"
471 #define TK_LIBRARY "/usr/local/lib/tk"
476 * See tkShare.c for explanation of following disgusting variable:
479 extern XEvent
*tkShareEventPtr
;
482 * Secret way to inhibit event collapsing. -deh
485 extern int tkCollapseMotion
;
488 * Secret way to break out to Tk_MainLoop. -deh
491 extern int tkMustExit
;
494 * Miscellaneous variables shared among Tk modules but not exported
495 * to the outside world:
498 extern Tk_Uid tkActiveUid
;
499 extern Tk_Uid tkDisabledUid
;
500 extern Tk_Uid tkNormalUid
;
503 * Internal procedures shared among Tk modules but not exported
504 * to the outside world:
507 extern int TkAreaToPolygon
_ANSI_ARGS_((double *polyPtr
,
508 int numPoints
, double *rectPtr
));
509 extern void TkBezierPoints
_ANSI_ARGS_((double control
[],
510 int numSteps
, double *coordPtr
));
511 extern void TkBindError
_ANSI_ARGS_((Tcl_Interp
*interp
));
512 extern void TkBindEventProc
_ANSI_ARGS_((TkWindow
*winPtr
,
514 extern Time TkCurrentTime
_ANSI_ARGS_((TkDisplay
*dispPtr
));
515 extern int TkDeadAppCmd
_ANSI_ARGS_((ClientData clientData
,
516 Tcl_Interp
*interp
, int argc
, char **argv
));
517 extern void TkDisplayChars
_ANSI_ARGS_((Display
*display
,
518 Drawable drawable
, GC gc
,
519 XFontStruct
*fontStructPtr
, char *string
,
520 int numChars
, int x
, int y
, int flags
));
521 extern void TkEventDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
522 extern void TkFocusEventProc
_ANSI_ARGS_((TkWindow
*winPtr
,
524 extern void TkGetButtPoints
_ANSI_ARGS_((double p1
[], double p2
[],
525 double width
, int project
, double m1
[],
527 extern int TkGetInterpNames
_ANSI_ARGS_((Tcl_Interp
*interp
,
529 extern int TkGetMiterPoints
_ANSI_ARGS_((double p1
[], double p2
[],
530 double p3
[], double width
, double m1
[],
532 extern void TkGrabDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
533 extern int TkLineToArea
_ANSI_ARGS_((double end1Ptr
[2],
534 double end2Ptr
[2], double rectPtr
[4]));
535 extern double TkLineToPoint
_ANSI_ARGS_((double end1Ptr
[2],
536 double end2Ptr
[2], double pointPtr
[2]));
537 extern int TkMeasureChars
_ANSI_ARGS_((XFontStruct
*fontStructPtr
,
538 char *source
, int maxChars
, int startX
, int maxX
,
539 int flags
, int *nextXPtr
));
540 extern void TkOptionDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
541 extern int TkOvalToArea
_ANSI_ARGS_((double *ovalPtr
,
543 extern double TkOvalToPoint
_ANSI_ARGS_((double ovalPtr
[4],
544 double width
, int filled
, double pointPtr
[2]));
545 extern int TkPointerEvent
_ANSI_ARGS_((XEvent
*eventPtr
,
547 extern int TkPolygonToArea
_ANSI_ARGS_((double *polyPtr
,
548 int numPoints
, double *rectPtr
));
549 extern double TkPolygonToPoint
_ANSI_ARGS_((double *polyPtr
,
550 int numPoints
, double *pointPtr
));
551 extern void TkSelDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
552 extern void TkSelEventProc
_ANSI_ARGS_((Tk_Window tkwin
,
554 extern void TkSelPropProc
_ANSI_ARGS_((XEvent
*eventPtr
));
555 extern void TkUnderlineChars
_ANSI_ARGS_((Display
*display
,
556 Drawable drawable
, GC gc
,
557 XFontStruct
*fontStructPtr
, char *string
,
558 int x
, int y
, int flags
, int firstChar
,
560 extern void TkWmDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
561 extern int TkWmMapWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
562 extern void TkWmSetClass
_ANSI_ARGS_((TkWindow
*winPtr
));
563 extern void TkWmNewWindow
_ANSI_ARGS_((TkWindow
*winPtr
));