comparison src/video/Xext/extensions/extutil.h @ 1168:045f186426e1

Dynamically load X11 libraries like we currently do for alsa, esd, etc. This allows you to run an SDL program on a system without Xlib, since it'll just report the x11 target unavailable at runtime.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 05 Nov 2005 19:53:37 +0000
parents eadc0746dfaf
children c0a74f199ecf
comparison
equal deleted inserted replaced
1167:435c2e481299 1168:045f186426e1
171 #endif 171 #endif
172 ); 172 );
173 173
174 #define XextHasExtension(i) ((i) && ((i)->codes)) 174 #define XextHasExtension(i) ((i) && ((i)->codes))
175 #define XextCheckExtension(dpy,i,name,val) \ 175 #define XextCheckExtension(dpy,i,name,val) \
176 if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } 176 if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return val; }
177 #define XextSimpleCheckExtension(dpy,i,name) \ 177 #define XextSimpleCheckExtension(dpy,i,name) \
178 if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; } 178 if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return; }
179 179
180 180
181 /* 181 /*
182 * helper macros to generate code that is common to all extensions; caller 182 * helper macros to generate code that is common to all extensions; caller
183 * should prefix it with static if extension source is in one file; this 183 * should prefix it with static if extension source is in one file; this
186 */ 186 */
187 #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \ 187 #define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
188 XExtDisplayInfo *proc (Display *dpy) \ 188 XExtDisplayInfo *proc (Display *dpy) \
189 { \ 189 { \
190 XExtDisplayInfo *dpyinfo; \ 190 XExtDisplayInfo *dpyinfo; \
191 if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \ 191 if (!extinfo) { if (!(extinfo = pXextCreateExtension())) return NULL; } \
192 if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \ 192 if (!(dpyinfo = pXextFindDisplay (extinfo, dpy))) \
193 dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \ 193 dpyinfo = pXextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
194 return dpyinfo; \ 194 return dpyinfo; \
195 } 195 }
196 196
197 #define XEXT_FIND_DISPLAY_PROTO(proc) \ 197 #define XEXT_FIND_DISPLAY_PROTO(proc) \
198 XExtDisplayInfo *proc(Display *dpy) 198 XExtDisplayInfo *proc(Display *dpy)
199 199
200 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \ 200 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
201 int proc (Display *dpy, XExtCodes *codes) \ 201 int proc (Display *dpy, XExtCodes *codes) \
202 { \ 202 { \
203 return XextRemoveDisplay (extinfo, dpy); \ 203 return pXextRemoveDisplay (extinfo, dpy); \
204 } 204 }
205 205
206 #define XEXT_CLOSE_DISPLAY_PROTO(proc) \ 206 #define XEXT_CLOSE_DISPLAY_PROTO(proc) \
207 int proc(Display *dpy, XExtCodes *codes) 207 int proc(Display *dpy, XExtCodes *codes)
208 208
211 { \ 211 { \
212 code -= codes->first_error; \ 212 code -= codes->first_error; \
213 if (code >= 0 && code < nerr) { \ 213 if (code >= 0 && code < nerr) { \
214 char tmp[256]; \ 214 char tmp[256]; \
215 sprintf (tmp, "%s.%d", extname, code); \ 215 sprintf (tmp, "%s.%d", extname, code); \
216 XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \ 216 pXGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
217 return buf; \ 217 return buf; \
218 } \ 218 } \
219 return (char *)0; \ 219 return (char *)0; \
220 } 220 }
221 221