/* $XConsortium: Xlib.h,v 11.215 91/07/22 15:42:38 rws Exp $ */
/* 
 * Copyright 1985, 1986, 1987, 1991 by the Massachusetts Institute of Technology
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted, provided 
 * that the above copyright notice appear in all copies and that both that 
 * copyright notice and this permission notice appear in supporting 
 * documentation, and that the name of M.I.T. not be used in advertising
 * or publicity pertaining to distribution of the software without specific, 
 * written prior permission. M.I.T. makes no representations about the 
 * suitability of this software for any purpose.  It is provided "as is"
 * without express or implied warranty.
 *
 * X Window System is a Trademark of MIT.
 *
 */


/*
 *	Xlib.h - Header definition and support file for the C subroutine
 *	interface library (Xlib) to the X Window System Protocol (V11).
 *	Structures and symbols starting with "_" are private to the library.
 */
/* XLIB Includes -- Modified for use with Windows */

typedef HWND Window;
typedef int Bool;
typedef unsigned long Time;
typedef unsigned int Atom;
typedef unsigned char KeyCode;
typedef UINT KeySym;
typedef UINT Drawable;
typedef HFONT	Font;
typedef HCURSOR	Cursor;
typedef HICON Pixmap;
typedef unsigned long XID;
typedef POINT XPoint;
typedef PALETTEENTRY XColor;
#define	CurrentTime	     0L /* special Time */
#define NoSymbol	     0L	/* special KeySym */
#define None		0L
#define True		1
#define False		0

/*****************************************************************
 * ERROR CODES 
 *****************************************************************/

#define Success		   0	/* everything's okay */
#define BadRequest	   1	/* bad request code */
#define BadValue	   2	/* int parameter out of range */
#define BadWindow	   3	/* parameter not a Window */
#define BadPixmap	   4	/* parameter not a Pixmap */
#define BadAtom		   5	/* parameter not an Atom */
#define BadCursor	   6	/* parameter not a Cursor */
#define BadFont		   7	/* parameter not a Font */
#define BadMatch	   8	/* parameter mismatch */
#define BadDrawable	   9	/* parameter not a Pixmap or Window */
#define BadAccess	  10	/* depending on context:
				 - key/button already grabbed
				 - attempt to free an illegal 
				   cmap entry 
				- attempt to store into a read-only 
				   color map entry.
 				- attempt to modify the access control
				   list from other than the local host.
				*/
#define BadAlloc	  11	/* insufficient resources */
#define BadColor	  12	/* no such colormap */
#define BadGC		  13	/* parameter not a GC */
#define BadIDChoice	  14	/* choice not in range or already used */
#define BadName		  15	/* font or color name doesn't exist */
#define BadLength	  16	/* Request length incorrect */
#define BadImplementation 17	/* server is defective */

#define FirstExtensionError	128
#define LastExtensionError	255

/* Borrowed defines and structures from XWindows */
#define CWEventMask	(1L << 11)
#define CWColormap	(1L << 13)
#define CWX		(1 << 0)
#define CWY		(1 << 1)
#define CWWidth		(1 << 2)
#define CWHeight	(1 << 3)
#define CWBorderWidth	(1 << 4)
#define CWSibling	(1 << 5)
#define CWStackMode	(1 << 6)
#define CWOverrideRedirect	(1L<<9)

typedef struct {
	int x, y;
	int width, height;
#ifndef TCL_MSDOS_PORT
	int border_width;
#endif
	Window sibling;
	int stack_mode;
} XWindowChanges;

/* Window stacking method (in configureWindow) */

#define Above                   0
#define Below                   1
#define TopIf                   2
#define BottomIf                3
#define Opposite                4

/* Bit Gravity */

#define ForgetGravity		0
#define NorthWestGravity	1
#define NorthGravity		2
#define NorthEastGravity	3
#define WestGravity		4
#define CenterGravity		5
#define EastGravity		6
#define SouthWestGravity	7
#define SouthGravity		8
#define SouthEastGravity	9
#define StaticGravity		10

/*
 * Data structure for setting window attributes.
 */
typedef struct {
#ifndef TCL_MSDOS_PORT
    Pixmap background_pixmap;	/* background or None or ParentRelative */
#endif
#ifdef TCL_MSDOS_PORT
    PALETTEENTRY background_pixel;
#else
    unsigned long background_pixel;	/* background pixel */
    Pixmap border_pixmap;	/* border of the window */
    unsigned long border_pixel;	/* border pixel value */
#endif
#ifndef TCL_MSDOS_PORT
    int bit_gravity;		/* one of bit gravity values */
    int win_gravity;		/* one of the window gravity values */
    int backing_store;		/* NotUseful, WhenMapped, Always */
    unsigned long backing_planes;/* planes to be preseved if possible */
    unsigned long backing_pixel;/* value to use in restoring planes */
    int save_under;		/* should bits under be saved? (popups) */
    long event_mask;		/* set of events that should be saved */
    long do_not_propagate_mask;	/* set of events that should not propagate */
#endif
    int override_redirect;	/* boolean value for override-redirect */
#ifndef TCL_MSDOS_PORT
    Colormap colormap;		/* color map to be associated with window */
#endif
    Cursor cursor;		/* cursor to be displayed (or None) */
} XSetWindowAttributes;

#define ScreenCount(x)	1	/* For Windows, only one screen */
#define DefaultDepth(disp, scrnum)	DisplayPlanes()

/* Data structure for X{Set,Get}ModifierMapping */

typedef struct {
 	int max_keypermod;	/* The server's max # of keys per modifier */
 	KeyCode *modifiermap;	/* An 8 by max_keypermod array of modifiers */
} XModifierKeymap;

/***************************************************************** 
 * EVENT DEFINITIONS 
 *****************************************************************/

/*
 * Definitions of specific events.
 */
typedef struct {
	int type;		/* of event */
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;	        /* "event" window it is reported relative to */
	Window root;	        /* root window that the event occured on */
	Window subwindow;	/* child window */
	Time time;		/* milliseconds */
	int x, y;		/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	unsigned int state;	/* key or button mask */
	unsigned int keycode;	/* detail */
	Bool same_screen;	/* same screen flag */
} XKeyEvent;
typedef XKeyEvent XKeyPressedEvent;
typedef XKeyEvent XKeyReleasedEvent;

typedef struct {
	int type;		/* of event */
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;	        /* "event" window it is reported relative to */
	Window root;	        /* root window that the event occured on */
	Window subwindow;	/* child window */
	Time time;		/* milliseconds */
	int x, y;		/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	unsigned int state;	/* key or button mask */
	unsigned int button;	/* detail */
	Bool same_screen;	/* same screen flag */
} XButtonEvent;
typedef XButtonEvent XButtonPressedEvent;
typedef XButtonEvent XButtonReleasedEvent;

typedef struct {
	int type;		/* of event */
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;	        /* "event" window reported relative to */
	Window root;	        /* root window that the event occured on */
	Window subwindow;	/* child window */
	Time time;		/* milliseconds */
	int x, y;		/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	unsigned int state;	/* key or button mask */
	char is_hint;		/* detail */
	Bool same_screen;	/* same screen flag */
} XMotionEvent;
typedef XMotionEvent XPointerMovedEvent;

typedef struct {
	int type;		/* of event */
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;	        /* "event" window reported relative to */
	Window root;	        /* root window that the event occured on */
	Window subwindow;	/* child window */
	Time time;		/* milliseconds */
	int x, y;		/* pointer x, y coordinates in event window */
	int x_root, y_root;	/* coordinates relative to root */
	int mode;		/* NotifyNormal, NotifyGrab, NotifyUngrab */
	int detail;
	/*
	 * NotifyAncestor, NotifyVirtual, NotifyInferior, 
	 * NotifyNonlinear,NotifyNonlinearVirtual
	 */
	Bool same_screen;	/* same screen flag */
	Bool focus;		/* boolean focus */
	unsigned int state;	/* key or button mask */
} XCrossingEvent;
typedef XCrossingEvent XEnterWindowEvent;
typedef XCrossingEvent XLeaveWindowEvent;

typedef struct {
	int type;		/* FocusIn or FocusOut */
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;		/* window of event */
	int mode;		/* NotifyNormal, NotifyGrab, NotifyUngrab */
	int detail;
	/*
	 * NotifyAncestor, NotifyVirtual, NotifyInferior, 
	 * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
	 * NotifyPointerRoot, NotifyDetailNone 
	 */
} XFocusChangeEvent;
typedef XFocusChangeEvent XFocusInEvent;
typedef XFocusChangeEvent XFocusOutEvent;

/* generated on EnterWindow and FocusIn  when KeyMapState selected */
typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	char key_vector[32];
} XKeymapEvent;	

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	int x, y;
	int width, height;
	int count;		/* if non-zero, at least this many more */
} XExposeEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
	Drawable drawable;
#endif
	int x, y;
	int width, height;
	int count;		/* if non-zero, at least this many more */
	int major_code;		/* core is CopyArea or CopyPlane */
	int minor_code;		/* not defined in the core */
} XGraphicsExposeEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
	Drawable drawable;
#endif
	int major_code;		/* core is CopyArea or CopyPlane */
	int minor_code;		/* not defined in the core */
} XNoExposeEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	int state;		/* Visibility state */
} XVisibilityEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window parent;		/* parent of the window */
	Window window;		/* window id of window created */
	int x, y;		/* window location */
	int width, height;	/* size of window */
	int border_width;	/* border width */
	Bool override_redirect;	/* creation should be overridden */
} XCreateWindowEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
} XDestroyWindowEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
	Bool from_configure;
} XUnmapEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
	Bool override_redirect;	/* boolean, is override set... */
} XMapEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window parent;
	Window window;
} XMapRequestEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
	Window parent;
	int x, y;
	Bool override_redirect;
} XReparentEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
	int x, y;
	int width, height;
	int border_width;
	Window above;
	Bool override_redirect;
} XConfigureEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
	int x, y;
} XGravityEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	int width, height;
} XResizeRequestEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window parent;
	Window window;
	int x, y;
	int width, height;
	int border_width;
	Window above;
	int detail;		/* Above, Below, TopIf, BottomIf, Opposite */
	unsigned long value_mask;
} XConfigureRequestEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window event;
	Window window;
	int place;		/* PlaceOnTop, PlaceOnBottom */
} XCirculateEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window parent;
	Window window;
	int place;		/* PlaceOnTop, PlaceOnBottom */
} XCirculateRequestEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	Atom atom;
	Time time;
	int state;		/* NewValue, Deleted */
} XPropertyEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	Atom selection;
	Time time;
} XSelectionClearEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window owner;
	Window requestor;
	Atom selection;
	Atom target;
	Atom property;
	Time time;
} XSelectionRequestEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window requestor;
	Atom selection;
	Atom target;
	Atom property;		/* ATOM or None */
	Time time;
} XSelectionEvent;

#ifndef TCL_MSDOS_PORT
typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
	Display *display;	/* Display the event was read from */
	Window window;
	Colormap colormap;	/* COLORMAP or None */
#if defined(__cplusplus) || defined(c_plusplus)
	Bool c_new;		/* C++ */
#else
	Bool new;
#endif
	int state;		/* ColormapInstalled, ColormapUninstalled */
} XColormapEvent;
#endif

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;
	Atom message_type;
	int format;
	union {
		char b[20];
		short s[10];
		long l[5];
		} data;
} XClientMessageEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
#endif
	Window window;		/* unused */
	int request;		/* one of MappingModifier, MappingKeyboard,
				   MappingPointer */
	int first_keycode;	/* first keycode */
	int count;		/* defines range of change w. first_keycode*/
} XMappingEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	Display *display;	/* Display the event was read from */
	XID resourceid;		/* resource id */
	unsigned long serial;	/* serial number of failed request */
#endif
	unsigned char error_code;	/* error code of failed request */
	unsigned char request_code;	/* Major op-code of failed request */
	unsigned char minor_code;	/* Minor op-code of failed request */
} XErrorEvent;

typedef struct {
	int type;
#ifndef TCL_MSDOS_PORT
	unsigned long serial;	/* # of last request processed by server */
#endif
	Bool send_event;	/* true if this came from a SendEvent request */
#ifndef TCL_MSDOS_PORT
	Display *display;/* Display the event was read from */
#endif
	Window window;	/* window on which event was requested in event mask */
} XAnyEvent;

/*
 * this union is defined so Xlib can always use the same sized
 * event structure internally, to avoid memory fragmentation.
 */
typedef union _XEvent {
        int type;		/* must not be changed; first element */
	XAnyEvent xany;
	XKeyEvent xkey;
	XButtonEvent xbutton;
	XMotionEvent xmotion;
	XCrossingEvent xcrossing;
	XFocusChangeEvent xfocus;
	XExposeEvent xexpose;
	XGraphicsExposeEvent xgraphicsexpose;
	XNoExposeEvent xnoexpose;
	XVisibilityEvent xvisibility;
	XCreateWindowEvent xcreatewindow;
	XDestroyWindowEvent xdestroywindow;
	XUnmapEvent xunmap;
	XMapEvent xmap;
	XMapRequestEvent xmaprequest;
	XReparentEvent xreparent;
	XConfigureEvent xconfigure;
	XGravityEvent xgravity;
	XResizeRequestEvent xresizerequest;
	XConfigureRequestEvent xconfigurerequest;
	XCirculateEvent xcirculate;
	XCirculateRequestEvent xcirculaterequest;
	XPropertyEvent xproperty;
	XSelectionClearEvent xselectionclear;
	XSelectionRequestEvent xselectionrequest;
	XSelectionEvent xselection;
#ifndef TCL_MSDOS_PORT
	XColormapEvent xcolormap;
#endif
	XClientMessageEvent xclient;
	XMappingEvent xmapping;
	XErrorEvent xerror;
	XKeymapEvent xkeymap;
	long pad[24];
} XEvent;
/* Input Event Masks. Used as event-mask window attribute and as arguments
   to Grab requests.  Not to be confused with event names.  */

#define NoEventMask			0L
#define KeyPressMask			(1L<<0)  
#define KeyReleaseMask			(1L<<1)  
#define ButtonPressMask			(1L<<2)  
#define ButtonReleaseMask		(1L<<3)  
#define EnterWindowMask			(1L<<4)  
#define LeaveWindowMask			(1L<<5)  
#define PointerMotionMask		(1L<<6)  
#define PointerMotionHintMask		(1L<<7)  
#define Button1MotionMask		(1L<<8)  
#define Button2MotionMask		(1L<<9)  
#define Button3MotionMask		(1L<<10) 
#define Button4MotionMask		(1L<<11) 
#define Button5MotionMask		(1L<<12) 
#define ButtonMotionMask		(1L<<13) 
#define KeymapStateMask			(1L<<14)
#define ExposureMask			(1L<<15) 
#define VisibilityChangeMask		(1L<<16) 
#define StructureNotifyMask		(1L<<17) 
#define ResizeRedirectMask		(1L<<18) 
#define SubstructureNotifyMask		(1L<<19) 
#define SubstructureRedirectMask	(1L<<20) 
#define FocusChangeMask			(1L<<21) 
#define PropertyChangeMask		(1L<<22) 
#define ColormapChangeMask		(1L<<23) 
#define OwnerGrabButtonMask		(1L<<24) 

/* Event names.  Used in "type" field in XEvent structures.  Not to be
confused with event masks above.  They start from 2 because 0 and 1
are reserved in the protocol for errors and replies. */

#define KeyPress		2
#define KeyRelease		3
#define ButtonPress		4
#define ButtonRelease		5
#define MotionNotify		6
#define EnterNotify		7
#define LeaveNotify		8
#define FocusIn			9
#define FocusOut		10
#define KeymapNotify		11
#define Expose			12
#define GraphicsExpose		13
#define NoExpose		14
#define VisibilityNotify	15
#define CreateNotify		16
#define DestroyNotify		17
#define UnmapNotify		18
#define MapNotify		19
#define MapRequest		20
#define ReparentNotify		21
#define ConfigureNotify		22
#define ConfigureRequest	23
#define GravityNotify		24
#define ResizeRequest		25
#define CirculateNotify		26
#define CirculateRequest	27
#define PropertyNotify		28
#define SelectionClear		29
#define SelectionRequest	30
#define SelectionNotify		31
#define ColormapNotify		32
#define ClientMessage		33
#define MappingNotify		34
#define LASTEvent		35	/* must be bigger than any event # */


/* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
   state in various key-, mouse-, and button-related events. */

#define ShiftMask		(1<<0)
#define LockMask		(1<<1)
#define ControlMask		(1<<2)
#define Mod1Mask		(1<<3)
#define Mod2Mask		(1<<4)
#define Mod3Mask		(1<<5)
#define Mod4Mask		(1<<6)
#define Mod5Mask		(1<<7)

/* modifier names.  Used to build a SetModifierMapping request or
   to read a GetModifierMapping request.  These correspond to the
   masks defined above. */
#define ShiftMapIndex		0
#define LockMapIndex		1
#define ControlMapIndex		2
#define Mod1MapIndex		3
#define Mod2MapIndex		4
#define Mod3MapIndex		5
#define Mod4MapIndex		6
#define Mod5MapIndex		7


/* button masks.  Used in same manner as Key masks above. Not to be confused
   with button names below. */

#define Button1Mask		(1<<8)
#define Button2Mask		(1<<9)
#define Button3Mask		(1<<10)
#define Button4Mask		(1<<11)
#define Button5Mask		(1<<12)

#define AnyModifier		(1<<15)  /* used in GrabButton, GrabKey */


/* button names. Used as arguments to GrabButton and as detail in ButtonPress
   and ButtonRelease events.  Not to be confused with button masks above.
   Note that 0 is already defined above as "AnyButton".  */

#define Button1			1
#define Button2			2
#define Button3			3
#define Button4			4
#define Button5			5

/* Notify modes */

#define NotifyNormal		0
#define NotifyGrab		1
#define NotifyUngrab		2
#define NotifyWhileGrabbed	3

#define NotifyHint		1	/* for MotionNotify events */
		       
/* Notify detail */

#define NotifyAncestor		0
#define NotifyVirtual		1
#define NotifyInferior		2
#define NotifyNonlinear		3
#define NotifyNonlinearVirtual	4
#define NotifyPointer		5
#define NotifyPointerRoot	6
#define NotifyDetailNone	7

/* Visibility notify */

#define VisibilityUnobscured		0
#define VisibilityPartiallyObscured	1
#define VisibilityFullyObscured		2

/* Circulation request */

#define PlaceOnTop		0
#define PlaceOnBottom		1

/* Property notification */

#define PropertyNewValue	0
#define PropertyDelete		1

/* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */

#define GrabModeSync		0
#define GrabModeAsync		1

/* GrabPointer, GrabKeyboard reply status */

#define GrabSuccess		0
#define AlreadyGrabbed		1
#define GrabInvalidTime		2
#define GrabNotViewable		3
#define GrabFrozen		4

#define XA_STRING  CF_TEXT
#define XA_PRIMARY ((Atom) 1)

typedef struct XRectangle{
    int x, y;
    int width, height;
} XRectangle;
