File indexing completed on 2025-01-30 10:26:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef _EXTUTIL_H_
0035 #define _EXTUTIL_H_
0036
0037 #include <X11/extensions/Xext.h>
0038
0039
0040
0041
0042
0043
0044 typedef struct _XExtDisplayInfo {
0045 struct _XExtDisplayInfo *next;
0046 Display *display;
0047 XExtCodes *codes;
0048 XPointer data;
0049 } XExtDisplayInfo;
0050
0051 typedef struct _XExtensionInfo {
0052 XExtDisplayInfo *head;
0053 XExtDisplayInfo *cur;
0054 int ndisplays;
0055 } XExtensionInfo;
0056
0057 typedef struct _XExtensionHooks {
0058 int (*create_gc)(
0059 Display* ,
0060 GC ,
0061 XExtCodes*
0062 );
0063 int (*copy_gc)(
0064 Display* ,
0065 GC ,
0066 XExtCodes*
0067 );
0068 int (*flush_gc)(
0069 Display* ,
0070 GC ,
0071 XExtCodes*
0072 );
0073 int (*free_gc)(
0074 Display* ,
0075 GC ,
0076 XExtCodes*
0077 );
0078 int (*create_font)(
0079 Display* ,
0080 XFontStruct* ,
0081 XExtCodes*
0082 );
0083 int (*free_font)(
0084 Display* ,
0085 XFontStruct* ,
0086 XExtCodes*
0087 );
0088 int (*close_display)(
0089 Display* ,
0090 XExtCodes*
0091 );
0092 Bool (*wire_to_event)(
0093 Display* ,
0094 XEvent* ,
0095 xEvent*
0096 );
0097 Status (*event_to_wire)(
0098 Display* ,
0099 XEvent* ,
0100 xEvent*
0101 );
0102 int (*error)(
0103 Display* ,
0104 xError* ,
0105 XExtCodes* ,
0106 int*
0107 );
0108 char *(*error_string)(
0109 Display* ,
0110 int ,
0111 XExtCodes* ,
0112 char* ,
0113 int
0114 );
0115 } XExtensionHooks;
0116
0117 extern XExtensionInfo *XextCreateExtension(
0118 void
0119 );
0120 extern void XextDestroyExtension(
0121 XExtensionInfo*
0122 );
0123 extern XExtDisplayInfo *XextAddDisplay(
0124 XExtensionInfo* ,
0125 Display* ,
0126 _Xconst char* ,
0127 XExtensionHooks* ,
0128 int ,
0129 XPointer
0130 );
0131 extern int XextRemoveDisplay(
0132 XExtensionInfo* ,
0133 Display*
0134 );
0135 extern XExtDisplayInfo *XextFindDisplay(
0136 XExtensionInfo* ,
0137 Display*
0138 );
0139
0140 #define XextHasExtension(i) ((i) && ((i)->codes))
0141 #define XextCheckExtension(dpy,i,name,val) do { \
0142 if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } \
0143 } while (0)
0144 #define XextSimpleCheckExtension(dpy,i,name) do { \
0145 if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; } \
0146 } while (0)
0147
0148
0149
0150
0151
0152
0153
0154
0155 #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
0156 XExtDisplayInfo *proc (Display *dpy) \
0157 { \
0158 XExtDisplayInfo *dpyinfo; \
0159 if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
0160 if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
0161 dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
0162 return dpyinfo; \
0163 }
0164
0165 #define XEXT_FIND_DISPLAY_PROTO(proc) \
0166 XExtDisplayInfo *proc(Display *dpy)
0167
0168 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
0169 int proc (Display *dpy, XExtCodes *codes) \
0170 { \
0171 return XextRemoveDisplay (extinfo, dpy); \
0172 }
0173
0174 #define XEXT_CLOSE_DISPLAY_PROTO(proc) \
0175 int proc(Display *dpy, XExtCodes *codes)
0176
0177 #define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
0178 char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
0179 { \
0180 code -= codes->first_error; \
0181 if (code >= 0 && code < nerr) { \
0182 char tmp[256]; \
0183 snprintf (tmp, sizeof(tmp), "%s.%d", extname, code); \
0184 XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
0185 return buf; \
0186 } \
0187 return (char *)0; \
0188 }
0189
0190 #define XEXT_ERROR_STRING_PROTO(proc) \
0191 char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
0192 #endif