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