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>
42 * One of the following structures is maintained for each display
43 * containing a window managed by Tk:
46 typedef struct TkDisplay
{
47 Display
*display
; /* Xlib's info about display. */
48 struct TkDisplay
*nextPtr
; /* Next in list of all displays. */
49 char *name
; /* Name of display (with any screen
50 * identifier removed). Malloc-ed. */
51 Time lastEventTime
; /* Time of last event received for this
55 * Information used by tkEvent.c only:
58 struct TkWindow
*mouseMainPtr
;
59 /* Pointer to the main window of this
60 * display that currently contains the
61 * mouse pointer. NULL means the pointer
62 * isn't in a main window managed by
66 * Information used by tkBind.c only:
69 int firstKeycode
; /* First keycode supported by
71 int lastKeycode
; /* Last keycode supported by
73 int symsPerCode
; /* Number of KeySyms in "keySyms"
74 * for each keycode. 0 means the
75 * keysym information hasn't been
76 * retrieved from the server yet. */
77 KeySym
*keySyms
; /* Array of KeySyms, returned by
78 * XGetKeyboardMapping. */
81 * Information used by tkError.c only:
84 struct TkErrorHandler
*errorPtr
;
85 /* First in list of error handlers
86 * for this display. NULL means
87 * no handlers exist at present. */
88 int deleteCount
; /* Counts # of handlers deleted since
89 * last time inactive handlers were
90 * garbage-collected. When this number
91 * gets big, handlers get cleaned up. */
94 * Information used by tkSend.c only:
97 Tk_Window commWindow
; /* Window used for communication
98 * between interpreters during "send"
99 * commands. NULL means send info hasn't
100 * been initialized yet. */
101 Atom commProperty
; /* X's name for comm property. */
102 Atom registryProperty
; /* X's name for property containing
103 * registry of interpreter names. */
106 * Information used by tkSelect.c only:
109 Tk_Window selectionOwner
; /* Current owner of selection, or
110 * NULL if selection isn't owned by
111 * a window in this process. */
112 int selectionSerial
; /* Serial number of last XSelectionSetOwner
113 * request we made to server (used to
114 * filter out redundant SelectionClear
116 Time selectionTime
; /* Timestamp used to acquire selection. */
117 Atom multipleAtom
; /* Atom for MULTIPLE. None means
118 * selection stuff isn't initialized. */
119 Atom incrAtom
; /* Atom for INCR. */
120 Atom targetsAtom
; /* Atom for TARGETS. */
121 Atom timestampAtom
; /* Atom for TIMESTAMP. */
122 Atom textAtom
; /* Atom for TEXT. */
123 Atom compoundTextAtom
; /* Atom for COMPOUND_TEXT. */
126 * Information used by tkAtom.c only:
129 int atomInit
; /* 0 means stuff below hasn't been
130 * initialized yet. */
131 Tcl_HashTable nameTable
; /* Maps from names to Atom's. */
132 Tcl_HashTable atomTable
; /* Maps from Atom's back to names. */
135 * Information used by tkCursor.c only:
138 Font cursorFont
; /* Font to use for standard cursors.
139 * None means font not loaded yet. */
142 * Information used by tkGrab.c only:
145 struct TkWindow
*grabWinPtr
;
146 /* Window in which the pointer is currently
147 * grabbed, or NULL if none. */
148 struct TkWindow
*ungrabWinPtr
;
149 /* Window to which pointer should be returned
150 * when the current grab ends (i.e. the
151 * window that the mouse is really on top
153 struct TkWindow
*buttonWinPtr
;
154 /* Window in which first mouse button was
155 * pressed while grab was in effect, or NULL
156 * if no such press in effect. */
157 struct TkWindow
*pointerWinPtr
;
158 /* The window that officially contains the
159 * pointer, as far as this application is
160 * concerned. If a grab is in effect then
161 * this may not be the window that's underneath
162 * the pointer. NULL means the application
163 * doesn't consider the pointer to be in any
165 struct TkWindow
*serverWinPtr
;
166 /* The window that contains the pointer, as
167 * far as the X server is concerned. This
168 * field gets set on every Enter or Leave
169 * event even if the grab code eventually
170 * discards the event. NULL means the server
171 * thinks the pointer is outside any window
172 * of any application on this screen. */
173 int grabFlags
; /* Miscellaneous flag values. See definitions
176 struct TkWindow
*focusPtr
; /* Identifies window that currently has the
177 * focus (or that will get the focus the next
178 * time the pointer enters any of the top-level
179 * windows associated with this display).
180 * NULL means nobody has the focus.
181 * Managed by tkEvent.c. */
185 * One of the following structures exists for each error handler
186 * created by a call to Tk_CreateErrorHandler. The structure
187 * is managed by tkError.c.
190 typedef struct TkErrorHandler
{
191 TkDisplay
*dispPtr
; /* Display to which handler applies. */
192 unsigned long firstRequest
; /* Only errors with serial numbers
193 * >= to this are considered. */
194 unsigned long lastRequest
; /* Only errors with serial numbers
195 * <= to this are considered. This
196 * field is filled in when XUnhandle
197 * is called. -1 means XUnhandle
198 * hasn't been called yet. */
199 int error
; /* Consider only errors with this
200 * error_code (-1 means consider
202 int request
; /* Consider only errors with this
203 * major request code (-1 means
204 * consider all major codes). */
205 int minorCode
; /* Consider only errors with this
206 * minor request code (-1 means
207 * consider all minor codes). */
208 Tk_ErrorProc
*errorProc
; /* Procedure to invoke when a matching
209 * error occurs. NULL means just ignore
211 ClientData clientData
; /* Arbitrary value to pass to
213 struct TkErrorHandler
*nextPtr
;
214 /* Pointer to next older handler for
215 * this display, or NULL for end of
220 * One of the following structures exists for each event handler
221 * created by calling Tk_CreateEventHandler. This information
222 * is used by tkEvent.c only.
225 typedef struct TkEventHandler
{
226 unsigned long mask
; /* Events for which to invoke
228 Tk_EventProc
*proc
; /* Procedure to invoke when an event
230 ClientData clientData
; /* Argument to pass to proc. */
231 struct TkEventHandler
*nextPtr
;
232 /* Next in list of handlers
233 * associated with window (NULL means
238 * One of the following structures exists for each selection
239 * handler created by calling Tk_CreateSelHandler. This
240 * information is used by tkSelect.c only.
243 typedef struct TkSelHandler
{
244 Atom target
; /* Target type for selection
245 * conversion, such as TARGETS or
247 Atom format
; /* Format in which selection
248 * info will be returned, such
249 * as STRING or ATOM. */
250 Tk_SelectionProc
*proc
; /* Procedure to generate selection
252 ClientData clientData
; /* Argument to pass to proc. */
253 int size
; /* Size of units returned by proc
254 * (8 for STRING, 32 for almost
256 struct TkSelHandler
*nextPtr
;
257 /* Next selection handler associated
258 * with same window (NULL for end of
263 * Tk keeps one of the following data structures for each main
264 * window (created by a call to Tk_CreateMainWindow). It stores
265 * information that is shared by all of the windows associated
266 * with a particular main window.
269 typedef struct TkMainInfo
{
270 struct TkWindow
*winPtr
; /* Pointer to main window. */
271 Tcl_Interp
*interp
; /* Interpreter associated with application. */
272 Tcl_HashTable nameTable
; /* Hash table mapping path names to TkWindow
273 * structs for all windows related to this
274 * main window. Managed by tkWindow.c. */
275 Tk_BindingTable bindingTable
;
276 /* Used in conjunction with "bind" command
277 * to bind events to Tcl commands. */
279 /* struct TkWindow *focusPtr; */ /* Identifies window that currently has the
280 * focus (or that will get the focus the next
281 * time the pointer enters any of the top-level
282 * windows associated with this display).
283 * NULL means nobody has the focus.
284 * Managed by tkEvent.c. */
285 struct ElArray
*optionRootPtr
;
286 /* Top level of option hierarchy for this
287 * main window. NULL means uninitialized.
288 * Managed by tkOption.c. */
292 * Tk keeps one of the following structures for each window.
293 * Some of the information (like size and location) is a shadow
294 * of information managed by the X server, and some is special
295 * information used here, such as event and geometry management
296 * information. This information is (mostly) managed by tkWindow.c.
297 * WARNING: the declaration below must be kept consistent with the
298 * Tk_ClientWindow structure in tk.h. If you change one, be sure to
302 typedef struct TkWindow
{
305 * Structural information:
308 Display
*display
; /* Display containing window. */
309 TkDisplay
*dispPtr
; /* Tk's information about display
311 int screenNum
; /* Index of screen for window, among all
312 * those for dispPtr. */
313 Window window
; /* X's id for window. NULL means window
314 * hasn't actually been created yet, or it's
316 struct TkWindow
*childList
; /* First in list of child windows,
317 * or NULL if no children. */
318 struct TkWindow
*parentPtr
; /* Pointer to parent window (logical
319 * parent, not necessarily X parent), or
320 * NULL if this is a main window. */
321 struct TkWindow
*nextPtr
; /* Next in list of children with
322 * same parent (NULL if end of
324 TkMainInfo
*mainPtr
; /* Information shared by all windows
325 * associated with a particular main
326 * window. NULL means this window is
327 * a rogue that isn't associated with
328 * any application (at present, there
329 * should never be any rogues). */
332 * Name and type information for the window:
335 char *pathName
; /* Path name of window (concatenation
336 * of all names between this window and
337 * its top-level ancestor). This is a
338 * pointer into an entry in
339 * mainPtr->nameTable or NULL if mainPtr
341 Tk_Uid nameUid
; /* Name of the window within its parent
342 * (unique within the parent). */
343 Tk_Uid classUid
; /* Class of the window. NULL means window
344 * hasn't been given a class yet. */
347 * Geometry and other attributes of window. This information
348 * may not be updated on the server immediately; stuff that
349 * hasn't been reflected in the server yet is called "dirty".
350 * At present, information can be dirty only if the window
351 * hasn't yet been created.
354 XWindowChanges changes
; /* Geometry and other info about
356 unsigned int dirtyChanges
; /* Bits indicate fields of "changes"
358 XSetWindowAttributes atts
; /* Current attributes of window. */
359 unsigned long dirtyAtts
; /* Bits indicate fields of "atts"
362 unsigned int flags
; /* Various flag values: these are all
363 * defined in tk.h (confusing, but they're
364 * needed there for some query macros). */
367 * Information kept by the event manager (tkEvent.c):
370 TkEventHandler
*handlerList
;/* First in list of event handlers
371 * declared for this window, or
374 * Information related to input focussing (tkEvent.c):
377 Tk_FocusProc
*focusProc
; /* Procedure to invoke when this window
378 * gets or loses the input focus. NULL
379 * means this window is not prepared to
380 * receive the focus. */
381 ClientData focusData
; /* Arbitrary value to pass to focusProc. */
384 * Information used by tkOption.c to manage options for the
388 int optionLevel
; /* -1 means no option information is
389 * currently cached for this window.
390 * Otherwise this gives the level in
391 * the option stack at which info is
394 * Information used by tkSelect.c to manage the selection.
397 TkSelHandler
*selHandlerList
;
398 /* First in list of handlers for
399 * returning the selection in various
401 Tk_LostSelProc
*selClearProc
;
402 ClientData selClearData
; /* Info to pass to selClearProc. */
405 * Information used by tkGeometry.c for geometry management.
408 Tk_GeometryProc
*geomProc
; /* Procedure to handle geometry
409 * requests (NULL means no window is
411 ClientData geomData
; /* Argument for geomProc. */
412 int reqWidth
, reqHeight
; /* Arguments from last call to
413 * Tk_GeometryRequest, or 0's if
414 * Tk_GeometryRequest hasn't been
416 int internalBorderWidth
; /* Width of internal border of window
417 * (0 means no internal border). Geom.
418 * mgr. should not place children on top
422 * Information maintained by tkWm.c for window manager communication.
425 struct TkWmInfo
*wmInfoPtr
; /* For top-level windows, points to
426 * structure with wm-related info (see
427 * tkWm.c). For other windows, this
432 * The context below is used to map from an X window id to
433 * the TkWindow structure associated with the window.
436 extern XContext tkWindowContext
;
439 * Pointer to first entry in list of all displays currently known.
442 extern TkDisplay
*tkDisplayList
;
445 * Flags passed to TkMeasureChars:
448 #define TK_WHOLE_WORDS 1
449 #define TK_AT_LEAST_ONE 2
450 #define TK_PARTIAL_OK 4
451 #define TK_NEWLINES_NOT_SPECIAL 8
454 * Location of library directory containing Tk scripts. This value
455 * is put in the $tkLibrary variable for each application.
460 #define TK_LIBRARY "res/tk"
462 #define TK_LIBRARY "/usr/local/lib/tk"
467 * See tkShare.c for explanation of following disgusting variable:
470 extern XEvent
*tkShareEventPtr
;
473 * Secret way to inhibit event collapsing. -deh
476 extern int tkCollapseMotion
;
479 * Secret way to break out to Tk_MainLoop. -deh
482 extern int tkMustExit
;
485 * Miscellaneous variables shared among Tk modules but not exported
486 * to the outside world:
489 extern Tk_Uid tkActiveUid
;
490 extern Tk_Uid tkDisabledUid
;
491 extern Tk_Uid tkNormalUid
;
494 * Internal procedures shared among Tk modules but not exported
495 * to the outside world:
498 extern int TkAreaToPolygon
_ANSI_ARGS_((double *polyPtr
,
499 int numPoints
, double *rectPtr
));
500 extern void TkBezierPoints
_ANSI_ARGS_((double control
[],
501 int numSteps
, double *coordPtr
));
502 extern void TkBindError
_ANSI_ARGS_((Tcl_Interp
*interp
));
503 extern void TkBindEventProc
_ANSI_ARGS_((TkWindow
*winPtr
,
505 extern Time TkCurrentTime
_ANSI_ARGS_((TkDisplay
*dispPtr
));
506 extern int TkDeadAppCmd
_ANSI_ARGS_((ClientData clientData
,
507 Tcl_Interp
*interp
, int argc
, char **argv
));
508 extern void TkDisplayChars
_ANSI_ARGS_((Display
*display
,
509 Drawable drawable
, GC gc
,
510 XFontStruct
*fontStructPtr
, char *string
,
511 int numChars
, int x
, int y
, int flags
));
512 extern void TkEventDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
513 extern void TkFocusEventProc
_ANSI_ARGS_((TkWindow
*winPtr
,
515 extern void TkGetButtPoints
_ANSI_ARGS_((double p1
[], double p2
[],
516 double width
, int project
, double m1
[],
518 extern int TkGetInterpNames
_ANSI_ARGS_((Tcl_Interp
*interp
,
520 extern int TkGetMiterPoints
_ANSI_ARGS_((double p1
[], double p2
[],
521 double p3
[], double width
, double m1
[],
523 extern void TkGrabDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
524 extern int TkLineToArea
_ANSI_ARGS_((double end1Ptr
[2],
525 double end2Ptr
[2], double rectPtr
[4]));
526 extern double TkLineToPoint
_ANSI_ARGS_((double end1Ptr
[2],
527 double end2Ptr
[2], double pointPtr
[2]));
528 extern int TkMeasureChars
_ANSI_ARGS_((XFontStruct
*fontStructPtr
,
529 char *source
, int maxChars
, int startX
, int maxX
,
530 int flags
, int *nextXPtr
));
531 extern void TkOptionDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
532 extern int TkOvalToArea
_ANSI_ARGS_((double *ovalPtr
,
534 extern double TkOvalToPoint
_ANSI_ARGS_((double ovalPtr
[4],
535 double width
, int filled
, double pointPtr
[2]));
536 extern int TkPointerEvent
_ANSI_ARGS_((XEvent
*eventPtr
,
538 extern int TkPolygonToArea
_ANSI_ARGS_((double *polyPtr
,
539 int numPoints
, double *rectPtr
));
540 extern double TkPolygonToPoint
_ANSI_ARGS_((double *polyPtr
,
541 int numPoints
, double *pointPtr
));
542 extern void TkSelDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
543 extern void TkSelEventProc
_ANSI_ARGS_((Tk_Window tkwin
,
545 extern void TkSelPropProc
_ANSI_ARGS_((XEvent
*eventPtr
));
546 extern void TkUnderlineChars
_ANSI_ARGS_((Display
*display
,
547 Drawable drawable
, GC gc
,
548 XFontStruct
*fontStructPtr
, char *string
,
549 int x
, int y
, int flags
, int firstChar
,
551 extern void TkWmDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
552 extern int TkWmMapWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
553 extern void TkWmSetClass
_ANSI_ARGS_((TkWindow
*winPtr
));
554 extern void TkWmNewWindow
_ANSI_ARGS_((TkWindow
*winPtr
));