| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | #ifndef _EXTUTIL_H_ |
| 35 | #define _EXTUTIL_H_ |
| 36 | |
| 37 | #include <X11/extensions/Xext.h> |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | typedef struct _XExtDisplayInfo { |
| 45 | struct _XExtDisplayInfo *next; |
| 46 | Display *display; |
| 47 | XExtCodes *codes; |
| 48 | XPointer data; |
| 49 | } XExtDisplayInfo; |
| 50 | |
| 51 | typedef struct _XExtensionInfo { |
| 52 | XExtDisplayInfo *head; |
| 53 | XExtDisplayInfo *cur; |
| 54 | int ndisplays; |
| 55 | } XExtensionInfo; |
| 56 | |
| 57 | typedef struct _XExtensionHooks { |
| 58 | int (*create_gc)( |
| 59 | Display* , |
| 60 | GC , |
| 61 | XExtCodes* |
| 62 | ); |
| 63 | int (*copy_gc)( |
| 64 | Display* , |
| 65 | GC , |
| 66 | XExtCodes* |
| 67 | ); |
| 68 | int (*flush_gc)( |
| 69 | Display* , |
| 70 | GC , |
| 71 | XExtCodes* |
| 72 | ); |
| 73 | int (*free_gc)( |
| 74 | Display* , |
| 75 | GC , |
| 76 | XExtCodes* |
| 77 | ); |
| 78 | int (*create_font)( |
| 79 | Display* , |
| 80 | XFontStruct* , |
| 81 | XExtCodes* |
| 82 | ); |
| 83 | int (*free_font)( |
| 84 | Display* , |
| 85 | XFontStruct* , |
| 86 | XExtCodes* |
| 87 | ); |
| 88 | int (*close_display)( |
| 89 | Display* , |
| 90 | XExtCodes* |
| 91 | ); |
| 92 | Bool (*wire_to_event)( |
| 93 | Display* , |
| 94 | XEvent* , |
| 95 | xEvent* |
| 96 | ); |
| 97 | Status (*event_to_wire)( |
| 98 | Display* , |
| 99 | XEvent* , |
| 100 | xEvent* |
| 101 | ); |
| 102 | int (*error)( |
| 103 | Display* , |
| 104 | xError* , |
| 105 | XExtCodes* , |
| 106 | int* |
| 107 | ); |
| 108 | char *(*error_string)( |
| 109 | Display* , |
| 110 | int , |
| 111 | XExtCodes* , |
| 112 | char* , |
| 113 | int |
| 114 | ); |
| 115 | } XExtensionHooks; |
| 116 | |
| 117 | extern XExtensionInfo *XextCreateExtension( |
| 118 | void |
| 119 | ); |
| 120 | extern void XextDestroyExtension( |
| 121 | XExtensionInfo* |
| 122 | ); |
| 123 | extern XExtDisplayInfo *XextAddDisplay( |
| 124 | XExtensionInfo* , |
| 125 | Display* , |
| 126 | _Xconst char* , |
| 127 | XExtensionHooks* , |
| 128 | int , |
| 129 | XPointer |
| 130 | ); |
| 131 | extern int XextRemoveDisplay( |
| 132 | XExtensionInfo* , |
| 133 | Display* |
| 134 | ); |
| 135 | extern XExtDisplayInfo *XextFindDisplay( |
| 136 | XExtensionInfo* , |
| 137 | Display* |
| 138 | ); |
| 139 | |
| 140 | #define XextHasExtension(i) ((i) && ((i)->codes)) |
| 141 | #define XextCheckExtension(dpy,i,name,val) do { \ |
| 142 | if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } \ |
| 143 | } while (0) |
| 144 | #define XextSimpleCheckExtension(dpy,i,name) do { \ |
| 145 | if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; } \ |
| 146 | } while (0) |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \ |
| 156 | XExtDisplayInfo *proc (Display *dpy) \ |
| 157 | { \ |
| 158 | XExtDisplayInfo *dpyinfo; \ |
| 159 | if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \ |
| 160 | if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \ |
| 161 | dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \ |
| 162 | return dpyinfo; \ |
| 163 | } |
| 164 | |
| 165 | #define XEXT_FIND_DISPLAY_PROTO(proc) \ |
| 166 | XExtDisplayInfo *proc(Display *dpy) |
| 167 | |
| 168 | #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \ |
| 169 | int proc (Display *dpy, XExtCodes *codes) \ |
| 170 | { \ |
| 171 | return XextRemoveDisplay (extinfo, dpy); \ |
| 172 | } |
| 173 | |
| 174 | #define XEXT_CLOSE_DISPLAY_PROTO(proc) \ |
| 175 | int proc(Display *dpy, XExtCodes *codes) |
| 176 | |
| 177 | #define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \ |
| 178 | char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \ |
| 179 | { \ |
| 180 | code -= codes->first_error; \ |
| 181 | if (code >= 0 && code < nerr) { \ |
| 182 | char tmp[256]; \ |
| 183 | snprintf (tmp, sizeof(tmp), "%s.%d", extname, code); \ |
| 184 | XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \ |
| 185 | return buf; \ |
| 186 | } \ |
| 187 | return (char *)0; \ |
| 188 | } |
| 189 | |
| 190 | #define XEXT_ERROR_STRING_PROTO(proc) \ |
| 191 | char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n) |
| 192 | #endif |