#ifndef _EXTUTIL_H_
#define _EXTUTIL_H_
#include <X11/extensions/Xext.h>
typedef struct _XExtDisplayInfo {
struct _XExtDisplayInfo *next;
Display *display;
XExtCodes *codes;
XPointer data;
} XExtDisplayInfo;
typedef struct _XExtensionInfo {
XExtDisplayInfo *head;
XExtDisplayInfo *cur;
int ndisplays;
} XExtensionInfo;
typedef struct _XExtensionHooks {
int (*create_gc)(
#if NeedNestedPrototypes
Display* ,
GC ,
XExtCodes*
#endif
);
int (*copy_gc)(
#if NeedNestedPrototypes
Display* ,
GC ,
XExtCodes*
#endif
);
int (*flush_gc)(
#if NeedNestedPrototypes
Display* ,
GC ,
XExtCodes*
#endif
);
int (*free_gc)(
#if NeedNestedPrototypes
Display* ,
GC ,
XExtCodes*
#endif
);
int (*create_font)(
#if NeedNestedPrototypes
Display* ,
XFontStruct* ,
XExtCodes*
#endif
);
int (*free_font)(
#if NeedNestedPrototypes
Display* ,
XFontStruct* ,
XExtCodes*
#endif
);
int (*close_display)(
#if NeedNestedPrototypes
Display* ,
XExtCodes*
#endif
);
Bool (*wire_to_event)(
#if NeedNestedPrototypes
Display* ,
XEvent* ,
xEvent*
#endif
);
Status (*event_to_wire)(
#if NeedNestedPrototypes
Display* ,
XEvent* ,
xEvent*
#endif
);
int (*error)(
#if NeedNestedPrototypes
Display* ,
xError* ,
XExtCodes* ,
int*
#endif
);
char *(*error_string)(
#if NeedNestedPrototypes
Display* ,
int ,
XExtCodes* ,
char* ,
int
#endif
);
} XExtensionHooks;
extern XExtensionInfo *XextCreateExtension(
#if NeedFunctionPrototypes
void
#endif
);
extern void XextDestroyExtension(
#if NeedFunctionPrototypes
XExtensionInfo*
#endif
);
extern XExtDisplayInfo *XextAddDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* ,
Display* ,
char* ,
XExtensionHooks* ,
int ,
XPointer
#endif
);
extern int XextRemoveDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* ,
Display*
#endif
);
extern XExtDisplayInfo *XextFindDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* ,
Display*
#endif
);
#define XextHasExtension(i) ((i) && ((i)->codes))
#define XextCheckExtension(dpy,i,name,val) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
#define XextSimpleCheckExtension(dpy,i,name) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
XExtDisplayInfo *proc (Display *dpy) \
{ \
XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \
}
#define XEXT_FIND_DISPLAY_PROTO(proc) \
XExtDisplayInfo *proc(Display *dpy)
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \
{ \
return XextRemoveDisplay (extinfo, dpy); \
}
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
int proc(Display *dpy, XExtCodes *codes)
#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
{ \
code -= codes->first_error; \
if (code >= 0 && code < nerr) { \
char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \
XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \
} \
return (char *)0; \
}
#define XEXT_ERROR_STRING_PROTO(proc) \
char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
#endif