Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
1167:435c2e481299 | 1168:045f186426e1 |
---|---|
44 #include "lib/X11/Xlibint.h" | 44 #include "lib/X11/Xlibint.h" |
45 #include "include/extensions/xf86vmstr.h" | 45 #include "include/extensions/xf86vmstr.h" |
46 #include "include/extensions/Xext.h" | 46 #include "include/extensions/Xext.h" |
47 #include "include/extensions/extutil.h" | 47 #include "include/extensions/extutil.h" |
48 #endif | 48 #endif |
49 | |
50 #include "../../x11/SDL_x11dyn.h" | |
51 | |
52 /* Workaround code in headers... */ | |
53 #define _XFlush p_XFlush | |
54 #define _XFlushGCCache p_XFlushGCCache | |
55 #define _XReply p_XReply | |
56 #define _XSend p_XSend | |
49 | 57 |
50 #ifdef DEBUG | 58 #ifdef DEBUG |
51 #include <stdio.h> | 59 #include <stdio.h> |
52 #endif | 60 #endif |
53 | 61 |
127 | 135 |
128 LockDisplay(dpy); | 136 LockDisplay(dpy); |
129 GetReq(XF86VidModeQueryVersion, req); | 137 GetReq(XF86VidModeQueryVersion, req); |
130 req->reqType = info->codes->major_opcode; | 138 req->reqType = info->codes->major_opcode; |
131 req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; | 139 req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; |
132 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 140 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
133 UnlockDisplay(dpy); | 141 UnlockDisplay(dpy); |
134 SyncHandle(); | 142 SyncHandle(); |
135 return False; | 143 return False; |
136 } | 144 } |
137 *majorVersion = rep.majorVersion; | 145 *majorVersion = rep.majorVersion; |
195 LockDisplay(dpy); | 203 LockDisplay(dpy); |
196 GetReq(XF86VidModeGetGamma, req); | 204 GetReq(XF86VidModeGetGamma, req); |
197 req->reqType = info->codes->major_opcode; | 205 req->reqType = info->codes->major_opcode; |
198 req->xf86vidmodeReqType = X_XF86VidModeGetGamma; | 206 req->xf86vidmodeReqType = X_XF86VidModeGetGamma; |
199 req->screen = screen; | 207 req->screen = screen; |
200 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 208 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
201 UnlockDisplay(dpy); | 209 UnlockDisplay(dpy); |
202 SyncHandle(); | 210 SyncHandle(); |
203 return False; | 211 return False; |
204 } | 212 } |
205 Gamma->red = ((float)rep.red) / 10000.; | 213 Gamma->red = ((float)rep.red) / 10000.; |
231 req->reqType = info->codes->major_opcode; | 239 req->reqType = info->codes->major_opcode; |
232 req->xf86vidmodeReqType = X_XF86VidModeGetModeLine; | 240 req->xf86vidmodeReqType = X_XF86VidModeGetModeLine; |
233 req->screen = screen; | 241 req->screen = screen; |
234 | 242 |
235 if (majorVersion < 2) { | 243 if (majorVersion < 2) { |
236 if (!_XReply(dpy, (xReply *)&oldrep, | 244 if (!p_XReply(dpy, (xReply *)&oldrep, |
237 (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { | 245 (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { |
238 UnlockDisplay(dpy); | 246 UnlockDisplay(dpy); |
239 SyncHandle(); | 247 SyncHandle(); |
240 return False; | 248 return False; |
241 } | 249 } |
250 modeline->vsyncend = oldrep.vsyncend; | 258 modeline->vsyncend = oldrep.vsyncend; |
251 modeline->vtotal = oldrep.vtotal; | 259 modeline->vtotal = oldrep.vtotal; |
252 modeline->flags = oldrep.flags; | 260 modeline->flags = oldrep.flags; |
253 modeline->privsize = oldrep.privsize; | 261 modeline->privsize = oldrep.privsize; |
254 } else { | 262 } else { |
255 if (!_XReply(dpy, (xReply *)&rep, | 263 if (!p_XReply(dpy, (xReply *)&rep, |
256 (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { | 264 (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { |
257 UnlockDisplay(dpy); | 265 UnlockDisplay(dpy); |
258 SyncHandle(); | 266 SyncHandle(); |
259 return False; | 267 return False; |
260 } | 268 } |
272 modeline->privsize = rep.privsize; | 280 modeline->privsize = rep.privsize; |
273 } | 281 } |
274 | 282 |
275 if (modeline->privsize > 0) { | 283 if (modeline->privsize > 0) { |
276 if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { | 284 if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { |
277 _XEatData(dpy, (modeline->privsize) * sizeof(INT32)); | 285 p_XEatData(dpy, (modeline->privsize) * sizeof(INT32)); |
278 Xfree(modeline->private); | 286 Xfree(modeline->private); |
279 return False; | 287 return False; |
280 } | 288 } |
281 _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); | 289 p_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); |
282 } else { | 290 } else { |
283 modeline->private = NULL; | 291 modeline->private = NULL; |
284 } | 292 } |
285 UnlockDisplay(dpy); | 293 UnlockDisplay(dpy); |
286 SyncHandle(); | 294 SyncHandle(); |
325 LockDisplay(dpy); | 333 LockDisplay(dpy); |
326 GetReq(XF86VidModeGetAllModeLines, req); | 334 GetReq(XF86VidModeGetAllModeLines, req); |
327 req->reqType = info->codes->major_opcode; | 335 req->reqType = info->codes->major_opcode; |
328 req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; | 336 req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; |
329 req->screen = screen; | 337 req->screen = screen; |
330 if (!_XReply(dpy, (xReply *)&rep, | 338 if (!p_XReply(dpy, (xReply *)&rep, |
331 (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) { | 339 (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) { |
332 UnlockDisplay(dpy); | 340 UnlockDisplay(dpy); |
333 SyncHandle(); | 341 SyncHandle(); |
334 return False; | 342 return False; |
335 } | 343 } |
338 | 346 |
339 if (!(modelines = (SDL_NAME(XF86VidModeModeInfo) **) Xcalloc(rep.modecount, | 347 if (!(modelines = (SDL_NAME(XF86VidModeModeInfo) **) Xcalloc(rep.modecount, |
340 sizeof(SDL_NAME(XF86VidModeModeInfo) *) | 348 sizeof(SDL_NAME(XF86VidModeModeInfo) *) |
341 +sizeof(SDL_NAME(XF86VidModeModeInfo))))) { | 349 +sizeof(SDL_NAME(XF86VidModeModeInfo))))) { |
342 if (majorVersion < 2) | 350 if (majorVersion < 2) |
343 _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); | 351 p_XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); |
344 else | 352 else |
345 _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); | 353 p_XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); |
346 Xfree(modelines); | 354 Xfree(modelines); |
347 UnlockDisplay(dpy); | 355 UnlockDisplay(dpy); |
348 SyncHandle(); | 356 SyncHandle(); |
349 return False; | 357 return False; |
350 } | 358 } |
354 ); | 362 ); |
355 | 363 |
356 for (i = 0; i < rep.modecount; i++) { | 364 for (i = 0; i < rep.modecount; i++) { |
357 modelines[i] = mdinfptr++; | 365 modelines[i] = mdinfptr++; |
358 if (majorVersion < 2) { | 366 if (majorVersion < 2) { |
359 _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo)); | 367 p_XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo)); |
360 modelines[i]->dotclock = oldxmdline.dotclock; | 368 modelines[i]->dotclock = oldxmdline.dotclock; |
361 modelines[i]->hdisplay = oldxmdline.hdisplay; | 369 modelines[i]->hdisplay = oldxmdline.hdisplay; |
362 modelines[i]->hsyncstart = oldxmdline.hsyncstart; | 370 modelines[i]->hsyncstart = oldxmdline.hsyncstart; |
363 modelines[i]->hsyncend = oldxmdline.hsyncend; | 371 modelines[i]->hsyncend = oldxmdline.hsyncend; |
364 modelines[i]->htotal = oldxmdline.htotal; | 372 modelines[i]->htotal = oldxmdline.htotal; |
374 } else { | 382 } else { |
375 modelines[i]->privsize = oldxmdline.privsize; | 383 modelines[i]->privsize = oldxmdline.privsize; |
376 if (oldxmdline.privsize > 0) { | 384 if (oldxmdline.privsize > 0) { |
377 if (!(modelines[i]->private = | 385 if (!(modelines[i]->private = |
378 Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { | 386 Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { |
379 _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); | 387 p_XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); |
380 Xfree(modelines[i]->private); | 388 Xfree(modelines[i]->private); |
381 } else { | 389 } else { |
382 _XRead(dpy, (char*)modelines[i]->private, | 390 p_XRead(dpy, (char*)modelines[i]->private, |
383 oldxmdline.privsize * sizeof(INT32)); | 391 oldxmdline.privsize * sizeof(INT32)); |
384 } | 392 } |
385 } else { | 393 } else { |
386 modelines[i]->private = NULL; | 394 modelines[i]->private = NULL; |
387 } | 395 } |
388 } | 396 } |
389 } else { | 397 } else { |
390 _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo)); | 398 p_XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo)); |
391 modelines[i]->dotclock = xmdline.dotclock; | 399 modelines[i]->dotclock = xmdline.dotclock; |
392 modelines[i]->hdisplay = xmdline.hdisplay; | 400 modelines[i]->hdisplay = xmdline.hdisplay; |
393 modelines[i]->hsyncstart = xmdline.hsyncstart; | 401 modelines[i]->hsyncstart = xmdline.hsyncstart; |
394 modelines[i]->hsyncend = xmdline.hsyncend; | 402 modelines[i]->hsyncend = xmdline.hsyncend; |
395 modelines[i]->htotal = xmdline.htotal; | 403 modelines[i]->htotal = xmdline.htotal; |
405 } else { | 413 } else { |
406 modelines[i]->privsize = xmdline.privsize; | 414 modelines[i]->privsize = xmdline.privsize; |
407 if (xmdline.privsize > 0) { | 415 if (xmdline.privsize > 0) { |
408 if (!(modelines[i]->private = | 416 if (!(modelines[i]->private = |
409 Xcalloc(xmdline.privsize, sizeof(INT32)))) { | 417 Xcalloc(xmdline.privsize, sizeof(INT32)))) { |
410 _XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); | 418 p_XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); |
411 Xfree(modelines[i]->private); | 419 Xfree(modelines[i]->private); |
412 } else { | 420 } else { |
413 _XRead(dpy, (char*)modelines[i]->private, | 421 p_XRead(dpy, (char*)modelines[i]->private, |
414 xmdline.privsize * sizeof(INT32)); | 422 xmdline.privsize * sizeof(INT32)); |
415 } | 423 } |
416 } else { | 424 } else { |
417 modelines[i]->private = NULL; | 425 modelines[i]->private = NULL; |
418 } | 426 } |
430 */ | 438 */ |
431 #if !defined(UNIXCPP) || defined(ANSICPP) | 439 #if !defined(UNIXCPP) || defined(ANSICPP) |
432 #define GetOldReq(name, oldname, req) \ | 440 #define GetOldReq(name, oldname, req) \ |
433 WORD64ALIGN\ | 441 WORD64ALIGN\ |
434 if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\ | 442 if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\ |
435 _XFlush(dpy);\ | 443 p_XFlush(dpy);\ |
436 req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\ | 444 req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\ |
437 req->reqType = X_##name;\ | 445 req->reqType = X_##name;\ |
438 req->length = (SIZEOF(x##oldname##Req))>>2;\ | 446 req->length = (SIZEOF(x##oldname##Req))>>2;\ |
439 dpy->bufptr += SIZEOF(x##oldname##Req);\ | 447 dpy->bufptr += SIZEOF(x##oldname##Req);\ |
440 dpy->request++ | 448 dpy->request++ |
441 | 449 |
442 #else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ | 450 #else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ |
443 #define GetOldReq(name, oldname, req) \ | 451 #define GetOldReq(name, oldname, req) \ |
444 WORD64ALIGN\ | 452 WORD64ALIGN\ |
445 if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\ | 453 if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\ |
446 _XFlush(dpy);\ | 454 p_XFlush(dpy);\ |
447 req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\ | 455 req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\ |
448 req->reqType = X_/**/name;\ | 456 req->reqType = X_/**/name;\ |
449 req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\ | 457 req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\ |
450 dpy->bufptr += SIZEOF(x/**/oldname/**/Req);\ | 458 dpy->bufptr += SIZEOF(x/**/oldname/**/Req);\ |
451 dpy->request++ | 459 dpy->request++ |
749 req->length += modeline->privsize; | 757 req->length += modeline->privsize; |
750 Data32(dpy, (long *) modeline->private, | 758 Data32(dpy, (long *) modeline->private, |
751 modeline->privsize * sizeof(INT32)); | 759 modeline->privsize * sizeof(INT32)); |
752 } | 760 } |
753 } | 761 } |
754 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 762 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
755 UnlockDisplay(dpy); | 763 UnlockDisplay(dpy); |
756 SyncHandle(); | 764 SyncHandle(); |
757 return MODE_BAD; | 765 return MODE_BAD; |
758 } | 766 } |
759 UnlockDisplay(dpy); | 767 UnlockDisplay(dpy); |
911 LockDisplay(dpy); | 919 LockDisplay(dpy); |
912 GetReq(XF86VidModeGetMonitor, req); | 920 GetReq(XF86VidModeGetMonitor, req); |
913 req->reqType = info->codes->major_opcode; | 921 req->reqType = info->codes->major_opcode; |
914 req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; | 922 req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; |
915 req->screen = screen; | 923 req->screen = screen; |
916 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 924 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
917 UnlockDisplay(dpy); | 925 UnlockDisplay(dpy); |
918 SyncHandle(); | 926 SyncHandle(); |
919 return False; | 927 return False; |
920 } | 928 } |
921 monitor->nhsync = rep.nhsync; | 929 monitor->nhsync = rep.nhsync; |
923 #if 0 | 931 #if 0 |
924 monitor->bandwidth = (float)rep.bandwidth / 1e6; | 932 monitor->bandwidth = (float)rep.bandwidth / 1e6; |
925 #endif | 933 #endif |
926 if (rep.vendorLength) { | 934 if (rep.vendorLength) { |
927 if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) { | 935 if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) { |
928 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + | 936 p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + |
929 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); | 937 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); |
930 UnlockDisplay(dpy); | 938 UnlockDisplay(dpy); |
931 SyncHandle(); | 939 SyncHandle(); |
932 return False; | 940 return False; |
933 } | 941 } |
934 } else { | 942 } else { |
935 monitor->vendor = NULL; | 943 monitor->vendor = NULL; |
936 } | 944 } |
937 if (rep.modelLength) { | 945 if (rep.modelLength) { |
938 if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { | 946 if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { |
939 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + | 947 p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + |
940 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); | 948 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); |
941 if (monitor->vendor) | 949 if (monitor->vendor) |
942 Xfree(monitor->vendor); | 950 Xfree(monitor->vendor); |
943 UnlockDisplay(dpy); | 951 UnlockDisplay(dpy); |
944 SyncHandle(); | 952 SyncHandle(); |
946 } | 954 } |
947 } else { | 955 } else { |
948 monitor->model = NULL; | 956 monitor->model = NULL; |
949 } | 957 } |
950 if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { | 958 if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { |
951 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + | 959 p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + |
952 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); | 960 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); |
953 | 961 |
954 if (monitor->vendor) | 962 if (monitor->vendor) |
955 Xfree(monitor->vendor); | 963 Xfree(monitor->vendor); |
956 if (monitor->model) | 964 if (monitor->model) |
958 UnlockDisplay(dpy); | 966 UnlockDisplay(dpy); |
959 SyncHandle(); | 967 SyncHandle(); |
960 return False; | 968 return False; |
961 } | 969 } |
962 if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { | 970 if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { |
963 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + | 971 p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + |
964 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); | 972 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); |
965 if (monitor->vendor) | 973 if (monitor->vendor) |
966 Xfree(monitor->vendor); | 974 Xfree(monitor->vendor); |
967 if (monitor->model) | 975 if (monitor->model) |
968 Xfree(monitor->model); | 976 Xfree(monitor->model); |
970 UnlockDisplay(dpy); | 978 UnlockDisplay(dpy); |
971 SyncHandle(); | 979 SyncHandle(); |
972 return False; | 980 return False; |
973 } | 981 } |
974 for (i = 0; i < rep.nhsync; i++) { | 982 for (i = 0; i < rep.nhsync; i++) { |
975 _XRead(dpy, (char *)&syncrange, 4); | 983 p_XRead(dpy, (char *)&syncrange, 4); |
976 monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; | 984 monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; |
977 monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0; | 985 monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0; |
978 } | 986 } |
979 for (i = 0; i < rep.nvsync; i++) { | 987 for (i = 0; i < rep.nvsync; i++) { |
980 _XRead(dpy, (char *)&syncrange, 4); | 988 p_XRead(dpy, (char *)&syncrange, 4); |
981 monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; | 989 monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; |
982 monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0; | 990 monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0; |
983 } | 991 } |
984 if (rep.vendorLength) | 992 if (rep.vendorLength) |
985 _XReadPad(dpy, monitor->vendor, rep.vendorLength); | 993 p_XReadPad(dpy, monitor->vendor, rep.vendorLength); |
986 else | 994 else |
987 monitor->vendor = ""; | 995 monitor->vendor = ""; |
988 if (rep.modelLength) | 996 if (rep.modelLength) |
989 _XReadPad(dpy, monitor->model, rep.modelLength); | 997 p_XReadPad(dpy, monitor->model, rep.modelLength); |
990 else | 998 else |
991 monitor->model = ""; | 999 monitor->model = ""; |
992 | 1000 |
993 UnlockDisplay(dpy); | 1001 UnlockDisplay(dpy); |
994 SyncHandle(); | 1002 SyncHandle(); |
1032 req->screen = screen; | 1040 req->screen = screen; |
1033 if (protocolBug) { | 1041 if (protocolBug) { |
1034 *x = 0; | 1042 *x = 0; |
1035 *y = 0; | 1043 *y = 0; |
1036 } else { | 1044 } else { |
1037 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 1045 if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) { |
1038 UnlockDisplay(dpy); | 1046 UnlockDisplay(dpy); |
1039 SyncHandle(); | 1047 SyncHandle(); |
1040 return False; | 1048 return False; |
1041 } | 1049 } |
1042 *x = rep.x; | 1050 *x = rep.x; |
1090 LockDisplay(dpy); | 1098 LockDisplay(dpy); |
1091 GetReq(XF86VidModeGetDotClocks, req); | 1099 GetReq(XF86VidModeGetDotClocks, req); |
1092 req->reqType = info->codes->major_opcode; | 1100 req->reqType = info->codes->major_opcode; |
1093 req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; | 1101 req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; |
1094 req->screen = screen; | 1102 req->screen = screen; |
1095 if (!_XReply(dpy, (xReply *)&rep, | 1103 if (!p_XReply(dpy, (xReply *)&rep, |
1096 (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse)) | 1104 (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse)) |
1097 { | 1105 { |
1098 UnlockDisplay(dpy); | 1106 UnlockDisplay(dpy); |
1099 SyncHandle(); | 1107 SyncHandle(); |
1100 return False; | 1108 return False; |
1102 *numclocksPtr = rep.clocks; | 1110 *numclocksPtr = rep.clocks; |
1103 *maxclocksPtr = rep.maxclocks; | 1111 *maxclocksPtr = rep.maxclocks; |
1104 *flagsPtr = rep.flags; | 1112 *flagsPtr = rep.flags; |
1105 | 1113 |
1106 if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) { | 1114 if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) { |
1107 _XEatData(dpy, (rep.clocks) * 4); | 1115 p_XEatData(dpy, (rep.clocks) * 4); |
1108 Xfree(dotclocks); | 1116 Xfree(dotclocks); |
1109 UnlockDisplay(dpy); | 1117 UnlockDisplay(dpy); |
1110 SyncHandle(); | 1118 SyncHandle(); |
1111 return False; | 1119 return False; |
1112 } | 1120 } |
1113 | 1121 |
1114 for (i = 0; i < rep.clocks; i++) { | 1122 for (i = 0; i < rep.clocks; i++) { |
1115 _XRead(dpy, (char*)&dotclk, 4); | 1123 p_XRead(dpy, (char*)&dotclk, 4); |
1116 dotclocks[i] = dotclk; | 1124 dotclocks[i] = dotclk; |
1117 } | 1125 } |
1118 *clocksPtr = dotclocks; | 1126 *clocksPtr = dotclocks; |
1119 UnlockDisplay(dpy); | 1127 UnlockDisplay(dpy); |
1120 SyncHandle(); | 1128 SyncHandle(); |
1141 req->reqType = info->codes->major_opcode; | 1149 req->reqType = info->codes->major_opcode; |
1142 req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp; | 1150 req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp; |
1143 req->screen = screen; | 1151 req->screen = screen; |
1144 req->length += (length >> 1) * 3; | 1152 req->length += (length >> 1) * 3; |
1145 req->size = size; | 1153 req->size = size; |
1146 _XSend(dpy, (char*)red, size * 2); | 1154 p_XSend(dpy, (char*)red, size * 2); |
1147 _XSend(dpy, (char*)green, size * 2); | 1155 p_XSend(dpy, (char*)green, size * 2); |
1148 _XSend(dpy, (char*)blue, size * 2); | 1156 p_XSend(dpy, (char*)blue, size * 2); |
1149 UnlockDisplay(dpy); | 1157 UnlockDisplay(dpy); |
1150 SyncHandle(); | 1158 SyncHandle(); |
1151 return True; | 1159 return True; |
1152 } | 1160 } |
1153 | 1161 |
1172 GetReq(XF86VidModeGetGammaRamp, req); | 1180 GetReq(XF86VidModeGetGammaRamp, req); |
1173 req->reqType = info->codes->major_opcode; | 1181 req->reqType = info->codes->major_opcode; |
1174 req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; | 1182 req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; |
1175 req->screen = screen; | 1183 req->screen = screen; |
1176 req->size = size; | 1184 req->size = size; |
1177 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { | 1185 if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) { |
1178 UnlockDisplay (dpy); | 1186 UnlockDisplay (dpy); |
1179 SyncHandle (); | 1187 SyncHandle (); |
1180 return False; | 1188 return False; |
1181 } | 1189 } |
1182 if(rep.size) { | 1190 if(rep.size) { |
1183 _XRead(dpy, (char*)red, rep.size << 1); | 1191 p_XRead(dpy, (char*)red, rep.size << 1); |
1184 _XRead(dpy, (char*)green, rep.size << 1); | 1192 p_XRead(dpy, (char*)green, rep.size << 1); |
1185 _XRead(dpy, (char*)blue, rep.size << 1); | 1193 p_XRead(dpy, (char*)blue, rep.size << 1); |
1186 } | 1194 } |
1187 | 1195 |
1188 UnlockDisplay(dpy); | 1196 UnlockDisplay(dpy); |
1189 SyncHandle(); | 1197 SyncHandle(); |
1190 return True; | 1198 return True; |
1207 LockDisplay(dpy); | 1215 LockDisplay(dpy); |
1208 GetReq(XF86VidModeGetGammaRampSize, req); | 1216 GetReq(XF86VidModeGetGammaRampSize, req); |
1209 req->reqType = info->codes->major_opcode; | 1217 req->reqType = info->codes->major_opcode; |
1210 req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; | 1218 req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; |
1211 req->screen = screen; | 1219 req->screen = screen; |
1212 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { | 1220 if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) { |
1213 UnlockDisplay (dpy); | 1221 UnlockDisplay (dpy); |
1214 SyncHandle (); | 1222 SyncHandle (); |
1215 return False; | 1223 return False; |
1216 } | 1224 } |
1217 *size = rep.size; | 1225 *size = rep.size; |