Mercurial > sdl-ios-xcode
diff src/video/Xext/Xxf86vm/XF86VMode.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 | b87d8d4c205d |
children | d05306f0dc21 |
line wrap: on
line diff
--- a/src/video/Xext/Xxf86vm/XF86VMode.c Sat Nov 05 17:41:11 2005 +0000 +++ b/src/video/Xext/Xxf86vm/XF86VMode.c Sat Nov 05 19:53:37 2005 +0000 @@ -47,6 +47,14 @@ #include "include/extensions/extutil.h" #endif +#include "../../x11/SDL_x11dyn.h" + +/* Workaround code in headers... */ +#define _XFlush p_XFlush +#define _XFlushGCCache p_XFlushGCCache +#define _XReply p_XReply +#define _XSend p_XSend + #ifdef DEBUG #include <stdio.h> #endif @@ -129,7 +137,7 @@ GetReq(XF86VidModeQueryVersion, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; @@ -197,7 +205,7 @@ req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGamma; req->screen = screen; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; @@ -233,7 +241,7 @@ req->screen = screen; if (majorVersion < 2) { - if (!_XReply(dpy, (xReply *)&oldrep, + if (!p_XReply(dpy, (xReply *)&oldrep, (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); @@ -252,7 +260,7 @@ modeline->flags = oldrep.flags; modeline->privsize = oldrep.privsize; } else { - if (!_XReply(dpy, (xReply *)&rep, + if (!p_XReply(dpy, (xReply *)&rep, (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); @@ -274,11 +282,11 @@ if (modeline->privsize > 0) { if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { - _XEatData(dpy, (modeline->privsize) * sizeof(INT32)); + p_XEatData(dpy, (modeline->privsize) * sizeof(INT32)); Xfree(modeline->private); return False; } - _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); + p_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); } else { modeline->private = NULL; } @@ -327,7 +335,7 @@ req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; req->screen = screen; - if (!_XReply(dpy, (xReply *)&rep, + if (!p_XReply(dpy, (xReply *)&rep, (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); SyncHandle(); @@ -340,9 +348,9 @@ sizeof(SDL_NAME(XF86VidModeModeInfo) *) +sizeof(SDL_NAME(XF86VidModeModeInfo))))) { if (majorVersion < 2) - _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); + p_XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); else - _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); + p_XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); Xfree(modelines); UnlockDisplay(dpy); SyncHandle(); @@ -356,7 +364,7 @@ for (i = 0; i < rep.modecount; i++) { modelines[i] = mdinfptr++; if (majorVersion < 2) { - _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo)); + p_XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo)); modelines[i]->dotclock = oldxmdline.dotclock; modelines[i]->hdisplay = oldxmdline.hdisplay; modelines[i]->hsyncstart = oldxmdline.hsyncstart; @@ -376,10 +384,10 @@ if (oldxmdline.privsize > 0) { if (!(modelines[i]->private = Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { - _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); + p_XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); Xfree(modelines[i]->private); } else { - _XRead(dpy, (char*)modelines[i]->private, + p_XRead(dpy, (char*)modelines[i]->private, oldxmdline.privsize * sizeof(INT32)); } } else { @@ -387,7 +395,7 @@ } } } else { - _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo)); + p_XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo)); modelines[i]->dotclock = xmdline.dotclock; modelines[i]->hdisplay = xmdline.hdisplay; modelines[i]->hsyncstart = xmdline.hsyncstart; @@ -407,10 +415,10 @@ if (xmdline.privsize > 0) { if (!(modelines[i]->private = Xcalloc(xmdline.privsize, sizeof(INT32)))) { - _XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); + p_XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); Xfree(modelines[i]->private); } else { - _XRead(dpy, (char*)modelines[i]->private, + p_XRead(dpy, (char*)modelines[i]->private, xmdline.privsize * sizeof(INT32)); } } else { @@ -432,7 +440,7 @@ #define GetOldReq(name, oldname, req) \ WORD64ALIGN\ if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ + p_XFlush(dpy);\ req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\ req->reqType = X_##name;\ req->length = (SIZEOF(x##oldname##Req))>>2;\ @@ -443,7 +451,7 @@ #define GetOldReq(name, oldname, req) \ WORD64ALIGN\ if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ + p_XFlush(dpy);\ req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\ req->reqType = X_/**/name;\ req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\ @@ -751,7 +759,7 @@ modeline->privsize * sizeof(INT32)); } } - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return MODE_BAD; @@ -913,7 +921,7 @@ req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; req->screen = screen; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; @@ -925,7 +933,7 @@ #endif if (rep.vendorLength) { if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); UnlockDisplay(dpy); SyncHandle(); @@ -936,7 +944,7 @@ } if (rep.modelLength) { if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); if (monitor->vendor) Xfree(monitor->vendor); @@ -948,7 +956,7 @@ monitor->model = NULL; } if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); if (monitor->vendor) @@ -960,7 +968,7 @@ return False; } if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); if (monitor->vendor) Xfree(monitor->vendor); @@ -972,21 +980,21 @@ return False; } for (i = 0; i < rep.nhsync; i++) { - _XRead(dpy, (char *)&syncrange, 4); + p_XRead(dpy, (char *)&syncrange, 4); monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0; } for (i = 0; i < rep.nvsync; i++) { - _XRead(dpy, (char *)&syncrange, 4); + p_XRead(dpy, (char *)&syncrange, 4); monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0; } if (rep.vendorLength) - _XReadPad(dpy, monitor->vendor, rep.vendorLength); + p_XReadPad(dpy, monitor->vendor, rep.vendorLength); else monitor->vendor = ""; if (rep.modelLength) - _XReadPad(dpy, monitor->model, rep.modelLength); + p_XReadPad(dpy, monitor->model, rep.modelLength); else monitor->model = ""; @@ -1034,7 +1042,7 @@ *x = 0; *y = 0; } else { - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; @@ -1092,7 +1100,7 @@ req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; req->screen = screen; - if (!_XReply(dpy, (xReply *)&rep, + if (!p_XReply(dpy, (xReply *)&rep, (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse)) { UnlockDisplay(dpy); @@ -1104,7 +1112,7 @@ *flagsPtr = rep.flags; if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) { - _XEatData(dpy, (rep.clocks) * 4); + p_XEatData(dpy, (rep.clocks) * 4); Xfree(dotclocks); UnlockDisplay(dpy); SyncHandle(); @@ -1112,7 +1120,7 @@ } for (i = 0; i < rep.clocks; i++) { - _XRead(dpy, (char*)&dotclk, 4); + p_XRead(dpy, (char*)&dotclk, 4); dotclocks[i] = dotclk; } *clocksPtr = dotclocks; @@ -1143,9 +1151,9 @@ req->screen = screen; req->length += (length >> 1) * 3; req->size = size; - _XSend(dpy, (char*)red, size * 2); - _XSend(dpy, (char*)green, size * 2); - _XSend(dpy, (char*)blue, size * 2); + p_XSend(dpy, (char*)red, size * 2); + p_XSend(dpy, (char*)green, size * 2); + p_XSend(dpy, (char*)blue, size * 2); UnlockDisplay(dpy); SyncHandle(); return True; @@ -1174,15 +1182,15 @@ req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; req->screen = screen; req->size = size; - if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { + if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return False; } if(rep.size) { - _XRead(dpy, (char*)red, rep.size << 1); - _XRead(dpy, (char*)green, rep.size << 1); - _XRead(dpy, (char*)blue, rep.size << 1); + p_XRead(dpy, (char*)red, rep.size << 1); + p_XRead(dpy, (char*)green, rep.size << 1); + p_XRead(dpy, (char*)blue, rep.size << 1); } UnlockDisplay(dpy); @@ -1209,7 +1217,7 @@ req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; req->screen = screen; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { + if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return False;