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.84 93/01/23 16:59:14 ouster Exp $ SPRITE (Berkeley)
26 #include <X11/Xutil.h>
39 * Opaque type declarations:
42 typedef struct Tk_PostscriptInfo Tk_PostscriptInfo
;
43 typedef struct TkGrabEvent TkGrabEvent
;
46 * One of the following structures is maintained for each display
47 * containing a window managed by Tk:
50 typedef struct TkDisplay
{
51 Display
*display
; /* Xlib's info about display. */
52 struct TkDisplay
*nextPtr
; /* Next in list of all displays. */
53 char *name
; /* Name of display (with any screen
54 * identifier removed). Malloc-ed. */
55 Time lastEventTime
; /* Time of last event received for this
59 * Information used by tkFocus.c and tkEvent.c:
62 struct TkWindow
*focusTopLevelPtr
;
63 /* Pointer to the top-level window that
64 * currently contains the focus for this
65 * display. NULL means none of the
66 * top-levels managed by this application
67 * contains the focus. */
68 int focussedOnEnter
; /* Non-zero means the focus was set
69 * implicitly from an Enter event rather
70 * than from a FocusIn event. */
73 * Information used primarily by tkBind.c:
76 int bindInfoStale
; /* Non-zero means the variables in this
77 * part of the structure are potentially
78 * incorrect and should be recomputed. */
79 unsigned int modeModMask
; /* Has one bit set to indicate the modifier
80 * corresponding to "mode shift". If no
81 * such modifier, than this is zero. */
82 enum {IGNORE
, CAPS
, SHIFT
} lockUsage
;
83 /* Indicates how to interpret lock modifier. */
86 * Information used by tkError.c only:
89 struct TkErrorHandler
*errorPtr
;
90 /* First in list of error handlers
91 * for this display. NULL means
92 * no handlers exist at present. */
93 int deleteCount
; /* Counts # of handlers deleted since
94 * last time inactive handlers were
95 * garbage-collected. When this number
96 * gets big, handlers get cleaned up. */
99 * Information used by tkSend.c only:
102 Tk_Window commWindow
; /* Window used for communication
103 * between interpreters during "send"
104 * commands. NULL means send info hasn't
105 * been initialized yet. */
106 Atom commProperty
; /* X's name for comm property. */
107 Atom registryProperty
; /* X's name for property containing
108 * registry of interpreter names. */
111 * Information used by tkSelect.c only:
114 Tk_Window selectionOwner
; /* Current owner of selection, or
115 * NULL if selection isn't owned by
116 * a window in this process. */
117 int selectionSerial
; /* Serial number of last XSelectionSetOwner
118 * request we made to server (used to
119 * filter out redundant SelectionClear
121 Time selectionTime
; /* Timestamp used to acquire selection. */
122 Atom multipleAtom
; /* Atom for MULTIPLE. None means
123 * selection stuff isn't initialized. */
124 Atom incrAtom
; /* Atom for INCR. */
125 Atom targetsAtom
; /* Atom for TARGETS. */
126 Atom timestampAtom
; /* Atom for TIMESTAMP. */
127 Atom textAtom
; /* Atom for TEXT. */
128 Atom compoundTextAtom
; /* Atom for COMPOUND_TEXT. */
129 Atom applicationAtom
; /* Atom for APPLICATION. */
130 Atom windowNameAtom
; /* Atom for WINDOW_NAME. */
133 * Information used by tkAtom.c only:
136 int atomInit
; /* 0 means stuff below hasn't been
137 * initialized yet. */
138 Tcl_HashTable nameTable
; /* Maps from names to Atom's. */
139 Tcl_HashTable atomTable
; /* Maps from Atom's back to names. */
142 * Information used by tkCursor.c only:
145 Font cursorFont
; /* Font to use for standard cursors.
146 * None means font not loaded yet. */
149 * Information used by tkGrab.c only:
152 struct TkWindow
*grabWinPtr
;
153 /* Window in which the pointer is currently
154 * grabbed, or NULL if none. */
155 struct TkWindow
*eventualGrabWinPtr
;
156 /* Value that grabWinPtr will have once the
157 * grab event queue (below) has been
158 * completely emptied. */
159 struct TkWindow
*buttonWinPtr
;
160 /* Window in which first mouse button was
161 * pressed while grab was in effect, or NULL
162 * if no such press in effect. */
163 struct TkWindow
*serverWinPtr
;
164 /* If no application contains the pointer then
165 * this is NULL. Otherwise it contains the
166 * last window for which we've gotten an
167 * Enter or Leave event from the server (i.e.
168 * the last window known to have contained
169 * the pointer). Doesn't reflect events
170 * that were synthesized in tkGrab.c. */
171 TkGrabEvent
*firstGrabEventPtr
;
172 /* First in list of enter/leave events
173 * synthesized by grab code. These events
174 * must be processed in order before any other
175 * events are processed. NULL means no such
177 TkGrabEvent
*lastGrabEventPtr
;
178 /* Last in list of synthesized events, or NULL
179 * if list is empty. */
180 int grabFlags
; /* Miscellaneous flag values. See definitions
184 * Miscellaneous information:
187 Tk_ColorModel
*colorModels
; /* Array of color models, one per screen;
188 * indicates whether windows should attempt
189 * to use full color for display, just mono,
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. */
287 struct TkWindow
*focusPtr
; /* Identifies window that currently has the
288 * focus (or that will get the focus the next
289 * time the pointer enters any of the top-level
290 * windows associated with this main window).
291 * NULL means nobody has the focus.
292 * Managed by tkFocus.c. */
293 struct TkWindow
*focusDefaultPtr
;
294 /* Window that is to receive the focus by
295 * default when the focusPtr window is
297 struct ElArray
*optionRootPtr
;
298 /* Top level of option hierarchy for this
299 * main window. NULL means uninitialized.
300 * Managed by tkOption.c. */
304 * Tk keeps one of the following structures for each window.
305 * Some of the information (like size and location) is a shadow
306 * of information managed by the X server, and some is special
307 * information used here, such as event and geometry management
308 * information. This information is (mostly) managed by tkWindow.c.
309 * WARNING: the declaration below must be kept consistent with the
310 * Tk_ClientWindow structure in tk.h. If you change one, be sure to
314 typedef struct TkWindow
{
317 * Structural information:
320 Display
*display
; /* Display containing window. */
321 TkDisplay
*dispPtr
; /* Tk's information about display
323 int screenNum
; /* Index of screen for window, among all
324 * those for dispPtr. */
325 Visual
*visual
; /* Visual to use for window. If not default,
326 * MUST be set before X window is created. */
327 int depth
; /* Number of bits/pixel. */
328 Window window
; /* X's id for window. NULL means window
329 * hasn't actually been created yet, or it's
331 struct TkWindow
*childList
; /* First in list of child windows,
332 * or NULL if no children. */
333 struct TkWindow
*parentPtr
; /* Pointer to parent window (logical
334 * parent, not necessarily X parent), or
335 * NULL if this is a main window. */
336 struct TkWindow
*nextPtr
; /* Next in list of children with
337 * same parent (NULL if end of
339 TkMainInfo
*mainPtr
; /* Information shared by all windows
340 * associated with a particular main
341 * window. NULL means this window is
342 * a rogue that isn't associated with
343 * any application (at present, there
344 * should never be any rogues). */
347 * Name and type information for the window:
350 char *pathName
; /* Path name of window (concatenation
351 * of all names between this window and
352 * its top-level ancestor). This is a
353 * pointer into an entry in
354 * mainPtr->nameTable or NULL if mainPtr
356 Tk_Uid nameUid
; /* Name of the window within its parent
357 * (unique within the parent). */
358 Tk_Uid classUid
; /* Class of the window. NULL means window
359 * hasn't been given a class yet. */
362 * Geometry and other attributes of window. This information
363 * may not be updated on the server immediately; stuff that
364 * hasn't been reflected in the server yet is called "dirty".
365 * At present, information can be dirty only if the window
366 * hasn't yet been created.
369 XWindowChanges changes
; /* Geometry and other info about
371 unsigned int dirtyChanges
; /* Bits indicate fields of "changes"
373 XSetWindowAttributes atts
; /* Current attributes of window. */
374 unsigned long dirtyAtts
; /* Bits indicate fields of "atts"
377 unsigned int flags
; /* Various flag values: these are all
378 * defined in tk.h (confusing, but they're
379 * needed there for some query macros). */
382 * Information kept by the event manager (tkEvent.c):
385 TkEventHandler
*handlerList
;/* First in list of event handlers
386 * declared for this window, or
389 * Information related to input focussing (tkFocus.c):
392 Tk_FocusProc
*focusProc
; /* Procedure to invoke when this window
393 * gets or loses the input focus. NULL
394 * means this window is not prepared to
395 * receive the focus. */
396 ClientData focusData
; /* Arbitrary value to pass to focusProc. */
399 * Information used by tkOption.c to manage options for the
403 int optionLevel
; /* -1 means no option information is
404 * currently cached for this window.
405 * Otherwise this gives the level in
406 * the option stack at which info is
409 * Information used by tkSelect.c to manage the selection.
412 TkSelHandler
*selHandlerList
;
413 /* First in list of handlers for
414 * returning the selection in various
416 Tk_LostSelProc
*selClearProc
;
417 ClientData selClearData
; /* Info to pass to selClearProc. */
420 * Information used by tkGeometry.c for geometry management.
423 Tk_GeometryProc
*geomProc
; /* Procedure to handle geometry
424 * requests (NULL means no window is
426 ClientData geomData
; /* Argument for geomProc. */
427 int reqWidth
, reqHeight
; /* Arguments from last call to
428 * Tk_GeometryRequest, or 0's if
429 * Tk_GeometryRequest hasn't been
431 int internalBorderWidth
; /* Width of internal border of window
432 * (0 means no internal border). Geom.
433 * mgr. should not place children on top
437 * Information maintained by tkWm.c for window manager communication.
440 struct TkWmInfo
*wmInfoPtr
; /* For top-level windows, points to
441 * structure with wm-related info (see
442 * tkWm.c). For other windows, this
447 * The context below is used to map from an X window id to
448 * the TkWindow structure associated with the window.
451 extern XContext tkWindowContext
;
454 * Pointer to first entry in list of all displays currently known.
457 extern TkDisplay
*tkDisplayList
;
460 * Flags passed to TkMeasureChars:
463 #define TK_WHOLE_WORDS 1
464 #define TK_AT_LEAST_ONE 2
465 #define TK_PARTIAL_OK 4
466 #define TK_NEWLINES_NOT_SPECIAL 8
469 * Location of library directory containing Tk scripts. This value
470 * is put in the $tkLibrary variable for each application.
474 #define TK_LIBRARY "/usr/local/lib/tk"
478 * Miscellaneous variables shared among Tk modules but not exported
479 * to the outside world:
482 extern Tk_Uid tkActiveUid
;
483 extern Tk_Uid tkDisabledUid
;
484 extern Tk_Uid tkNormalUid
;
487 * Internal procedures shared among Tk modules but not exported
488 * to the outside world:
491 extern int TkAreaToPolygon
_ANSI_ARGS_((double *polyPtr
,
492 int numPoints
, double *rectPtr
));
493 extern void TkBezierPoints
_ANSI_ARGS_((double control
[],
494 int numSteps
, double *coordPtr
));
495 extern void TkBindEventProc
_ANSI_ARGS_((TkWindow
*winPtr
,
497 extern Time TkCurrentTime
_ANSI_ARGS_((TkDisplay
*dispPtr
));
498 extern int TkDeadAppCmd
_ANSI_ARGS_((ClientData clientData
,
499 Tcl_Interp
*interp
, int argc
, char **argv
));
500 extern void TkDisplayChars
_ANSI_ARGS_((Display
*display
,
501 Drawable drawable
, GC gc
,
502 XFontStruct
*fontStructPtr
, char *string
,
503 int numChars
, int x
, int y
, int flags
));
504 extern void TkEventDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
505 extern void TkFocusDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
506 extern int TkFocusFilterEvent
_ANSI_ARGS_((TkWindow
*winPtr
,
508 extern void TkGetButtPoints
_ANSI_ARGS_((double p1
[], double p2
[],
509 double width
, int project
, double m1
[],
511 extern int TkGetInterpNames
_ANSI_ARGS_((Tcl_Interp
*interp
,
513 extern int TkGetMiterPoints
_ANSI_ARGS_((double p1
[], double p2
[],
514 double p3
[], double width
, double m1
[],
516 extern void TkGrabDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
517 extern void TkGrabTriggerProc
_ANSI_ARGS_((XEvent
*eventPtr
));
518 extern int TkLineToArea
_ANSI_ARGS_((double end1Ptr
[2],
519 double end2Ptr
[2], double rectPtr
[4]));
520 extern double TkLineToPoint
_ANSI_ARGS_((double end1Ptr
[2],
521 double end2Ptr
[2], double pointPtr
[2]));
522 extern void TkMakeBezierPostscript
_ANSI_ARGS_((Tcl_Interp
*interp
,
523 double *pointPtr
, int numPoints
,
524 Tk_PostscriptInfo
*psInfoPtr
));
525 extern int TkMeasureChars
_ANSI_ARGS_((XFontStruct
*fontStructPtr
,
526 char *source
, int maxChars
, int startX
, int maxX
,
527 int flags
, int *nextXPtr
));
528 extern void TkOptionDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
529 extern int TkOvalToArea
_ANSI_ARGS_((double *ovalPtr
,
531 extern double TkOvalToPoint
_ANSI_ARGS_((double ovalPtr
[4],
532 double width
, int filled
, double pointPtr
[2]));
533 extern int TkPointerEvent
_ANSI_ARGS_((XEvent
*eventPtr
,
535 extern int TkPolygonToArea
_ANSI_ARGS_((double *polyPtr
,
536 int numPoints
, double *rectPtr
));
537 extern double TkPolygonToPoint
_ANSI_ARGS_((double *polyPtr
,
538 int numPoints
, double *pointPtr
));
539 extern void TkSelDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
540 extern void TkSelEventProc
_ANSI_ARGS_((Tk_Window tkwin
,
542 extern void TkSelPropProc
_ANSI_ARGS_((XEvent
*eventPtr
));
543 extern void TkUnderlineChars
_ANSI_ARGS_((Display
*display
,
544 Drawable drawable
, GC gc
,
545 XFontStruct
*fontStructPtr
, char *string
,
546 int x
, int y
, int flags
, int firstChar
,
548 extern void TkWmDeadWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
549 extern void TkWmMapWindow
_ANSI_ARGS_((TkWindow
*winPtr
));
550 extern void TkWmProtocolEventProc
_ANSI_ARGS_((TkWindow
*winPtr
,
552 extern void TkWmSetClass
_ANSI_ARGS_((TkWindow
*winPtr
));
553 extern void TkWmNewWindow
_ANSI_ARGS_((TkWindow
*winPtr
));