1: #include <X/mit-copyright.h> 2: 3: /* $Header: Xlib.h,v 10.14 86/02/01 15:41:59 tony Rel $ */ 4: /* Copyright Massachusetts Institute of Technology 1985 */ 5: 6: /* 7: * Xlib.h - Header definition and support file for the C subroutine 8: * interface library (Xlib) to the X Window System Protocol. 9: * 10: */ 11: 12: #include <sys/types.h> 13: #include <X/X.h> 14: 15: #define Status int 16: #define XId long 17: #define XClearVertexFlag() (_XlibCurrentDisplay->lastdraw = NULL) 18: #define XMakePattern(pattern, patlen, patmul)\ 19: ((Pattern)(((patmul) << 20) | (((patlen) - 1) << 16) | (pattern) )) 20: #define dpyno() (_XlibCurrentDisplay->fd) 21: #define RootWindow (_XlibCurrentDisplay->root) 22: #define BlackPixmap (_XlibCurrentDisplay->black) 23: #define WhitePixmap (_XlibCurrentDisplay->white) 24: #define AllPlanes (~0) 25: #define QLength() (_XlibCurrentDisplay->qlen) 26: #define DisplayType() (_XlibCurrentDisplay->dtype) 27: #define DisplayPlanes() (_XlibCurrentDisplay->dplanes) 28: #define DisplayCells() (_XlibCurrentDisplay->dcells) 29: #define ProtocolVersion() (_XlibCurrentDisplay->vnumber) 30: #define DisplayName() (_XlibCurrentDisplay->displayname) 31: 32: /* Bitmask returned by XParseGeometry(). Each bit tells if the corresponding 33: value (x, y, width, height) was found in the parsed string. */ 34: 35: #define NoValue 0x0000 36: #define XValue 0x0001 37: #define YValue 0x0002 38: #define WidthValue 0x0004 39: #define HeightValue 0x0008 40: #define AllValues 0x000F 41: #define XNegative 0x0010 42: #define YNegative 0x0020 43: 44: /* Definition of a generic event. It must be cast to a specific event 45: * type before one can read event-specific data */ 46: 47: typedef struct _XEvent { 48: unsigned long type; /* of event (KeyPressed, ExposeWindow, etc.) */ 49: Window window; /* which selected this event */ 50: long pad_l1, pad_l2; /* event-specific data */ 51: Window subwindow; /* child window (if any) event actually happened in */ 52: long pad_l4; /* event-specific data */ 53: } XEvent; 54: 55: 56: /* 57: * _QEvent datatype for use in input queueing. 58: */ 59: typedef struct _qevent { 60: struct _qevent *next; 61: XEvent event; 62: } _QEvent; 63: 64: 65: /* 66: * Display datatype maintaining display specific data. 67: */ 68: typedef struct _display { 69: int fd; /* Network socket. */ 70: Window root; /* Root window id. */ 71: int vnumber; /* X protocol version number. */ 72: int dtype; /* X server display device type. */ 73: int dplanes; /* Number of display bit planes. */ 74: int dcells; /* Number of display color map cells. */ 75: _QEvent *head, *tail; /* Input event queue. */ 76: int qlen; /* Length of input event queue */ 77: int request; /* Id of last request. */ 78: char * lastdraw; /* Last draw request. */ 79: char *buffer; /* Output buffer starting address. */ 80: char *bufptr; /* Output buffer index pointer. */ 81: char *bufmax; /* Output buffer maximum+1 address. */ 82: int squish; /* Squish MouseMoved events? */ 83: Pixmap black, white; /* Constant tile pixmaps */ 84: char *displayname; /* "host:display" string used on this connect*/ 85: int width, height; /* width and height of display */ 86: } Display; 87: 88: 89: /* 90: * XAssoc - Associations used in the XAssocTable data structure. The 91: * associations are used as circular queue entries in the association table 92: * which is contains an array of circular queues (buckets). 93: */ 94: typedef struct _x_assoc { 95: struct _x_assoc *next; /* Next object in this bucket. */ 96: struct _x_assoc *prev; /* Previous obejct in this bucket. */ 97: Display *display; /* Display which ownes the id. */ 98: XId x_id; /* X Window System id. */ 99: char *data; /* Pointer to untyped memory. */ 100: } XAssoc; 101: 102: /* 103: * XAssocTable - X Window System id to data structure pointer association 104: * table. An XAssocTable consists of a pointer to an array of XAssoc's 105: * (table) which are circular queue (bucket) headers and an integer (size) 106: * representing the number of circular queues (buckets) in the array. 107: */ 108: typedef struct _x_assoc_table { 109: struct _x_assoc (*table)[]; /* Array of association queues. */ 110: int size; /* Table size. */ 111: } XAssocTable; 112: 113: 114: /* 115: * Data returned by XQueryWindow. 116: */ 117: typedef struct _WindowInfo { 118: short width, height; /* Width and height. */ 119: short x, y; /* X and y coordinates. */ 120: short bdrwidth; /* Border width. */ 121: short mapped; /* IsUnmapped, IsMapped or IsInvisible.*/ 122: short type; /* IsTransparent, IsOpaque or IsIcon. */ 123: Window assoc_wind; /* Associated icon or opaque Window. */ 124: } WindowInfo; 125: 126: 127: /* 128: * Data returned by XQueryFont. 129: */ 130: typedef struct _FontInfo { 131: Font id; 132: short height, width, baseline, fixedwidth; 133: unsigned char firstchar, lastchar; 134: short *widths; /* pointer to width array in OpenFont */ 135: } FontInfo; 136: 137: 138: /* 139: * Data structure used by color operations; ints rather than shorts 140: * to keep 16 bit protocol limitation out of the library. 141: */ 142: typedef struct _Color { 143: int pixel; 144: unsigned short red, green, blue; 145: } Color; 146: 147: 148: /* 149: * Data structure use by XCreateTiles. 150: */ 151: typedef struct _TileFrame { 152: int pixel; /* Pixel color for constructing the tile. */ 153: Pixmap pixmap; /* Pixmap id of the pixmap, filled in later. */ 154: } TileFrame; 155: 156: 157: /* 158: * Data structures used by XCreateWindows XCreateTransparencies and 159: * XCreateWindowBatch. 160: */ 161: typedef struct _OpaqueFrame { 162: Window self; /* window id of the window, filled in later */ 163: short x, y; /* where to create the window */ 164: short width, height; /* width and height */ 165: short bdrwidth; /* border width */ 166: Pixmap border; /* border pixmap */ 167: Pixmap background; /* background */ 168: } OpaqueFrame; 169: 170: typedef struct _TransparentFrame { 171: Window self; /* window id of the window, filled in later */ 172: short x, y; /* where to create the window */ 173: short width, height; /* width and height */ 174: } TransparentFrame; 175: 176: typedef struct _BatchFrame { 177: short type; /* One of (IsOpaque, IsTransparent). */ 178: Window parent; /* Window if of the window's parent. */ 179: Window self; /* Window id of the window, filled in later. */ 180: short x, y; /* Where to create the window. */ 181: short width, height; /* Window width and height. */ 182: short bdrwidth; /* Window border width. */ 183: Pixmap border; /* Window border pixmap */ 184: Pixmap background; /* Window background pixmap. */ 185: } BatchFrame; 186: 187: 188: /* 189: * Definitions of specific events 190: * In all of the following, fields whose names begin with "pad" contain 191: * no meaningful value. 192: */ 193: 194: struct _XKeyOrButtonEvent { 195: unsigned long type; /* of event (KeyPressed, ButtonReleased, etc.) */ 196: Window window; /* which selected this event */ 197: unsigned short time; /* in 10 millisecond ticks */ 198: short detail; /* event-dependent data (key state, etc.) */ 199: short x; /* mouse x coordinate within event window */ 200: short y; /* mouse y coordinate within event window */ 201: Window subwindow; /* child window (if any) mouse was in */ 202: Locator location; /* absolute coordinates of mouse */ 203: }; 204: 205: typedef struct _XKeyOrButtonEvent XKeyOrButtonEvent; 206: 207: typedef struct _XKeyOrButtonEvent XKeyEvent; 208: typedef struct _XKeyOrButtonEvent XKeyPressedEvent; 209: typedef struct _XKeyOrButtonEvent XKeyReleasedEvent; 210: 211: typedef struct _XKeyOrButtonEvent XButtonEvent; 212: typedef struct _XKeyOrButtonEvent XButtonPressedEvent; 213: typedef struct _XKeyOrButtonEvent XButtonReleasedEvent; 214: 215: struct _XMouseOrCrossingEvent { 216: unsigned long type; /* EnterWindow, LeaveWindow, or MouseMoved */ 217: Window window; /* which selected this event */ 218: short pad_s2; 219: short detail; /* event-dependent data (key state, etc. ) */ 220: short x; /* mouse x coordinate within event window */ 221: short y; /* mouse y coordinate within event window */ 222: Window subwindow; /* child window (if any) mouse was in */ 223: Locator location; /* absolute coordinates of mouse */ 224: }; 225: 226: typedef struct _XMouseOrCrossingEvent XMouseOrCrossingEvent; 227: 228: typedef struct _XMouseOrCrossingEvent XMouseEvent; 229: typedef struct _XMouseOrCrossingEvent XMouseMovedEvent; 230: 231: typedef struct _XMouseOrCrossingEvent XCrossingEvent; 232: typedef struct _XMouseOrCrossingEvent XEnterWindowEvent; 233: typedef struct _XMouseOrCrossingEvent XLeaveWindowEvent; 234: 235: struct _XExposeEvent { 236: unsigned long type; /* ExposeWindow or ExposeRegion */ 237: Window window; /* that selected this event */ 238: short pad_s2; 239: short detail; /* 0 or ExposeCopy */ 240: short width; /* width of exposed area */ 241: short height; /* height of exposed area */ 242: Window subwindow; /* child window (if any) actually exposed */ 243: short y; /* top of exposed area (0 for ExposeWindow) */ 244: short x; /* left edge of exposed area (0 for ExposeWindow) */ 245: }; 246: 247: typedef struct _XExposeEvent XExposeEvent; 248: typedef struct _XExposeEvent XExposeWindowEvent; 249: typedef struct _XExposeEvent XExposeRegionEvent; 250: 251: typedef struct _XExposeCopyEvent { 252: unsigned long type; /* ExposeCopy */ 253: Window window; /* that selected this event */ 254: long pad_l1; 255: long pad_l2; 256: Window subwindow; /* child window (if any) actually exposed */ 257: long pad_l4; 258: } XExposeCopyEvent; 259: 260: typedef struct _XUnmapEvent { 261: unsigned long type; /* UnmapWindow */ 262: Window window; /* that selected this event */ 263: long pad_l1; 264: long pad_l2; 265: Window subwindow; /* child window (if any) actually unmapped */ 266: long pad_l4; 267: } XUnmapEvent; 268: 269: typedef struct _XFocusChangeEvent { 270: unsigned long type; /* FocusChange */ 271: Window window; /* that selected this event */ 272: short pad_s2; 273: short detail; /* EnterWindow or LeaveWindow */ 274: long pad_l2; 275: Window subwindow; /* child window (if any) of actual focus change*/ 276: long pad_l4; 277: } XFocusChangeEvent; 278: 279: typedef struct _XErrorEvent { 280: long pad; 281: long serial; /* serial number of failed request */ 282: char error_code; /* error code of failed request */ 283: char request_code; /* request code of failed request */ 284: char func; /* function field of failed request */ 285: char pad_b7; 286: Window window; /* Window of failed request */ 287: long pad_l3; 288: long pad_l4; 289: } XErrorEvent; 290: 291: /* 292: * Line pattern related definitions for the library. 293: */ 294: typedef long Pattern; 295: 296: #define DashedLine XMakePattern(0xf0f0, 16, 1) 297: #define DottedLine XMakePattern(0xaaaa, 16, 1) 298: #define DotDashLine XMakePattern(0xf4f4, 16, 1) 299: #define SolidLine XMakePattern(1,1,1) 300: 301: typedef short KeyMapEntry [8]; 302: 303: /* define values for keyboard map table */ 304: /* these values will vanish in the next version; DO NOT USE THEM! */ 305: #define SHFT (short) -2 306: #define CNTL (short) -3 307: #define LOCK (short) -4 308: #define SYMBOL (short) -5 309: #define KEYPAD (short) -6 310: #define CURSOR (short) -7 311: #define PFX (short) -8 312: #define FUNC1 (short) -9 313: #define FUNC2 (short) -10 314: #define FUNC3 (short) -11 315: #define FUNC4 (short) -12 316: #define FUNC5 (short) -13 317: #define FUNC6 (short) -14 318: #define FUNC7 (short) -15 319: #define FUNC8 (short) -16 320: #define FUNC9 (short) -17 321: #define FUNC10 (short) -18 322: #define FUNC11 (short) -19 323: #define FUNC12 (short) -20 324: #define FUNC13 (short) -21 325: #define FUNC14 (short) -22 326: #define FUNC15 (short) -23 327: #define FUNC16 (short) -24 328: #define FUNC17 (short) -25 329: #define FUNC18 (short) -26 330: #define FUNC19 (short) -27 331: #define FUNC20 (short) -28 332: #define E1 (short) -29 333: #define E2 (short) -30 334: #define E3 (short) -31 335: #define E4 (short) -32 336: #define E5 (short) -33 337: #define E6 (short) -34 338: 339: 340: /* 341: * X function declarations. 342: */ 343: Display *XOpenDisplay(); 344: 345: char *XFetchBytes(); 346: char * XFetchBuffer(); 347: 348: char *XErrDescrip(); 349: char *XLookupMapping(); 350: 351: short *XFontWidths(); 352: FontInfo *XOpenFont(); 353: extern Display *_XlibCurrentDisplay; 354: char *XGetDefault(); 355: Bitmap XCharBitmap(), XStoreBitmap(); 356: Pixmap XMakePixmap(), XMakeTile(), XStorePixmapXY(), XStorePixmapZ(); 357: Pixmap XPixmapSave(); 358: Cursor XCreateCursor(), XStoreCursor(); 359: Window XCreate(), XCreateTerm(), XCreateTransparency(), XCreateWindow(); 360: Window XGetIconWindow(); 361: Font XGetFont(); 362: Status XFetchName(), XGetColorCells(), XGetColor(), XGetHardwareColor(); 363: Status XGetResizeHint(), XGrabButton(), XGrabMouse(), XInterpretLocator(); 364: Status XParseColor(), XPixmapGetXY(), XPismapGetZ(), XQueryMouseButtons(); 365: Status XQueryFont(), XQueryMouse(), XQueryTree(), XQueryWindow(); 366: Status XReadBitmapFile(), XUpdateMouse();