Mercurial > sdl-ios-xcode
comparison src/video/Xext/Xxf86dga/XF86DGA.c @ 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 | d05306f0dc21 |
comparison
equal
deleted
inserted
replaced
1167:435c2e481299 | 1168:045f186426e1 |
---|---|
54 | 54 |
55 #ifdef XNO_SYSCONF | 55 #ifdef XNO_SYSCONF |
56 #undef _SC_PAGESIZE | 56 #undef _SC_PAGESIZE |
57 #endif | 57 #endif |
58 | 58 |
59 | |
60 #define NEED_EVENTS | 59 #define NEED_EVENTS |
61 #define NEED_REPLIES | 60 #define NEED_REPLIES |
62 #include <X11/Xlibint.h> | 61 #include <X11/Xlibint.h> |
63 #include "xf86dga.h" | 62 #include "xf86dga.h" |
64 #include "xf86dgastr.h" | 63 #include "xf86dgastr.h" |
65 #include <X11/extensions/Xext.h> | 64 #include <X11/extensions/Xext.h> |
66 #include "extutil.h" | 65 #include "extutil.h" |
67 | 66 |
67 #include "../../x11/SDL_x11dyn.h" | |
68 | |
69 /* Workaround code in headers... */ | |
70 #define _XFlush p_XFlush | |
71 #define _XFlushGCCache p_XFlushGCCache | |
72 #define _XReply p_XReply | |
73 #define _XSend p_XSend | |
74 | |
68 extern XExtDisplayInfo* SDL_NAME(xdga_find_display)(Display*); | 75 extern XExtDisplayInfo* SDL_NAME(xdga_find_display)(Display*); |
69 extern char *SDL_NAME(xdga_extension_name); | 76 extern char *SDL_NAME(xdga_extension_name); |
70 | 77 |
71 #define XF86DGACheckExtension(dpy,i,val) \ | 78 #define XF86DGACheckExtension(dpy,i,val) \ |
72 XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val) | 79 XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val) |
110 LockDisplay(dpy); | 117 LockDisplay(dpy); |
111 GetReq(XF86DGAGetVideoLL, req); | 118 GetReq(XF86DGAGetVideoLL, req); |
112 req->reqType = info->codes->major_opcode; | 119 req->reqType = info->codes->major_opcode; |
113 req->dgaReqType = X_XF86DGAGetVideoLL; | 120 req->dgaReqType = X_XF86DGAGetVideoLL; |
114 req->screen = screen; | 121 req->screen = screen; |
115 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 122 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
116 UnlockDisplay(dpy); | 123 UnlockDisplay(dpy); |
117 SyncHandle(); | 124 SyncHandle(); |
118 return False; | 125 return False; |
119 } | 126 } |
120 | 127 |
145 req->dgaReqType = X_XF86DGADirectVideo; | 152 req->dgaReqType = X_XF86DGADirectVideo; |
146 req->screen = screen; | 153 req->screen = screen; |
147 req->enable = enable; | 154 req->enable = enable; |
148 UnlockDisplay(dpy); | 155 UnlockDisplay(dpy); |
149 SyncHandle(); | 156 SyncHandle(); |
150 XSync(dpy,False); | 157 pXSync(dpy,False); |
151 return True; | 158 return True; |
152 } | 159 } |
153 | 160 |
154 Bool SDL_NAME(XF86DGAGetViewPortSize)( | 161 Bool SDL_NAME(XF86DGAGetViewPortSize)( |
155 Display* dpy, | 162 Display* dpy, |
166 LockDisplay(dpy); | 173 LockDisplay(dpy); |
167 GetReq(XF86DGAGetViewPortSize, req); | 174 GetReq(XF86DGAGetViewPortSize, req); |
168 req->reqType = info->codes->major_opcode; | 175 req->reqType = info->codes->major_opcode; |
169 req->dgaReqType = X_XF86DGAGetViewPortSize; | 176 req->dgaReqType = X_XF86DGAGetViewPortSize; |
170 req->screen = screen; | 177 req->screen = screen; |
171 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 178 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
172 UnlockDisplay(dpy); | 179 UnlockDisplay(dpy); |
173 SyncHandle(); | 180 SyncHandle(); |
174 return False; | 181 return False; |
175 } | 182 } |
176 | 183 |
201 req->screen = screen; | 208 req->screen = screen; |
202 req->x = x; | 209 req->x = x; |
203 req->y = y; | 210 req->y = y; |
204 UnlockDisplay(dpy); | 211 UnlockDisplay(dpy); |
205 SyncHandle(); | 212 SyncHandle(); |
206 XSync(dpy,False); | 213 pXSync(dpy,False); |
207 return True; | 214 return True; |
208 } | 215 } |
209 | 216 |
210 | 217 |
211 Bool SDL_NAME(XF86DGAGetVidPage)( | 218 Bool SDL_NAME(XF86DGAGetVidPage)( |
222 LockDisplay(dpy); | 229 LockDisplay(dpy); |
223 GetReq(XF86DGAGetVidPage, req); | 230 GetReq(XF86DGAGetVidPage, req); |
224 req->reqType = info->codes->major_opcode; | 231 req->reqType = info->codes->major_opcode; |
225 req->dgaReqType = X_XF86DGAGetVidPage; | 232 req->dgaReqType = X_XF86DGAGetVidPage; |
226 req->screen = screen; | 233 req->screen = screen; |
227 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 234 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
228 UnlockDisplay(dpy); | 235 UnlockDisplay(dpy); |
229 SyncHandle(); | 236 SyncHandle(); |
230 return False; | 237 return False; |
231 } | 238 } |
232 | 239 |
253 req->dgaReqType = X_XF86DGASetVidPage; | 260 req->dgaReqType = X_XF86DGASetVidPage; |
254 req->screen = screen; | 261 req->screen = screen; |
255 req->vpage = vpage; | 262 req->vpage = vpage; |
256 UnlockDisplay(dpy); | 263 UnlockDisplay(dpy); |
257 SyncHandle(); | 264 SyncHandle(); |
258 XSync(dpy,False); | 265 pXSync(dpy,False); |
259 return True; | 266 return True; |
260 } | 267 } |
261 | 268 |
262 Bool SDL_NAME(XF86DGAInstallColormap)( | 269 Bool SDL_NAME(XF86DGAInstallColormap)( |
263 Display* dpy, | 270 Display* dpy, |
275 req->dgaReqType = X_XF86DGAInstallColormap; | 282 req->dgaReqType = X_XF86DGAInstallColormap; |
276 req->screen = screen; | 283 req->screen = screen; |
277 req->id = cmap; | 284 req->id = cmap; |
278 UnlockDisplay(dpy); | 285 UnlockDisplay(dpy); |
279 SyncHandle(); | 286 SyncHandle(); |
280 XSync(dpy,False); | 287 pXSync(dpy,False); |
281 return True; | 288 return True; |
282 } | 289 } |
283 | 290 |
284 Bool SDL_NAME(XF86DGAQueryDirectVideo)( | 291 Bool SDL_NAME(XF86DGAQueryDirectVideo)( |
285 Display *dpy, | 292 Display *dpy, |
295 LockDisplay(dpy); | 302 LockDisplay(dpy); |
296 GetReq(XF86DGAQueryDirectVideo, req); | 303 GetReq(XF86DGAQueryDirectVideo, req); |
297 req->reqType = info->codes->major_opcode; | 304 req->reqType = info->codes->major_opcode; |
298 req->dgaReqType = X_XF86DGAQueryDirectVideo; | 305 req->dgaReqType = X_XF86DGAQueryDirectVideo; |
299 req->screen = screen; | 306 req->screen = screen; |
300 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 307 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
301 UnlockDisplay(dpy); | 308 UnlockDisplay(dpy); |
302 SyncHandle(); | 309 SyncHandle(); |
303 return False; | 310 return False; |
304 } | 311 } |
305 *flags = rep.flags; | 312 *flags = rep.flags; |
323 GetReq(XF86DGAViewPortChanged, req); | 330 GetReq(XF86DGAViewPortChanged, req); |
324 req->reqType = info->codes->major_opcode; | 331 req->reqType = info->codes->major_opcode; |
325 req->dgaReqType = X_XF86DGAViewPortChanged; | 332 req->dgaReqType = X_XF86DGAViewPortChanged; |
326 req->screen = screen; | 333 req->screen = screen; |
327 req->n = n; | 334 req->n = n; |
328 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 335 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
329 UnlockDisplay(dpy); | 336 UnlockDisplay(dpy); |
330 SyncHandle(); | 337 SyncHandle(); |
331 return False; | 338 return False; |
332 } | 339 } |
333 UnlockDisplay(dpy); | 340 UnlockDisplay(dpy); |
596 | 603 |
597 waitpid(pid, &status, 0); | 604 waitpid(pid, &status, 0); |
598 for (i = 0; i < numScrs; i++) { | 605 for (i = 0; i < numScrs; i++) { |
599 sp = scrList[i]; | 606 sp = scrList[i]; |
600 SDL_NAME(XF86DGADirectVideoLL)(sp->display, sp->screen, 0); | 607 SDL_NAME(XF86DGADirectVideoLL)(sp->display, sp->screen, 0); |
601 XSync(sp->display, False); | 608 pXSync(sp->display, False); |
602 } | 609 } |
603 if (WIFEXITED(status)) | 610 if (WIFEXITED(status)) |
604 _exit(0); | 611 _exit(0); |
605 else | 612 else |
606 _exit(-1); | 613 _exit(-1); |
656 beenhere = 1; | 663 beenhere = 1; |
657 | 664 |
658 for (i = 0; i < numScrs; i++) { | 665 for (i = 0; i < numScrs; i++) { |
659 sp = scrList[i]; | 666 sp = scrList[i]; |
660 SDL_NAME(XF86DGADirectVideo)(sp->display, sp->screen, 0); | 667 SDL_NAME(XF86DGADirectVideo)(sp->display, sp->screen, 0); |
661 XSync(sp->display, False); | 668 pXSync(sp->display, False); |
662 } | 669 } |
663 _exit(3); | 670 _exit(3); |
664 } | 671 } |
665 | 672 |
666 Bool | 673 Bool |