1/* $XConsortium: Xlib.h,v 11.221 93/07/02 14:13:28 gildea Exp $ */
2/*
3 * Copyright 1985, 1986, 1987, 1991 by the Massachusetts Institute of Technology
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation for any purpose and without fee is hereby granted, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of M.I.T. not be used in advertising
10 * or publicity pertaining to distribution of the software without specific,
11 * written prior permission. M.I.T. makes no representations about the
12 * suitability of this software for any purpose.  It is provided "as is"
13 * without express or implied warranty.
14 *
15 * X Window System is a Trademark of MIT.
16 *
17 */
18
19
20/*
21 *	Xlib.h - Header definition and support file for the C subroutine
22 *	interface library (Xlib) to the X Window System Protocol (V11).
23 *	Structures and symbols starting with "_" are private to the library.
24 */
25#ifndef _XLIB_H_
26#define _XLIB_H_
27
28#define XlibSpecificationRelease 5
29
30#if !defined(MAC_OSX_TK)
31#   include <X11/X.h>
32#endif
33#ifdef MAC_OSX_TK
34#   include <X11/X.h>
35#   define Cursor XCursor
36#   define Region XRegion
37#endif
38
39/* applications should not depend on these two headers being included! */
40#include <X11/Xfuncproto.h>
41
42#ifndef X_WCHAR
43#ifdef X_NOT_STDC_ENV
44#define X_WCHAR
45#endif
46#endif
47
48#ifndef X_WCHAR
49#include <stddef.h>
50#else
51/* replace this with #include or typedef appropriate for your system */
52typedef unsigned long wchar_t;
53#endif
54
55typedef char *XPointer;
56
57#define Bool int
58#if defined(MAC_OSX_TK)
59/* Use define rather than typedef, since may need to undefine this later */
60#define Status int
61#else
62typedef int Status;
63#endif
64#define True 1
65#define False 0
66
67#define QueuedAlready 0
68#define QueuedAfterReading 1
69#define QueuedAfterFlush 2
70
71#define ConnectionNumber(dpy) 	((dpy)->fd)
72#define RootWindow(dpy, scr) 	(((dpy)->screens[(scr)]).root)
73#define DefaultScreen(dpy) 	((dpy)->default_screen)
74#define DefaultRootWindow(dpy) 	(((dpy)->screens[(dpy)->default_screen]).root)
75#define DefaultVisual(dpy, scr) (((dpy)->screens[(scr)]).root_visual)
76#define DefaultGC(dpy, scr) 	(((dpy)->screens[(scr)]).default_gc)
77#define BlackPixel(dpy, scr) 	(((dpy)->screens[(scr)]).black_pixel)
78#define WhitePixel(dpy, scr) 	(((dpy)->screens[(scr)]).white_pixel)
79#define AllPlanes 		((unsigned long)~0L)
80#define QLength(dpy) 		((dpy)->qlen)
81#define DisplayWidth(dpy, scr) 	(((dpy)->screens[(scr)]).width)
82#define DisplayHeight(dpy, scr) (((dpy)->screens[(scr)]).height)
83#define DisplayWidthMM(dpy, scr)(((dpy)->screens[(scr)]).mwidth)
84#define DisplayHeightMM(dpy, scr)(((dpy)->screens[(scr)]).mheight)
85#define DisplayPlanes(dpy, scr) (((dpy)->screens[(scr)]).root_depth)
86#define DisplayCells(dpy, scr) 	(DefaultVisual((dpy), (scr))->map_entries)
87#define ScreenCount(dpy) 	((dpy)->nscreens)
88#define ServerVendor(dpy) 	((dpy)->vendor)
89#define ProtocolVersion(dpy) 	((dpy)->proto_major_version)
90#define ProtocolRevision(dpy) 	((dpy)->proto_minor_version)
91#define VendorRelease(dpy) 	((dpy)->release)
92#define DisplayString(dpy) 	((dpy)->display_name)
93#define DefaultDepth(dpy, scr) 	(((dpy)->screens[(scr)]).root_depth)
94#define DefaultColormap(dpy, scr)(((dpy)->screens[(scr)]).cmap)
95#define BitmapUnit(dpy) 	((dpy)->bitmap_unit)
96#define BitmapBitOrder(dpy) 	((dpy)->bitmap_bit_order)
97#define BitmapPad(dpy) 		((dpy)->bitmap_pad)
98#define ImageByteOrder(dpy) 	((dpy)->byte_order)
99#define NextRequest(dpy)	((dpy)->request + 1)
100#define LastKnownRequestProcessed(dpy)	((dpy)->request)
101
102/* macros for screen oriented applications (toolkit) */
103#define ScreenOfDisplay(dpy, scr)(&((dpy)->screens[(scr)]))
104#define DefaultScreenOfDisplay(dpy) (&((dpy)->screens[(dpy)->default_screen]))
105#define DisplayOfScreen(s)	((s)->display)
106#define RootWindowOfScreen(s)	((s)->root)
107#define BlackPixelOfScreen(s)	((s)->black_pixel)
108#define WhitePixelOfScreen(s)	((s)->white_pixel)
109#define DefaultColormapOfScreen(s)((s)->cmap)
110#define DefaultDepthOfScreen(s)	((s)->root_depth)
111#define DefaultGCOfScreen(s)	((s)->default_gc)
112#define DefaultVisualOfScreen(s)((s)->root_visual)
113#define WidthOfScreen(s)	((s)->width)
114#define HeightOfScreen(s)	((s)->height)
115#define WidthMMOfScreen(s)	((s)->mwidth)
116#define HeightMMOfScreen(s)	((s)->mheight)
117#define PlanesOfScreen(s)	((s)->root_depth)
118#define CellsOfScreen(s)	(DefaultVisualOfScreen((s))->map_entries)
119#define MinCmapsOfScreen(s)	((s)->min_maps)
120#define MaxCmapsOfScreen(s)	((s)->max_maps)
121#define DoesSaveUnders(s)	((s)->save_unders)
122#define DoesBackingStore(s)	((s)->backing_store)
123#define EventMaskOfScreen(s)	((s)->root_input_mask)
124
125/*
126 * Extensions need a way to hang private data on some structures.
127 */
128typedef struct _XExtData {
129	int number;		/* number returned by XRegisterExtension */
130	struct _XExtData *next;	/* next item on list of data for structure */
131	int (*free_private)();	/* called to free private storage */
132	XPointer private_data;	/* data private to this extension. */
133} XExtData;
134
135/*
136 * This file contains structures used by the extension mechanism.
137 */
138typedef struct {		/* public to extension, cannot be changed */
139	int extension;		/* extension number */
140	int major_opcode;	/* major op-code assigned by server */
141	int first_event;	/* first event number for the extension */
142	int first_error;	/* first error number for the extension */
143} XExtCodes;
144
145/*
146 * Data structure for retrieving info about pixmap formats.
147 */
148
149typedef struct {
150    int depth;
151    int bits_per_pixel;
152    int scanline_pad;
153} XPixmapFormatValues;
154
155
156/*
157 * Data structure for setting graphics context.
158 */
159typedef struct {
160	int function;		/* logical operation */
161	unsigned long plane_mask;/* plane mask */
162	unsigned long foreground;/* foreground pixel */
163	unsigned long background;/* background pixel */
164	int line_width;		/* line width */
165	int line_style;	 	/* LineSolid, LineOnOffDash, LineDoubleDash */
166	int cap_style;	  	/* CapNotLast, CapButt,
167				   CapRound, CapProjecting */
168	int join_style;	 	/* JoinMiter, JoinRound, JoinBevel */
169	int fill_style;	 	/* FillSolid, FillTiled,
170				   FillStippled, FillOpaeueStippled */
171	int fill_rule;	  	/* EvenOddRule, WindingRule */
172	int arc_mode;		/* ArcChord, ArcPieSlice */
173	Pixmap tile;		/* tile pixmap for tiling operations */
174	Pixmap stipple;		/* stipple 1 plane pixmap for stipping */
175	int ts_x_origin;	/* offset for tile or stipple operations */
176	int ts_y_origin;
177        Font font;	        /* default text font for text operations */
178	int subwindow_mode;     /* ClipByChildren, IncludeInferiors */
179	Bool graphics_exposures;/* boolean, should exposures be generated */
180	int clip_x_origin;	/* origin for clipping */
181	int clip_y_origin;
182	Pixmap clip_mask;	/* bitmap clipping; other calls for rects */
183	int dash_offset;	/* patterned/dashed line information */
184	char dashes;
185} XGCValues;
186
187/*
188 * Graphics context.  The contents of this structure are implementation
189 * dependent.  A GC should be treated as opaque by application code.
190 */
191
192typedef XGCValues *GC;
193
194/*
195 * Visual structure; contains information about colormapping possible.
196 */
197typedef struct {
198	XExtData *ext_data;	/* hook for extension to hang data */
199	VisualID visualid;	/* visual id of this visual */
200#if defined(__cplusplus) || defined(c_plusplus)
201	int c_class;		/* C++ class of screen (monochrome, etc.) */
202#else
203	int class;		/* class of screen (monochrome, etc.) */
204#endif
205	unsigned long red_mask, green_mask, blue_mask;	/* mask values */
206	int bits_per_rgb;	/* log base 2 of distinct color values */
207	int map_entries;	/* color map entries */
208} Visual;
209
210/*
211 * Depth structure; contains information for each possible depth.
212 */
213typedef struct {
214	int depth;		/* this depth (Z) of the depth */
215	int nvisuals;		/* number of Visual types at this depth */
216	Visual *visuals;	/* list of visuals possible at this depth */
217} Depth;
218
219/*
220 * Information about the screen.  The contents of this structure are
221 * implementation dependent.  A Screen should be treated as opaque
222 * by application code.
223 */
224typedef struct {
225	XExtData *ext_data;	/* hook for extension to hang data */
226	struct _XDisplay *display;/* back pointer to display structure */
227	Window root;		/* Root window id. */
228	int width, height;	/* width and height of screen */
229	int mwidth, mheight;	/* width and height of  in millimeters */
230	int ndepths;		/* number of depths possible */
231	Depth *depths;		/* list of allowable depths on the screen */
232	int root_depth;		/* bits per pixel */
233	Visual *root_visual;	/* root visual */
234	GC default_gc;		/* GC for the root root visual */
235	Colormap cmap;		/* default color map */
236	unsigned long white_pixel;
237	unsigned long black_pixel;	/* White and Black pixel values */
238	int max_maps, min_maps;	/* max and min color maps */
239	int backing_store;	/* Never, WhenMapped, Always */
240	Bool save_unders;
241	long root_input_mask;	/* initial root input mask */
242} Screen;
243
244/*
245 * Format structure; describes ZFormat data the screen will understand.
246 */
247typedef struct {
248	XExtData *ext_data;	/* hook for extension to hang data */
249	int depth;		/* depth of this image format */
250	int bits_per_pixel;	/* bits/pixel at this depth */
251	int scanline_pad;	/* scanline must padded to this multiple */
252} ScreenFormat;
253
254/*
255 * Data structure for setting window attributes.
256 */
257typedef struct {
258    Pixmap background_pixmap;	/* background or None or ParentRelative */
259    unsigned long background_pixel;	/* background pixel */
260    Pixmap border_pixmap;	/* border of the window */
261    unsigned long border_pixel;	/* border pixel value */
262    int bit_gravity;		/* one of bit gravity values */
263    int win_gravity;		/* one of the window gravity values */
264    int backing_store;		/* NotUseful, WhenMapped, Always */
265    unsigned long backing_planes;/* planes to be preseved if possible */
266    unsigned long backing_pixel;/* value to use in restoring planes */
267    Bool save_under;		/* should bits under be saved? (popups) */
268    long event_mask;		/* set of events that should be saved */
269    long do_not_propagate_mask;	/* set of events that should not propagate */
270    Bool override_redirect;	/* boolean value for override-redirect */
271    Colormap colormap;		/* color map to be associated with window */
272    Cursor cursor;		/* cursor to be displayed (or None) */
273} XSetWindowAttributes;
274
275typedef struct {
276    int x, y;			/* location of window */
277    int width, height;		/* width and height of window */
278    int border_width;		/* border width of window */
279    int depth;          	/* depth of window */
280    Visual *visual;		/* the associated visual structure */
281    Window root;        	/* root of screen containing window */
282#if defined(__cplusplus) || defined(c_plusplus)
283    int c_class;		/* C++ InputOutput, InputOnly*/
284#else
285    int class;			/* InputOutput, InputOnly*/
286#endif
287    int bit_gravity;		/* one of bit gravity values */
288    int win_gravity;		/* one of the window gravity values */
289    int backing_store;		/* NotUseful, WhenMapped, Always */
290    unsigned long backing_planes;/* planes to be preserved if possible */
291    unsigned long backing_pixel;/* value to be used when restoring planes */
292    Bool save_under;		/* boolean, should bits under be saved? */
293    Colormap colormap;		/* color map to be associated with window */
294    Bool map_installed;		/* boolean, is color map currently installed*/
295    int map_state;		/* IsUnmapped, IsUnviewable, IsViewable */
296    long all_event_masks;	/* set of events all people have interest in*/
297    long your_event_mask;	/* my event mask */
298    long do_not_propagate_mask; /* set of events that should not propagate */
299    Bool override_redirect;	/* boolean value for override-redirect */
300    Screen *screen;		/* back pointer to correct screen */
301} XWindowAttributes;
302
303/*
304 * Data structure for host setting; getting routines.
305 *
306 */
307
308typedef struct {
309	int family;		/* for example FamilyInternet */
310	int length;		/* length of address, in bytes */
311	char *address;		/* pointer to where to find the bytes */
312} XHostAddress;
313
314/*
315 * Data structure for "image" data, used by image manipulation routines.
316 */
317typedef struct _XImage {
318    int width, height;		/* size of image */
319    int xoffset;		/* number of pixels offset in X direction */
320    int format;			/* XYBitmap, XYPixmap, ZPixmap */
321    char *data;			/* pointer to image data */
322    int byte_order;		/* data byte order, LSBFirst, MSBFirst */
323    int bitmap_unit;		/* quant. of scanline 8, 16, 32 */
324    int bitmap_bit_order;	/* LSBFirst, MSBFirst */
325    int bitmap_pad;		/* 8, 16, 32 either XY or ZPixmap */
326    int depth;			/* depth of image */
327    int bytes_per_line;		/* accelarator to next line */
328    int bits_per_pixel;		/* bits per pixel (ZPixmap) */
329    unsigned long red_mask;	/* bits in z arrangment */
330    unsigned long green_mask;
331    unsigned long blue_mask;
332    XPointer obdata;		/* hook for the object routines to hang on */
333    struct funcs {		/* image manipulation routines */
334	struct _XImage *(*create_image)();
335#if NeedFunctionPrototypes
336	int (*destroy_image)        (struct _XImage *);
337	unsigned long (*get_pixel)  (struct _XImage *, int, int);
338	int (*put_pixel)            (struct _XImage *, int, int, unsigned long);
339	struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
340	int (*add_pixel)            (struct _XImage *, long);
341#else
342	int (*destroy_image)();
343	unsigned long (*get_pixel)();
344	int (*put_pixel)();
345	struct _XImage *(*sub_image)();
346	int (*add_pixel)();
347#endif
348	} f;
349} XImage;
350
351/*
352 * Data structure for XReconfigureWindow
353 */
354typedef struct {
355    int x, y;
356    int width, height;
357    int border_width;
358    Window sibling;
359    int stack_mode;
360} XWindowChanges;
361
362/*
363 * Data structure used by color operations
364 */
365typedef struct {
366	unsigned long pixel;
367	unsigned short red, green, blue;
368	char flags;  /* do_red, do_green, do_blue */
369	char pad;
370} XColor;
371
372/*
373 * Data structures for graphics operations.  On most machines, these are
374 * congruent with the wire protocol structures, so reformatting the data
375 * can be avoided on these architectures.
376 */
377typedef struct {
378    short x1, y1, x2, y2;
379} XSegment;
380
381typedef struct {
382    short x, y;
383} XPoint;
384
385typedef struct {
386    short x, y;
387    unsigned short width, height;
388} XRectangle;
389
390typedef struct {
391    short x, y;
392    unsigned short width, height;
393    short angle1, angle2;
394} XArc;
395
396
397/* Data structure for XChangeKeyboardControl */
398
399typedef struct {
400        int key_click_percent;
401        int bell_percent;
402        int bell_pitch;
403        int bell_duration;
404        int led;
405        int led_mode;
406        int key;
407        int auto_repeat_mode;   /* On, Off, Default */
408} XKeyboardControl;
409
410/* Data structure for XGetKeyboardControl */
411
412typedef struct {
413        int key_click_percent;
414	int bell_percent;
415	unsigned int bell_pitch, bell_duration;
416	unsigned long led_mask;
417	int global_auto_repeat;
418	char auto_repeats[32];
419} XKeyboardState;
420
421/* Data structure for XGetMotionEvents.  */
422
423typedef struct {
424        Time time;
425	short x, y;
426} XTimeCoord;
427
428/* Data structure for X{Set,Get}ModifierMapping */
429
430typedef struct {
431 	int max_keypermod;	/* The server's max # of keys per modifier */
432 	KeyCode *modifiermap;	/* An 8 by max_keypermod array of modifiers */
433} XModifierKeymap;
434
435
436/*
437 * Display datatype maintaining display specific data.
438 * The contents of this structure are implementation dependent.
439 * A Display should be treated as opaque by application code.
440 */
441typedef struct _XDisplay {
442	XExtData *ext_data;	/* hook for extension to hang data */
443	struct _XFreeFuncs *free_funcs; /* internal free functions */
444	int fd;			/* Network socket. */
445	int conn_checker;         /* ugly thing used by _XEventsQueued */
446	int proto_major_version;/* maj. version of server's X protocol */
447	int proto_minor_version;/* minor version of servers X protocol */
448	char *vendor;		/* vendor of the server hardware */
449        XID resource_base;	/* resource ID base */
450	XID resource_mask;	/* resource ID mask bits */
451	XID resource_id;	/* allocator current ID */
452	int resource_shift;	/* allocator shift to correct bits */
453	XID (*resource_alloc)(); /* allocator function */
454	int byte_order;		/* screen byte order, LSBFirst, MSBFirst */
455	int bitmap_unit;	/* padding and data requirements */
456	int bitmap_pad;		/* padding requirements on bitmaps */
457	int bitmap_bit_order;	/* LeastSignificant or MostSignificant */
458	int nformats;		/* number of pixmap formats in list */
459	ScreenFormat *pixmap_format;	/* pixmap format list */
460	int vnumber;		/* Xlib's X protocol version number. */
461	int release;		/* release of the server */
462	struct _XSQEvent *head, *tail;	/* Input event queue. */
463	int qlen;		/* Length of input event queue */
464	unsigned long request;	/* sequence number of last request. */
465	char *last_req;		/* beginning of last request, or dummy */
466	char *buffer;		/* Output buffer starting address. */
467	char *bufptr;		/* Output buffer index pointer. */
468	char *bufmax;		/* Output buffer maximum+1 address. */
469	unsigned max_request_size; /* maximum number 32 bit words in request*/
470	struct _XrmHashBucketRec *db;
471	int (*synchandler)();	/* Synchronization handler */
472	char *display_name;	/* "host:display" string used on this connect*/
473	int default_screen;	/* default screen for operations */
474	int nscreens;		/* number of screens on this server*/
475	Screen *screens;	/* pointer to list of screens */
476	unsigned long motion_buffer;	/* size of motion buffer */
477	unsigned long flags;	/* internal connection flags */
478	int min_keycode;	/* minimum defined keycode */
479	int max_keycode;	/* maximum defined keycode */
480	KeySym *keysyms;	/* This server's keysyms */
481	XModifierKeymap *modifiermap;	/* This server's modifier keymap */
482	int keysyms_per_keycode;/* number of rows */
483	char *xdefaults;	/* contents of defaults from server */
484	char *scratch_buffer;	/* place to hang scratch buffer */
485	unsigned long scratch_length;	/* length of scratch buffer */
486	int ext_number;		/* extension number on this display */
487	struct _XExten *ext_procs; /* extensions initialized on this display */
488	/*
489	 * the following can be fixed size, as the protocol defines how
490	 * much address space is available.
491	 * While this could be done using the extension vector, there
492	 * may be MANY events processed, so a search through the extension
493	 * list to find the right procedure for each event might be
494	 * expensive if many extensions are being used.
495	 */
496	Bool (*event_vec[128])();  /* vector for wire to event */
497	Status (*wire_vec[128])(); /* vector for event to wire */
498	KeySym lock_meaning;	   /* for XLookupString */
499	struct _XLockInfo *lock;   /* multi-thread state, display lock */
500	struct _XInternalAsync *async_handlers; /* for internal async */
501	unsigned long bigreq_size; /* max size of big requests */
502	struct _XLockPtrs *lock_fns; /* pointers to threads functions */
503	/* things above this line should not move, for binary compatibility */
504	struct _XKeytrans *key_bindings; /* for XLookupString */
505	Font cursor_font;	   /* for XCreateFontCursor */
506	struct _XDisplayAtoms *atoms; /* for XInternAtom */
507	unsigned int mode_switch;  /* keyboard group modifiers */
508	struct _XContextDB *context_db; /* context database */
509	Bool (**error_vec)();      /* vector for wire to error */
510	/*
511	 * Xcms information
512	 */
513	struct {
514	   XPointer defaultCCCs;  /* pointer to an array of default XcmsCCC */
515	   XPointer clientCmaps;  /* pointer to linked list of XcmsCmapRec */
516	   XPointer perVisualIntensityMaps;
517				  /* linked list of XcmsIntensityMap */
518	} cms;
519	struct _XIMFilter *im_filters;
520	struct _XSQEvent *qfree; /* unallocated event queue elements */
521	unsigned long next_event_serial_num; /* inserted into next queue elt */
522	int (*savedsynchandler)(); /* user synchandler when Xlib usurps */
523} Display;
524
525#if NeedFunctionPrototypes	/* prototypes require event type definitions */
526#undef _XEVENT_
527#endif
528#ifndef _XEVENT_
529
530#define XMaxTransChars 4
531
532/*
533 * Definitions of specific events.
534 */
535typedef struct {
536	int type;		/* of event */
537	unsigned long serial;	/* # of last request processed by server */
538	Bool send_event;	/* true if this came from a SendEvent request */
539	Display *display;	/* Display the event was read from */
540	Window window;	        /* "event" window it is reported relative to */
541	Window root;	        /* root window that the event occured on */
542	Window subwindow;	/* child window */
543	Time time;		/* milliseconds */
544	int x, y;		/* pointer x, y coordinates in event window */
545	int x_root, y_root;	/* coordinates relative to root */
546	unsigned int state;	/* key or button mask */
547	unsigned int keycode;	/* detail */
548	Bool same_screen;	/* same screen flag */
549        char trans_chars[XMaxTransChars];
550				/* translated characters */
551	int nbytes;
552} XKeyEvent;
553typedef XKeyEvent XKeyPressedEvent;
554typedef XKeyEvent XKeyReleasedEvent;
555
556typedef struct {
557	int type;		/* of event */
558	unsigned long serial;	/* # of last request processed by server */
559	Bool send_event;	/* true if this came from a SendEvent request */
560	Display *display;	/* Display the event was read from */
561	Window window;	        /* "event" window it is reported relative to */
562	Window root;	        /* root window that the event occured on */
563	Window subwindow;	/* child window */
564	Time time;		/* milliseconds */
565	int x, y;		/* pointer x, y coordinates in event window */
566	int x_root, y_root;	/* coordinates relative to root */
567	unsigned int state;	/* key or button mask */
568	unsigned int button;	/* detail */
569	Bool same_screen;	/* same screen flag */
570} XButtonEvent;
571typedef XButtonEvent XButtonPressedEvent;
572typedef XButtonEvent XButtonReleasedEvent;
573
574typedef struct {
575	int type;		/* of event */
576	unsigned long serial;	/* # of last request processed by server */
577	Bool send_event;	/* true if this came from a SendEvent request */
578	Display *display;	/* Display the event was read from */
579	Window window;	        /* "event" window reported relative to */
580	Window root;	        /* root window that the event occured on */
581	Window subwindow;	/* child window */
582	Time time;		/* milliseconds */
583	int x, y;		/* pointer x, y coordinates in event window */
584	int x_root, y_root;	/* coordinates relative to root */
585	unsigned int state;	/* key or button mask */
586	char is_hint;		/* detail */
587	Bool same_screen;	/* same screen flag */
588} XMotionEvent;
589typedef XMotionEvent XPointerMovedEvent;
590
591typedef struct {
592	int type;		/* of event */
593	unsigned long serial;	/* # of last request processed by server */
594	Bool send_event;	/* true if this came from a SendEvent request */
595	Display *display;	/* Display the event was read from */
596	Window window;	        /* "event" window reported relative to */
597	Window root;	        /* root window that the event occured on */
598	Window subwindow;	/* child window */
599	Time time;		/* milliseconds */
600	int x, y;		/* pointer x, y coordinates in event window */
601	int x_root, y_root;	/* coordinates relative to root */
602	int mode;		/* NotifyNormal, NotifyGrab, NotifyUngrab */
603	int detail;
604	/*
605	 * NotifyAncestor, NotifyVirtual, NotifyInferior,
606	 * NotifyNonlinear,NotifyNonlinearVirtual
607	 */
608	Bool same_screen;	/* same screen flag */
609	Bool focus;		/* boolean focus */
610	unsigned int state;	/* key or button mask */
611} XCrossingEvent;
612typedef XCrossingEvent XEnterWindowEvent;
613typedef XCrossingEvent XLeaveWindowEvent;
614
615typedef struct {
616	int type;		/* FocusIn or FocusOut */
617	unsigned long serial;	/* # of last request processed by server */
618	Bool send_event;	/* true if this came from a SendEvent request */
619	Display *display;	/* Display the event was read from */
620	Window window;		/* window of event */
621	int mode;		/* NotifyNormal, NotifyGrab, NotifyUngrab */
622	int detail;
623	/*
624	 * NotifyAncestor, NotifyVirtual, NotifyInferior,
625	 * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
626	 * NotifyPointerRoot, NotifyDetailNone
627	 */
628} XFocusChangeEvent;
629typedef XFocusChangeEvent XFocusInEvent;
630typedef XFocusChangeEvent XFocusOutEvent;
631
632/* generated on EnterWindow and FocusIn  when KeyMapState selected */
633typedef struct {
634	int type;
635	unsigned long serial;	/* # of last request processed by server */
636	Bool send_event;	/* true if this came from a SendEvent request */
637	Display *display;	/* Display the event was read from */
638	Window window;
639	char key_vector[32];
640} XKeymapEvent;
641
642typedef struct {
643	int type;
644	unsigned long serial;	/* # of last request processed by server */
645	Bool send_event;	/* true if this came from a SendEvent request */
646	Display *display;	/* Display the event was read from */
647	Window window;
648	int x, y;
649	int width, height;
650	int count;		/* if non-zero, at least this many more */
651} XExposeEvent;
652
653typedef struct {
654	int type;
655	unsigned long serial;	/* # of last request processed by server */
656	Bool send_event;	/* true if this came from a SendEvent request */
657	Display *display;	/* Display the event was read from */
658	Drawable drawable;
659	int x, y;
660	int width, height;
661	int count;		/* if non-zero, at least this many more */
662	int major_code;		/* core is CopyArea or CopyPlane */
663	int minor_code;		/* not defined in the core */
664} XGraphicsExposeEvent;
665
666typedef struct {
667	int type;
668	unsigned long serial;	/* # of last request processed by server */
669	Bool send_event;	/* true if this came from a SendEvent request */
670	Display *display;	/* Display the event was read from */
671	Drawable drawable;
672	int major_code;		/* core is CopyArea or CopyPlane */
673	int minor_code;		/* not defined in the core */
674} XNoExposeEvent;
675
676typedef struct {
677	int type;
678	unsigned long serial;	/* # of last request processed by server */
679	Bool send_event;	/* true if this came from a SendEvent request */
680	Display *display;	/* Display the event was read from */
681	Window window;
682	int state;		/* Visibility state */
683} XVisibilityEvent;
684
685typedef struct {
686	int type;
687	unsigned long serial;	/* # of last request processed by server */
688	Bool send_event;	/* true if this came from a SendEvent request */
689	Display *display;	/* Display the event was read from */
690	Window parent;		/* parent of the window */
691	Window window;		/* window id of window created */
692	int x, y;		/* window location */
693	int width, height;	/* size of window */
694	int border_width;	/* border width */
695	Bool override_redirect;	/* creation should be overridden */
696} XCreateWindowEvent;
697
698typedef struct {
699	int type;
700	unsigned long serial;	/* # of last request processed by server */
701	Bool send_event;	/* true if this came from a SendEvent request */
702	Display *display;	/* Display the event was read from */
703	Window event;
704	Window window;
705} XDestroyWindowEvent;
706
707typedef struct {
708	int type;
709	unsigned long serial;	/* # of last request processed by server */
710	Bool send_event;	/* true if this came from a SendEvent request */
711	Display *display;	/* Display the event was read from */
712	Window event;
713	Window window;
714	Bool from_configure;
715} XUnmapEvent;
716
717typedef struct {
718	int type;
719	unsigned long serial;	/* # of last request processed by server */
720	Bool send_event;	/* true if this came from a SendEvent request */
721	Display *display;	/* Display the event was read from */
722	Window event;
723	Window window;
724	Bool override_redirect;	/* boolean, is override set... */
725} XMapEvent;
726
727typedef struct {
728	int type;
729	unsigned long serial;	/* # of last request processed by server */
730	Bool send_event;	/* true if this came from a SendEvent request */
731	Display *display;	/* Display the event was read from */
732	Window parent;
733	Window window;
734} XMapRequestEvent;
735
736typedef struct {
737	int type;
738	unsigned long serial;	/* # of last request processed by server */
739	Bool send_event;	/* true if this came from a SendEvent request */
740	Display *display;	/* Display the event was read from */
741	Window event;
742	Window window;
743	Window parent;
744	int x, y;
745	Bool override_redirect;
746} XReparentEvent;
747
748typedef struct {
749	int type;
750	unsigned long serial;	/* # of last request processed by server */
751	Bool send_event;	/* true if this came from a SendEvent request */
752	Display *display;	/* Display the event was read from */
753	Window event;
754	Window window;
755	int x, y;
756	int width, height;
757	int border_width;
758	Window above;
759	Bool override_redirect;
760} XConfigureEvent;
761
762typedef struct {
763	int type;
764	unsigned long serial;	/* # of last request processed by server */
765	Bool send_event;	/* true if this came from a SendEvent request */
766	Display *display;	/* Display the event was read from */
767	Window event;
768	Window window;
769	int x, y;
770} XGravityEvent;
771
772typedef struct {
773	int type;
774	unsigned long serial;	/* # of last request processed by server */
775	Bool send_event;	/* true if this came from a SendEvent request */
776	Display *display;	/* Display the event was read from */
777	Window window;
778	int width, height;
779} XResizeRequestEvent;
780
781typedef struct {
782	int type;
783	unsigned long serial;	/* # of last request processed by server */
784	Bool send_event;	/* true if this came from a SendEvent request */
785	Display *display;	/* Display the event was read from */
786	Window parent;
787	Window window;
788	int x, y;
789	int width, height;
790	int border_width;
791	Window above;
792	int detail;		/* Above, Below, TopIf, BottomIf, Opposite */
793	unsigned long value_mask;
794} XConfigureRequestEvent;
795
796typedef struct {
797	int type;
798	unsigned long serial;	/* # of last request processed by server */
799	Bool send_event;	/* true if this came from a SendEvent request */
800	Display *display;	/* Display the event was read from */
801	Window event;
802	Window window;
803	int place;		/* PlaceOnTop, PlaceOnBottom */
804} XCirculateEvent;
805
806typedef struct {
807	int type;
808	unsigned long serial;	/* # of last request processed by server */
809	Bool send_event;	/* true if this came from a SendEvent request */
810	Display *display;	/* Display the event was read from */
811	Window parent;
812	Window window;
813	int place;		/* PlaceOnTop, PlaceOnBottom */
814} XCirculateRequestEvent;
815
816typedef struct {
817	int type;
818	unsigned long serial;	/* # of last request processed by server */
819	Bool send_event;	/* true if this came from a SendEvent request */
820	Display *display;	/* Display the event was read from */
821	Window window;
822	Atom atom;
823	Time time;
824	int state;		/* NewValue, Deleted */
825} XPropertyEvent;
826
827typedef struct {
828	int type;
829	unsigned long serial;	/* # of last request processed by server */
830	Bool send_event;	/* true if this came from a SendEvent request */
831	Display *display;	/* Display the event was read from */
832	Window window;
833	Atom selection;
834	Time time;
835} XSelectionClearEvent;
836
837typedef struct {
838	int type;
839	unsigned long serial;	/* # of last request processed by server */
840	Bool send_event;	/* true if this came from a SendEvent request */
841	Display *display;	/* Display the event was read from */
842	Window owner;
843	Window requestor;
844	Atom selection;
845	Atom target;
846	Atom property;
847	Time time;
848} XSelectionRequestEvent;
849
850typedef struct {
851	int type;
852	unsigned long serial;	/* # of last request processed by server */
853	Bool send_event;	/* true if this came from a SendEvent request */
854	Display *display;	/* Display the event was read from */
855	Window requestor;
856	Atom selection;
857	Atom target;
858	Atom property;		/* ATOM or None */
859	Time time;
860} XSelectionEvent;
861
862typedef struct {
863	int type;
864	unsigned long serial;	/* # of last request processed by server */
865	Bool send_event;	/* true if this came from a SendEvent request */
866	Display *display;	/* Display the event was read from */
867	Window window;
868	Colormap colormap;	/* COLORMAP or None */
869#if defined(__cplusplus) || defined(c_plusplus)
870	Bool c_new;		/* C++ */
871#else
872	Bool new;
873#endif
874	int state;		/* ColormapInstalled, ColormapUninstalled */
875} XColormapEvent;
876
877typedef struct {
878	int type;
879	unsigned long serial;	/* # of last request processed by server */
880	Bool send_event;	/* true if this came from a SendEvent request */
881	Display *display;	/* Display the event was read from */
882	Window window;
883	Atom message_type;
884	int format;
885	union {
886		char b[20];
887		short s[10];
888		long l[5];
889		} data;
890} XClientMessageEvent;
891
892typedef struct {
893	int type;
894	unsigned long serial;	/* # of last request processed by server */
895	Bool send_event;	/* true if this came from a SendEvent request */
896	Display *display;	/* Display the event was read from */
897	Window window;		/* unused */
898	int request;		/* one of MappingModifier, MappingKeyboard,
899				   MappingPointer */
900	int first_keycode;	/* first keycode */
901	int count;		/* defines range of change w. first_keycode*/
902} XMappingEvent;
903
904typedef struct {
905	int type;
906	Display *display;	/* Display the event was read from */
907	XID resourceid;		/* resource id */
908	unsigned long serial;	/* serial number of failed request */
909	unsigned char error_code;	/* error code of failed request */
910	unsigned char request_code;	/* Major op-code of failed request */
911	unsigned char minor_code;	/* Minor op-code of failed request */
912} XErrorEvent;
913
914typedef struct {
915	int type;
916	unsigned long serial;	/* # of last request processed by server */
917	Bool send_event;	/* true if this came from a SendEvent request */
918	Display *display;/* Display the event was read from */
919	Window window;	/* window on which event was requested in event mask */
920} XAnyEvent;
921
922/*
923 * this union is defined so Xlib can always use the same sized
924 * event structure internally, to avoid memory fragmentation.
925 */
926typedef union _XEvent {
927        int type;		/* must not be changed; first element */
928	XAnyEvent xany;
929	XKeyEvent xkey;
930	XButtonEvent xbutton;
931	XMotionEvent xmotion;
932	XCrossingEvent xcrossing;
933	XFocusChangeEvent xfocus;
934	XExposeEvent xexpose;
935	XGraphicsExposeEvent xgraphicsexpose;
936	XNoExposeEvent xnoexpose;
937	XVisibilityEvent xvisibility;
938	XCreateWindowEvent xcreatewindow;
939	XDestroyWindowEvent xdestroywindow;
940	XUnmapEvent xunmap;
941	XMapEvent xmap;
942	XMapRequestEvent xmaprequest;
943	XReparentEvent xreparent;
944	XConfigureEvent xconfigure;
945	XGravityEvent xgravity;
946	XResizeRequestEvent xresizerequest;
947	XConfigureRequestEvent xconfigurerequest;
948	XCirculateEvent xcirculate;
949	XCirculateRequestEvent xcirculaterequest;
950	XPropertyEvent xproperty;
951	XSelectionClearEvent xselectionclear;
952	XSelectionRequestEvent xselectionrequest;
953	XSelectionEvent xselection;
954	XColormapEvent xcolormap;
955	XClientMessageEvent xclient;
956	XMappingEvent xmapping;
957	XErrorEvent xerror;
958	XKeymapEvent xkeymap;
959	long pad[24];
960} XEvent;
961#endif
962
963#define XAllocID(dpy) ((*(dpy)->resource_alloc)((dpy)))
964
965/*
966 * per character font metric information.
967 */
968typedef struct {
969    short	lbearing;	/* origin to left edge of raster */
970    short	rbearing;	/* origin to right edge of raster */
971    short	width;		/* advance to next char's origin */
972    short	ascent;		/* baseline to top edge of raster */
973    short	descent;	/* baseline to bottom edge of raster */
974    unsigned short attributes;	/* per char flags (not predefined) */
975} XCharStruct;
976
977/*
978 * To allow arbitrary information with fonts, there are additional properties
979 * returned.
980 */
981typedef struct {
982    Atom name;
983    unsigned long card32;
984} XFontProp;
985
986typedef struct {
987    XExtData	*ext_data;	/* hook for extension to hang data */
988    Font        fid;            /* Font id for this font */
989    unsigned	direction;	/* hint about direction the font is painted */
990    unsigned	min_char_or_byte2;/* first character */
991    unsigned	max_char_or_byte2;/* last character */
992    unsigned	min_byte1;	/* first row that exists */
993    unsigned	max_byte1;	/* last row that exists */
994    Bool	all_chars_exist;/* flag if all characters have non-zero size*/
995    unsigned	default_char;	/* char to print for undefined character */
996    int         n_properties;   /* how many properties there are */
997    XFontProp	*properties;	/* pointer to array of additional properties*/
998    XCharStruct	min_bounds;	/* minimum bounds over all existing char*/
999    XCharStruct	max_bounds;	/* maximum bounds over all existing char*/
1000    XCharStruct	*per_char;	/* first_char to last_char information */
1001    int		ascent;		/* log. extent above baseline for spacing */
1002    int		descent;	/* log. descent below baseline for spacing */
1003} XFontStruct;
1004
1005/*
1006 * PolyText routines take these as arguments.
1007 */
1008typedef struct {
1009    char *chars;		/* pointer to string */
1010    int nchars;			/* number of characters */
1011    int delta;			/* delta between strings */
1012    Font font;			/* font to print it in, None don't change */
1013} XTextItem;
1014
1015typedef struct {		/* normal 16 bit characters are two bytes */
1016    unsigned char byte1;
1017    unsigned char byte2;
1018} XChar2b;
1019
1020typedef struct {
1021    XChar2b *chars;		/* two byte characters */
1022    int nchars;			/* number of characters */
1023    int delta;			/* delta between strings */
1024    Font font;			/* font to print it in, None don't change */
1025} XTextItem16;
1026
1027
1028typedef union { Display *display;
1029		GC gc;
1030		Visual *visual;
1031		Screen *screen;
1032		ScreenFormat *pixmap_format;
1033		XFontStruct *font; } XEDataObject;
1034
1035typedef struct {
1036    XRectangle      max_ink_extent;
1037    XRectangle      max_logical_extent;
1038} XFontSetExtents;
1039
1040typedef struct _XFontSet *XFontSet;
1041
1042typedef struct {
1043    char           *chars;
1044    int             nchars;
1045    int             delta;
1046    XFontSet        font_set;
1047} XmbTextItem;
1048
1049typedef struct {
1050    wchar_t        *chars;
1051    int             nchars;
1052    int             delta;
1053    XFontSet        font_set;
1054} XwcTextItem;
1055
1056typedef void (*XIMProc)();
1057
1058typedef struct _XIM *XIM;
1059typedef struct _XIC *XIC;
1060
1061typedef unsigned long XIMStyle;
1062
1063typedef struct {
1064    unsigned short count_styles;
1065    XIMStyle *supported_styles;
1066} XIMStyles;
1067
1068#define XIMPreeditArea		0x0001L
1069#define XIMPreeditCallbacks	0x0002L
1070#define XIMPreeditPosition	0x0004L
1071#define XIMPreeditNothing	0x0008L
1072#define XIMPreeditNone		0x0010L
1073#define XIMStatusArea		0x0100L
1074#define XIMStatusCallbacks	0x0200L
1075#define XIMStatusNothing	0x0400L
1076#define XIMStatusNone		0x0800L
1077
1078#define XNVaNestedList "XNVaNestedList"
1079#define XNClientWindow "clientWindow"
1080#define XNInputStyle "inputStyle"
1081#define XNFocusWindow "focusWindow"
1082#define XNResourceName "resourceName"
1083#define XNResourceClass "resourceClass"
1084#define XNGeometryCallback "geometryCallback"
1085#define XNFilterEvents "filterEvents"
1086#define XNPreeditStartCallback "preeditStartCallback"
1087#define XNPreeditDoneCallback "preeditDoneCallback"
1088#define XNPreeditDrawCallback "preeditDrawCallback"
1089#define XNPreeditCaretCallback "preeditCaretCallback"
1090#define XNPreeditAttributes "preeditAttributes"
1091#define XNStatusStartCallback "statusStartCallback"
1092#define XNStatusDoneCallback "statusDoneCallback"
1093#define XNStatusDrawCallback "statusDrawCallback"
1094#define XNStatusAttributes "statusAttributes"
1095#define XNArea "area"
1096#define XNAreaNeeded "areaNeeded"
1097#define XNSpotLocation "spotLocation"
1098#define XNColormap "colorMap"
1099#define XNStdColormap "stdColorMap"
1100#define XNForeground "foreground"
1101#define XNBackground "background"
1102#define XNBackgroundPixmap "backgroundPixmap"
1103#define XNFontSet "fontSet"
1104#define XNLineSpace "lineSpace"
1105#define XNCursor "cursor"
1106
1107#define XBufferOverflow		-1
1108#define XLookupNone		1
1109#define XLookupChars		2
1110#define XLookupKeySym		3
1111#define XLookupBoth		4
1112
1113#if NeedFunctionPrototypes
1114typedef void *XVaNestedList;
1115#else
1116typedef XPointer XVaNestedList;
1117#endif
1118
1119typedef struct {
1120    XPointer client_data;
1121    XIMProc callback;
1122} XIMCallback;
1123
1124typedef unsigned long XIMFeedback;
1125
1126#define XIMReverse	1
1127#define XIMUnderline	(1<<1)
1128#define XIMHighlight	(1<<2)
1129#define XIMPrimary 	(1<<5)
1130#define XIMSecondary	(1<<6)
1131#define XIMTertiary 	(1<<7)
1132
1133typedef struct _XIMText {
1134    unsigned short length;
1135    XIMFeedback *feedback;
1136    Bool encoding_is_wchar;
1137    union {
1138	char *multi_byte;
1139	wchar_t *wide_char;
1140    } string;
1141} XIMText;
1142
1143typedef struct _XIMPreeditDrawCallbackStruct {
1144    int caret;		/* Cursor offset within pre-edit string */
1145    int chg_first;	/* Starting change position */
1146    int chg_length;	/* Length of the change in character count */
1147    XIMText *text;
1148} XIMPreeditDrawCallbackStruct;
1149
1150typedef enum {
1151    XIMForwardChar, XIMBackwardChar,
1152    XIMForwardWord, XIMBackwardWord,
1153    XIMCaretUp, XIMCaretDown,
1154    XIMNextLine, XIMPreviousLine,
1155    XIMLineStart, XIMLineEnd,
1156    XIMAbsolutePosition,
1157    XIMDontChange
1158} XIMCaretDirection;
1159
1160typedef enum {
1161    XIMIsInvisible,	/* Disable caret feedback */
1162    XIMIsPrimary,	/* UI defined caret feedback */
1163    XIMIsSecondary	/* UI defined caret feedback */
1164} XIMCaretStyle;
1165
1166typedef struct _XIMPreeditCaretCallbackStruct {
1167    int position;		 /* Caret offset within pre-edit string */
1168    XIMCaretDirection direction; /* Caret moves direction */
1169    XIMCaretStyle style;	 /* Feedback of the caret */
1170} XIMPreeditCaretCallbackStruct;
1171
1172typedef enum {
1173    XIMTextType,
1174    XIMBitmapType
1175} XIMStatusDataType;
1176
1177typedef struct _XIMStatusDrawCallbackStruct {
1178    XIMStatusDataType type;
1179    union {
1180	XIMText *text;
1181	Pixmap  bitmap;
1182    } data;
1183} XIMStatusDrawCallbackStruct;
1184
1185typedef int (*XErrorHandler) (	    /* WARNING, this type not in Xlib spec */
1186#if NeedFunctionPrototypes
1187    Display*		/* display */,
1188    XErrorEvent*	/* error_event */
1189#endif
1190);
1191
1192_XFUNCPROTOBEGIN
1193
1194
1195
1196#include "tkIntXlibDecls.h"
1197
1198_XFUNCPROTOEND
1199
1200#if defined(MAC_OSX_TK)
1201#   undef Cursor
1202#   undef Region
1203#endif
1204
1205#endif /* _XLIB_H_ */
1206