1 /* $XConsortium: XF86VMode.c /main/2 1995/11/14 18:17:58 kaleb $ */ 2 /* $XFree86: xc/lib/Xxf86vm/XF86VMode.c,v 3.32 2001/07/25 15:04:54 dawes Exp $ */ 3 /* 4 5 Copyright (c) 1995 Kaleb S. KEITHLEY 6 7 Permission is hereby granted, free of charge, to any person obtaining 8 a copy of this software and associated documentation files (the 9 "Software"), to deal in the Software without restriction, including 10 without limitation the rights to use, copy, modify, merge, publish, 11 distribute, sublicense, and/or sell copies of the Software, and to 12 permit persons to whom the Software is furnished to do so, subject to 13 the following conditions: 14 15 The above copyright notice and this permission notice shall be 16 included in all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES 22 OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 OTHER DEALINGS IN THE SOFTWARE. 25 26 Except as contained in this notice, the name of Kaleb S. KEITHLEY 27 shall not be used in advertising or otherwise to promote the sale, use 28 or other dealings in this Software without prior written authorization 29 from Kaleb S. KEITHLEY. 30 31 */ 32 /* $XConsortium: XF86VMode.c /main/4 1996/01/16 07:52:25 kaleb CHECKEDOUT $ */ 33 34 /* THIS IS NOT AN X CONSORTIUM STANDARD */ 35 36 #define NEED_EVENTS 37 #define NEED_REPLIES 38 39 #ifndef XBUILD_IN_CLIENT 40 /* Apparently some X11 systems can't include this multiple times... */ 41 #ifndef SDL_INCLUDED_XLIBINT_H 42 #define SDL_INCLUDED_XLIBINT_H 1 43 #include <X11/Xlibint.h> 44 #endif 45 #include "../extensions/xf86vmstr.h" 46 #include "../extensions/Xext.h" 47 #include "../extensions/extutil.h" 48 #else 49 #include "include/extensions/xf86vmstr.h" 50 #include "include/extensions/Xext.h" 51 #include "include/extensions/extutil.h" 52 #endif 53 54 #ifdef DEBUG 55 #include <stdio.h> 56 #endif 57 58 #ifndef MODE_BAD 59 #define MODE_BAD 255 60 #endif 61 62 static XExtensionInfo _xf86vidmode_info_data; 63 static XExtensionInfo *xf86vidmode_info = &_xf86vidmode_info_data; 64 static char *xf86vidmode_extension_name = XF86VIDMODENAME; 65 66 #define XF86VidModeCheckExtension(dpy,i,val) \ 67 XextCheckExtension (dpy, i, xf86vidmode_extension_name, val) 68 69 /***************************************************************************** 70 * * 71 * private utility routines * 72 * * 73 *****************************************************************************/ 74 75 static XEXT_CLOSE_DISPLAY_PROTO(close_display); 76 static /* const */ XExtensionHooks xf86vidmode_extension_hooks = { 77 NULL, /* create_gc */ 78 NULL, /* copy_gc */ 79 NULL, /* flush_gc */ 80 NULL, /* free_gc */ 81 NULL, /* create_font */ 82 NULL, /* free_font */ 83 close_display, /* close_display */ 84 NULL, /* wire_to_event */ 85 NULL, /* event_to_wire */ 86 NULL, /* error */ 87 NULL, /* error_string */ 88 }; 89 90 static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86vidmode_info, 91 xf86vidmode_extension_name, 92 &xf86vidmode_extension_hooks, 93 0, NULL) 94 95 static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86vidmode_info) 96 97 98 /***************************************************************************** 99 * * 100 * public XFree86-VidMode Extension routines * 101 * * 102 *****************************************************************************/ 103 104 Bool 105 SDL_NAME(XF86VidModeQueryExtension) (dpy, event_basep, error_basep) 106 Display *dpy; 107 int *event_basep, *error_basep; 108 { 109 XExtDisplayInfo *info = find_display (dpy); 110 111 if (XextHasExtension(info)) { 112 *event_basep = info->codes->first_event; 113 *error_basep = info->codes->first_error; 114 return True; 115 } else { 116 return False; 117 } 118 } 119 120 Bool 121 SDL_NAME(XF86VidModeQueryVersion)(dpy, majorVersion, minorVersion) 122 Display* dpy; 123 int* majorVersion; 124 int* minorVersion; 125 { 126 XExtDisplayInfo *info = find_display (dpy); 127 xXF86VidModeQueryVersionReply rep; 128 xXF86VidModeQueryVersionReq *req; 129 130 XF86VidModeCheckExtension (dpy, info, False); 131 132 LockDisplay(dpy); 133 GetReq(XF86VidModeQueryVersion, req); 134 req->reqType = info->codes->major_opcode; 135 req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; 136 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 137 UnlockDisplay(dpy); 138 SyncHandle(); 139 return False; 140 } 141 *majorVersion = rep.majorVersion; 142 *minorVersion = rep.minorVersion; 143 UnlockDisplay(dpy); 144 SyncHandle(); 145 if (*majorVersion >= 2) 146 SDL_NAME(XF86VidModeSetClientVersion)(dpy); 147 return True; 148 } 149 150 Bool 151 SDL_NAME(XF86VidModeSetClientVersion)(Display *dpy) 152 { 153 XExtDisplayInfo *info = find_display(dpy); 154 xXF86VidModeSetClientVersionReq *req; 155 156 XF86VidModeCheckExtension(dpy, info, False); 157 158 LockDisplay(dpy); 159 GetReq(XF86VidModeSetClientVersion, req); 160 req->reqType = info->codes->major_opcode; 161 req->xf86vidmodeReqType = X_XF86VidModeSetClientVersion; 162 req->major = XF86VIDMODE_MAJOR_VERSION; 163 req->minor = XF86VIDMODE_MINOR_VERSION; 164 UnlockDisplay(dpy); 165 SyncHandle(); 166 return True; 167 } 168 169 Bool 170 SDL_NAME(XF86VidModeSetGamma)(Display *dpy, int screen, SDL_NAME(XF86VidModeGamma) *Gamma) 171 { 172 XExtDisplayInfo *info = find_display(dpy); 173 xXF86VidModeSetGammaReq *req; 174 175 XF86VidModeCheckExtension(dpy, info, False); 176 177 LockDisplay(dpy); 178 GetReq(XF86VidModeSetGamma, req); 179 req->reqType = info->codes->major_opcode; 180 req->xf86vidmodeReqType = X_XF86VidModeSetGamma; 181 req->screen = screen; 182 req->red = (CARD32)(Gamma->red * 10000.); 183 req->green = (CARD32)(Gamma->green * 10000.); 184 req->blue = (CARD32)(Gamma->blue * 10000.); 185 UnlockDisplay(dpy); 186 SyncHandle(); 187 return True; 188 } 189 190 Bool 191 SDL_NAME(XF86VidModeGetGamma)(Display *dpy, int screen, SDL_NAME(XF86VidModeGamma) *Gamma) 192 { 193 XExtDisplayInfo *info = find_display (dpy); 194 xXF86VidModeGetGammaReply rep; 195 xXF86VidModeGetGammaReq *req; 196 197 XF86VidModeCheckExtension (dpy, info, False); 198 199 LockDisplay(dpy); 200 GetReq(XF86VidModeGetGamma, req); 201 req->reqType = info->codes->major_opcode; 202 req->xf86vidmodeReqType = X_XF86VidModeGetGamma; 203 req->screen = screen; 204 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 205 UnlockDisplay(dpy); 206 SyncHandle(); 207 return False; 208 } 209 Gamma->red = ((float)rep.red) / 10000.; 210 Gamma->green = ((float)rep.green) / 10000.; 211 Gamma->blue = ((float)rep.blue) / 10000.; 212 UnlockDisplay(dpy); 213 SyncHandle(); 214 return True; 215 } 216 217 Bool 218 SDL_NAME(XF86VidModeGetModeLine)(dpy, screen, dotclock, modeline) 219 Display* dpy; 220 int screen; 221 int* dotclock; 222 SDL_NAME(XF86VidModeModeLine)* modeline; 223 { 224 XExtDisplayInfo *info = find_display (dpy); 225 xXF86VidModeGetModeLineReply rep; 226 xXF86OldVidModeGetModeLineReply oldrep; 227 xXF86VidModeGetModeLineReq *req; 228 int majorVersion, minorVersion; 229 230 XF86VidModeCheckExtension (dpy, info, False); 231 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 232 233 LockDisplay(dpy); 234 GetReq(XF86VidModeGetModeLine, req); 235 req->reqType = info->codes->major_opcode; 236 req->xf86vidmodeReqType = X_XF86VidModeGetModeLine; 237 req->screen = screen; 238 239 if (majorVersion < 2) { 240 if (!_XReply(dpy, (xReply *)&oldrep, 241 (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { 242 UnlockDisplay(dpy); 243 SyncHandle(); 244 return False; 245 } 246 *dotclock = oldrep.dotclock; 247 modeline->hdisplay = oldrep.hdisplay; 248 modeline->hsyncstart = oldrep.hsyncstart; 249 modeline->hsyncend = oldrep.hsyncend; 250 modeline->htotal = oldrep.htotal; 251 modeline->hskew = 0; 252 modeline->vdisplay = oldrep.vdisplay; 253 modeline->vsyncstart = oldrep.vsyncstart; 254 modeline->vsyncend = oldrep.vsyncend; 255 modeline->vtotal = oldrep.vtotal; 256 modeline->flags = oldrep.flags; 257 modeline->privsize = oldrep.privsize; 258 } else { 259 if (!_XReply(dpy, (xReply *)&rep, 260 (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) { 261 UnlockDisplay(dpy); 262 SyncHandle(); 263 return False; 264 } 265 *dotclock = rep.dotclock; 266 modeline->hdisplay = rep.hdisplay; 267 modeline->hsyncstart = rep.hsyncstart; 268 modeline->hsyncend = rep.hsyncend; 269 modeline->htotal = rep.htotal; 270 modeline->hskew = rep.hskew; 271 modeline->vdisplay = rep.vdisplay; 272 modeline->vsyncstart = rep.vsyncstart; 273 modeline->vsyncend = rep.vsyncend; 274 modeline->vtotal = rep.vtotal; 275 modeline->flags = rep.flags; 276 modeline->privsize = rep.privsize; 277 } 278 279 if (modeline->privsize > 0) { 280 if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { 281 _XEatData(dpy, (modeline->privsize) * sizeof(INT32)); 282 Xfree(modeline->private); 283 return False; 284 } 285 _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); 286 } else { 287 modeline->private = NULL; 288 } 289 UnlockDisplay(dpy); 290 SyncHandle(); 291 return True; 292 } 293 294 Bool 295 SDL_NAME(XF86VidModeGetAllModeLines)(dpy, screen, modecount, modelinesPtr) 296 Display* dpy; 297 int screen; 298 int* modecount; 299 SDL_NAME(XF86VidModeModeInfo) ***modelinesPtr; 300 { 301 XExtDisplayInfo *info = find_display (dpy); 302 xXF86VidModeGetAllModeLinesReply rep; 303 xXF86VidModeGetAllModeLinesReq *req; 304 SDL_NAME(XF86VidModeModeInfo) *mdinfptr, **modelines; 305 xXF86VidModeModeInfo xmdline; 306 xXF86OldVidModeModeInfo oldxmdline; 307 int i; 308 int majorVersion, minorVersion; 309 Bool protocolBug = False; 310 311 XF86VidModeCheckExtension (dpy, info, False); 312 313 /* 314 * Note: There was a bug in the protocol implementation in versions 315 * 0.x with x < 8 (the .private field wasn't being passed over the wire). 316 * Check the server's version, and accept the old format if appropriate. 317 */ 318 319 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 320 if (majorVersion == 0 && minorVersion < 8) { 321 protocolBug = True; 322 #ifdef DEBUG 323 fprintf(stderr, "XF86VidModeGetAllModeLines: Warning: Xserver is" 324 "running an old version (%d.%d)\n", majorVersion, 325 minorVersion); 326 #endif 327 } 328 329 LockDisplay(dpy); 330 GetReq(XF86VidModeGetAllModeLines, req); 331 req->reqType = info->codes->major_opcode; 332 req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; 333 req->screen = screen; 334 if (!_XReply(dpy, (xReply *)&rep, 335 (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) { 336 UnlockDisplay(dpy); 337 SyncHandle(); 338 return False; 339 } 340 341 *modecount = rep.modecount; 342 343 if (!(modelines = (SDL_NAME(XF86VidModeModeInfo) **) Xcalloc(rep.modecount, 344 sizeof(SDL_NAME(XF86VidModeModeInfo) *) 345 +sizeof(SDL_NAME(XF86VidModeModeInfo))))) { 346 if (majorVersion < 2) 347 _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); 348 else 349 _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); 350 Xfree(modelines); 351 UnlockDisplay(dpy); 352 SyncHandle(); 353 return False; 354 } 355 mdinfptr = (SDL_NAME(XF86VidModeModeInfo) *) ( 356 (char *) modelines 357 + rep.modecount*sizeof(SDL_NAME(XF86VidModeModeInfo) *) 358 ); 359 360 for (i = 0; i < rep.modecount; i++) { 361 modelines[i] = mdinfptr++; 362 if (majorVersion < 2) { 363 _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo)); 364 modelines[i]->dotclock = oldxmdline.dotclock; 365 modelines[i]->hdisplay = oldxmdline.hdisplay; 366 modelines[i]->hsyncstart = oldxmdline.hsyncstart; 367 modelines[i]->hsyncend = oldxmdline.hsyncend; 368 modelines[i]->htotal = oldxmdline.htotal; 369 modelines[i]->hskew = 0; 370 modelines[i]->vdisplay = oldxmdline.vdisplay; 371 modelines[i]->vsyncstart = oldxmdline.vsyncstart; 372 modelines[i]->vsyncend = oldxmdline.vsyncend; 373 modelines[i]->vtotal = oldxmdline.vtotal; 374 modelines[i]->flags = oldxmdline.flags; 375 if (protocolBug) { 376 modelines[i]->privsize = 0; 377 modelines[i]->private = NULL; 378 } else { 379 modelines[i]->privsize = oldxmdline.privsize; 380 if (oldxmdline.privsize > 0) { 381 if (!(modelines[i]->private = 382 Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { 383 _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); 384 Xfree(modelines[i]->private); 385 } else { 386 _XRead(dpy, (char*)modelines[i]->private, 387 oldxmdline.privsize * sizeof(INT32)); 388 } 389 } else { 390 modelines[i]->private = NULL; 391 } 392 } 393 } else { 394 _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo)); 395 modelines[i]->dotclock = xmdline.dotclock; 396 modelines[i]->hdisplay = xmdline.hdisplay; 397 modelines[i]->hsyncstart = xmdline.hsyncstart; 398 modelines[i]->hsyncend = xmdline.hsyncend; 399 modelines[i]->htotal = xmdline.htotal; 400 modelines[i]->hskew = xmdline.hskew; 401 modelines[i]->vdisplay = xmdline.vdisplay; 402 modelines[i]->vsyncstart = xmdline.vsyncstart; 403 modelines[i]->vsyncend = xmdline.vsyncend; 404 modelines[i]->vtotal = xmdline.vtotal; 405 modelines[i]->flags = xmdline.flags; 406 if (protocolBug) { 407 modelines[i]->privsize = 0; 408 modelines[i]->private = NULL; 409 } else { 410 modelines[i]->privsize = xmdline.privsize; 411 if (xmdline.privsize > 0) { 412 if (!(modelines[i]->private = 413 Xcalloc(xmdline.privsize, sizeof(INT32)))) { 414 _XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); 415 Xfree(modelines[i]->private); 416 } else { 417 _XRead(dpy, (char*)modelines[i]->private, 418 xmdline.privsize * sizeof(INT32)); 419 } 420 } else { 421 modelines[i]->private = NULL; 422 } 423 } 424 } 425 } 426 *modelinesPtr = modelines; 427 UnlockDisplay(dpy); 428 SyncHandle(); 429 return True; 430 } 431 432 /* 433 * GetReq replacement for use with VidMode protocols earlier than 2.0 434 */ 435 #if !defined(UNIXCPP) || defined(ANSICPP) 436 #define GetOldReq(name, oldname, req) \ 437 WORD64ALIGN\ 438 if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\ 439 _XFlush(dpy);\ 440 req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\ 441 req->reqType = X_##name;\ 442 req->length = (SIZEOF(x##oldname##Req))>>2;\ 443 dpy->bufptr += SIZEOF(x##oldname##Req);\ 444 dpy->request++ 445 446 #else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ 447 #define GetOldReq(name, oldname, req) \ 448 WORD64ALIGN\ 449 if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\ 450 _XFlush(dpy);\ 451 req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\ 452 req->reqType = X_/**/name;\ 453 req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\ 454 dpy->bufptr += SIZEOF(x/**/oldname/**/Req);\ 455 dpy->request++ 456 #endif 457 458 Bool 459 SDL_NAME(XF86VidModeAddModeLine) (dpy, screen, newmodeline, aftermodeline) 460 Display *dpy; 461 int screen; 462 SDL_NAME(XF86VidModeModeInfo)* newmodeline; 463 SDL_NAME(XF86VidModeModeInfo)* aftermodeline; 464 { 465 XExtDisplayInfo *info = find_display (dpy); 466 xXF86VidModeAddModeLineReq *req; 467 xXF86OldVidModeAddModeLineReq *oldreq; 468 int majorVersion, minorVersion; 469 470 XF86VidModeCheckExtension (dpy, info, False); 471 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 472 473 LockDisplay(dpy); 474 if (majorVersion < 2) { 475 GetOldReq(XF86VidModeAddModeLine, XF86OldVidModeAddModeLine, oldreq); 476 oldreq->reqType = info->codes->major_opcode; 477 oldreq->xf86vidmodeReqType = X_XF86VidModeAddModeLine; 478 oldreq->screen = screen; 479 oldreq->dotclock = newmodeline->dotclock; 480 oldreq->hdisplay = newmodeline->hdisplay; 481 oldreq->hsyncstart = newmodeline->hsyncstart; 482 oldreq->hsyncend = newmodeline->hsyncend; 483 oldreq->htotal = newmodeline->htotal; 484 oldreq->vdisplay = newmodeline->vdisplay; 485 oldreq->vsyncstart = newmodeline->vsyncstart; 486 oldreq->vsyncend = newmodeline->vsyncend; 487 oldreq->vtotal = newmodeline->vtotal; 488 oldreq->flags = newmodeline->flags; 489 oldreq->privsize = newmodeline->privsize; 490 if (aftermodeline != NULL) { 491 oldreq->after_dotclock = aftermodeline->dotclock; 492 oldreq->after_hdisplay = aftermodeline->hdisplay; 493 oldreq->after_hsyncstart = aftermodeline->hsyncstart; 494 oldreq->after_hsyncend = aftermodeline->hsyncend; 495 oldreq->after_htotal = aftermodeline->htotal; 496 oldreq->after_vdisplay = aftermodeline->vdisplay; 497 oldreq->after_vsyncstart = aftermodeline->vsyncstart; 498 oldreq->after_vsyncend = aftermodeline->vsyncend; 499 oldreq->after_vtotal = aftermodeline->vtotal; 500 oldreq->after_flags = aftermodeline->flags; 501 } else { 502 oldreq->after_dotclock = 0; 503 oldreq->after_hdisplay = 0; 504 oldreq->after_hsyncstart = 0; 505 oldreq->after_hsyncend = 0; 506 oldreq->after_htotal = 0; 507 oldreq->after_vdisplay = 0; 508 oldreq->after_vsyncstart = 0; 509 oldreq->after_vsyncend = 0; 510 oldreq->after_vtotal = 0; 511 oldreq->after_flags = 0; 512 } 513 if (newmodeline->privsize) { 514 oldreq->length += newmodeline->privsize; 515 Data32(dpy, (long *) newmodeline->private, 516 newmodeline->privsize * sizeof(INT32)); 517 } 518 } else { 519 GetReq(XF86VidModeAddModeLine, req); 520 req->reqType = info->codes->major_opcode; 521 req->xf86vidmodeReqType = X_XF86VidModeAddModeLine; 522 req->screen = screen; 523 req->dotclock = newmodeline->dotclock; 524 req->hdisplay = newmodeline->hdisplay; 525 req->hsyncstart = newmodeline->hsyncstart; 526 req->hsyncend = newmodeline->hsyncend; 527 req->htotal = newmodeline->htotal; 528 req->hskew = newmodeline->hskew; 529 req->vdisplay = newmodeline->vdisplay; 530 req->vsyncstart = newmodeline->vsyncstart; 531 req->vsyncend = newmodeline->vsyncend; 532 req->vtotal = newmodeline->vtotal; 533 req->flags = newmodeline->flags; 534 req->privsize = newmodeline->privsize; 535 if (aftermodeline != NULL) { 536 req->after_dotclock = aftermodeline->dotclock; 537 req->after_hdisplay = aftermodeline->hdisplay; 538 req->after_hsyncstart = aftermodeline->hsyncstart; 539 req->after_hsyncend = aftermodeline->hsyncend; 540 req->after_htotal = aftermodeline->htotal; 541 req->after_hskew = aftermodeline->hskew; 542 req->after_vdisplay = aftermodeline->vdisplay; 543 req->after_vsyncstart = aftermodeline->vsyncstart; 544 req->after_vsyncend = aftermodeline->vsyncend; 545 req->after_vtotal = aftermodeline->vtotal; 546 req->after_flags = aftermodeline->flags; 547 } else { 548 req->after_dotclock = 0; 549 req->after_hdisplay = 0; 550 req->after_hsyncstart = 0; 551 req->after_hsyncend = 0; 552 req->after_htotal = 0; 553 req->after_hskew = 0; 554 req->after_vdisplay = 0; 555 req->after_vsyncstart = 0; 556 req->after_vsyncend = 0; 557 req->after_vtotal = 0; 558 req->after_flags = 0; 559 } 560 if (newmodeline->privsize) { 561 req->length += newmodeline->privsize; 562 Data32(dpy, (long *) newmodeline->private, 563 newmodeline->privsize * sizeof(INT32)); 564 } 565 } 566 UnlockDisplay(dpy); 567 SyncHandle(); 568 return True; 569 } 570 571 Bool 572 SDL_NAME(XF86VidModeDeleteModeLine) (dpy, screen, modeline) 573 Display *dpy; 574 int screen; 575 SDL_NAME(XF86VidModeModeInfo)* modeline; 576 { 577 XExtDisplayInfo *info = find_display (dpy); 578 xXF86VidModeDeleteModeLineReq *req; 579 xXF86OldVidModeDeleteModeLineReq *oldreq; 580 int majorVersion, minorVersion; 581 582 XF86VidModeCheckExtension (dpy, info, 0); 583 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 584 585 LockDisplay(dpy); 586 if (majorVersion < 2) { 587 GetOldReq(XF86VidModeDeleteModeLine, XF86OldVidModeDeleteModeLine, oldreq); 588 oldreq->reqType = info->codes->major_opcode; 589 oldreq->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; 590 oldreq->screen = screen; 591 oldreq->dotclock = modeline->dotclock; 592 oldreq->hdisplay = modeline->hdisplay; 593 oldreq->hsyncstart = modeline->hsyncstart; 594 oldreq->hsyncend = modeline->hsyncend; 595 oldreq->htotal = modeline->htotal; 596 oldreq->vdisplay = modeline->vdisplay; 597 oldreq->vsyncstart = modeline->vsyncstart; 598 oldreq->vsyncend = modeline->vsyncend; 599 oldreq->vtotal = modeline->vtotal; 600 oldreq->flags = modeline->flags; 601 oldreq->privsize = modeline->privsize; 602 if (modeline->privsize) { 603 oldreq->length += modeline->privsize; 604 Data32(dpy, (long *) modeline->private, 605 modeline->privsize * sizeof(INT32)); 606 } 607 } else { 608 GetReq(XF86VidModeDeleteModeLine, req); 609 req->reqType = info->codes->major_opcode; 610 req->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; 611 req->screen = screen; 612 req->dotclock = modeline->dotclock; 613 req->hdisplay = modeline->hdisplay; 614 req->hsyncstart = modeline->hsyncstart; 615 req->hsyncend = modeline->hsyncend; 616 req->htotal = modeline->htotal; 617 req->hskew = modeline->hskew; 618 req->vdisplay = modeline->vdisplay; 619 req->vsyncstart = modeline->vsyncstart; 620 req->vsyncend = modeline->vsyncend; 621 req->vtotal = modeline->vtotal; 622 req->flags = modeline->flags; 623 req->privsize = modeline->privsize; 624 if (modeline->privsize) { 625 req->length += modeline->privsize; 626 Data32(dpy, (long *) modeline->private, 627 modeline->privsize * sizeof(INT32)); 628 } 629 } 630 UnlockDisplay(dpy); 631 SyncHandle(); 632 return True; 633 } 634 635 Bool 636 SDL_NAME(XF86VidModeModModeLine) (dpy, screen, modeline) 637 Display *dpy; 638 int screen; 639 SDL_NAME(XF86VidModeModeLine)* modeline; 640 { 641 XExtDisplayInfo *info = find_display (dpy); 642 xXF86VidModeModModeLineReq *req; 643 xXF86OldVidModeModModeLineReq *oldreq; 644 int majorVersion, minorVersion; 645 646 XF86VidModeCheckExtension (dpy, info, 0); 647 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 648 649 LockDisplay(dpy); 650 if (majorVersion < 2) { 651 GetOldReq(XF86VidModeModModeLine, XF86OldVidModeModModeLine, oldreq); 652 oldreq->reqType = info->codes->major_opcode; 653 oldreq->xf86vidmodeReqType = X_XF86VidModeModModeLine; 654 oldreq->screen = screen; 655 oldreq->hdisplay = modeline->hdisplay; 656 oldreq->hsyncstart = modeline->hsyncstart; 657 oldreq->hsyncend = modeline->hsyncend; 658 oldreq->htotal = modeline->htotal; 659 oldreq->vdisplay = modeline->vdisplay; 660 oldreq->vsyncstart = modeline->vsyncstart; 661 oldreq->vsyncend = modeline->vsyncend; 662 oldreq->vtotal = modeline->vtotal; 663 oldreq->flags = modeline->flags; 664 oldreq->privsize = modeline->privsize; 665 if (modeline->privsize) { 666 oldreq->length += modeline->privsize; 667 Data32(dpy, (long *) modeline->private, 668 modeline->privsize * sizeof(INT32)); 669 } 670 } else { 671 GetReq(XF86VidModeModModeLine, req); 672 req->reqType = info->codes->major_opcode; 673 req->xf86vidmodeReqType = X_XF86VidModeModModeLine; 674 req->screen = screen; 675 req->hdisplay = modeline->hdisplay; 676 req->hsyncstart = modeline->hsyncstart; 677 req->hsyncend = modeline->hsyncend; 678 req->htotal = modeline->htotal; 679 req->hskew = modeline->hskew; 680 req->vdisplay = modeline->vdisplay; 681 req->vsyncstart = modeline->vsyncstart; 682 req->vsyncend = modeline->vsyncend; 683 req->vtotal = modeline->vtotal; 684 req->flags = modeline->flags; 685 req->privsize = modeline->privsize; 686 if (modeline->privsize) { 687 req->length += modeline->privsize; 688 Data32(dpy, (long *) modeline->private, 689 modeline->privsize * sizeof(INT32)); 690 } 691 } 692 UnlockDisplay(dpy); 693 SyncHandle(); 694 return True; 695 } 696 697 Status 698 SDL_NAME(XF86VidModeValidateModeLine) (dpy, screen, modeline) 699 Display *dpy; 700 int screen; 701 SDL_NAME(XF86VidModeModeInfo)* modeline; 702 { 703 XExtDisplayInfo *info = find_display (dpy); 704 xXF86VidModeValidateModeLineReq *req; 705 xXF86OldVidModeValidateModeLineReq *oldreq; 706 xXF86VidModeValidateModeLineReply rep; 707 int majorVersion, minorVersion; 708 709 XF86VidModeCheckExtension (dpy, info, 0); 710 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 711 712 LockDisplay(dpy); 713 714 if (majorVersion < 2) { 715 GetOldReq(XF86VidModeValidateModeLine, XF86OldVidModeValidateModeLine, oldreq); 716 oldreq->reqType = info->codes->major_opcode; 717 oldreq->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; 718 oldreq->screen = screen; 719 oldreq->dotclock = modeline->dotclock; 720 oldreq->hdisplay = modeline->hdisplay; 721 oldreq->hsyncstart = modeline->hsyncstart; 722 oldreq->hsyncend = modeline->hsyncend; 723 oldreq->htotal = modeline->htotal; 724 oldreq->vdisplay = modeline->vdisplay; 725 oldreq->vsyncstart = modeline->vsyncstart; 726 oldreq->vsyncend = modeline->vsyncend; 727 oldreq->vtotal = modeline->vtotal; 728 oldreq->flags = modeline->flags; 729 oldreq->privsize = modeline->privsize; 730 if (modeline->privsize) { 731 oldreq->length += modeline->privsize; 732 Data32(dpy, (long *) modeline->private, 733 modeline->privsize * sizeof(INT32)); 734 } 735 } else { 736 GetReq(XF86VidModeValidateModeLine, req); 737 req->reqType = info->codes->major_opcode; 738 req->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; 739 req->screen = screen; 740 req->dotclock = modeline->dotclock; 741 req->hdisplay = modeline->hdisplay; 742 req->hsyncstart = modeline->hsyncstart; 743 req->hsyncend = modeline->hsyncend; 744 req->htotal = modeline->htotal; 745 req->hskew = modeline->hskew; 746 req->vdisplay = modeline->vdisplay; 747 req->vsyncstart = modeline->vsyncstart; 748 req->vsyncend = modeline->vsyncend; 749 req->vtotal = modeline->vtotal; 750 req->flags = modeline->flags; 751 req->privsize = modeline->privsize; 752 if (modeline->privsize) { 753 req->length += modeline->privsize; 754 Data32(dpy, (long *) modeline->private, 755 modeline->privsize * sizeof(INT32)); 756 } 757 } 758 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 759 UnlockDisplay(dpy); 760 SyncHandle(); 761 return MODE_BAD; 762 } 763 UnlockDisplay(dpy); 764 SyncHandle(); 765 return rep.status; 766 } 767 768 Bool 769 SDL_NAME(XF86VidModeSwitchMode)(dpy, screen, zoom) 770 Display* dpy; 771 int screen; 772 int zoom; 773 { 774 XExtDisplayInfo *info = find_display (dpy); 775 xXF86VidModeSwitchModeReq *req; 776 777 XF86VidModeCheckExtension (dpy, info, False); 778 779 LockDisplay(dpy); 780 GetReq(XF86VidModeSwitchMode, req); 781 req->reqType = info->codes->major_opcode; 782 req->xf86vidmodeReqType = X_XF86VidModeSwitchMode; 783 req->screen = screen; 784 req->zoom = zoom; 785 UnlockDisplay(dpy); 786 SyncHandle(); 787 return True; 788 } 789 790 Bool 791 SDL_NAME(XF86VidModeSwitchToMode)(dpy, screen, modeline) 792 Display* dpy; 793 int screen; 794 SDL_NAME(XF86VidModeModeInfo)* modeline; 795 { 796 XExtDisplayInfo *info = find_display (dpy); 797 xXF86VidModeSwitchToModeReq *req; 798 xXF86OldVidModeSwitchToModeReq *oldreq; 799 int majorVersion, minorVersion; 800 Bool protocolBug = False; 801 802 XF86VidModeCheckExtension (dpy, info, False); 803 804 /* 805 * Note: There was a bug in the protocol implementation in versions 806 * 0.x with x < 8 (the .private field wasn't expected to be sent over 807 * the wire). Check the server's version, and accept the old format 808 * if appropriate. 809 */ 810 811 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 812 if (majorVersion == 0 && minorVersion < 8) { 813 protocolBug = True; 814 #ifdef DEBUG 815 fprintf(stderr, "XF86VidModeSwitchToMode: Warning: Xserver is" 816 "running an old version (%d.%d)\n", majorVersion, 817 minorVersion); 818 #endif 819 } 820 821 LockDisplay(dpy); 822 if (majorVersion < 2) { 823 GetOldReq(XF86VidModeSwitchToMode, XF86OldVidModeSwitchToMode, oldreq); 824 oldreq->reqType = info->codes->major_opcode; 825 oldreq->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; 826 oldreq->screen = screen; 827 oldreq->dotclock = modeline->dotclock; 828 oldreq->hdisplay = modeline->hdisplay; 829 oldreq->hsyncstart = modeline->hsyncstart; 830 oldreq->hsyncend = modeline->hsyncend; 831 oldreq->htotal = modeline->htotal; 832 oldreq->vdisplay = modeline->vdisplay; 833 oldreq->vsyncstart = modeline->vsyncstart; 834 oldreq->vsyncend = modeline->vsyncend; 835 oldreq->vtotal = modeline->vtotal; 836 oldreq->flags = modeline->flags; 837 if (protocolBug) { 838 oldreq->privsize = 0; 839 } else { 840 oldreq->privsize = modeline->privsize; 841 if (modeline->privsize) { 842 oldreq->length += modeline->privsize; 843 Data32(dpy, (long *) modeline->private, 844 modeline->privsize * sizeof(INT32)); 845 } 846 } 847 } else { 848 GetReq(XF86VidModeSwitchToMode, req); 849 req->reqType = info->codes->major_opcode; 850 req->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; 851 req->screen = screen; 852 req->dotclock = modeline->dotclock; 853 req->hdisplay = modeline->hdisplay; 854 req->hsyncstart = modeline->hsyncstart; 855 req->hsyncend = modeline->hsyncend; 856 req->htotal = modeline->htotal; 857 req->hskew = modeline->hskew; 858 req->vdisplay = modeline->vdisplay; 859 req->vsyncstart = modeline->vsyncstart; 860 req->vsyncend = modeline->vsyncend; 861 req->vtotal = modeline->vtotal; 862 req->flags = modeline->flags; 863 if (protocolBug) { 864 req->privsize = 0; 865 } else { 866 req->privsize = modeline->privsize; 867 if (modeline->privsize) { 868 req->length += modeline->privsize; 869 Data32(dpy, (long *) modeline->private, 870 modeline->privsize * sizeof(INT32)); 871 } 872 } 873 } 874 UnlockDisplay(dpy); 875 SyncHandle(); 876 return True; 877 } 878 879 Bool 880 SDL_NAME(XF86VidModeLockModeSwitch)(dpy, screen, lock) 881 Display* dpy; 882 int screen; 883 int lock; 884 { 885 XExtDisplayInfo *info = find_display (dpy); 886 xXF86VidModeLockModeSwitchReq *req; 887 888 XF86VidModeCheckExtension (dpy, info, False); 889 890 LockDisplay(dpy); 891 GetReq(XF86VidModeLockModeSwitch, req); 892 req->reqType = info->codes->major_opcode; 893 req->xf86vidmodeReqType = X_XF86VidModeLockModeSwitch; 894 req->screen = screen; 895 req->lock = lock; 896 UnlockDisplay(dpy); 897 SyncHandle(); 898 return True; 899 } 900 901 Bool 902 SDL_NAME(XF86VidModeGetMonitor)(dpy, screen, monitor) 903 Display* dpy; 904 int screen; 905 SDL_NAME(XF86VidModeMonitor)* monitor; 906 { 907 XExtDisplayInfo *info = find_display (dpy); 908 xXF86VidModeGetMonitorReply rep; 909 xXF86VidModeGetMonitorReq *req; 910 CARD32 syncrange; 911 int i; 912 913 XF86VidModeCheckExtension (dpy, info, False); 914 915 LockDisplay(dpy); 916 GetReq(XF86VidModeGetMonitor, req); 917 req->reqType = info->codes->major_opcode; 918 req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; 919 req->screen = screen; 920 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 921 UnlockDisplay(dpy); 922 SyncHandle(); 923 return False; 924 } 925 monitor->nhsync = rep.nhsync; 926 monitor->nvsync = rep.nvsync; 927 #if 0 928 monitor->bandwidth = (float)rep.bandwidth / 1e6; 929 #endif 930 if (rep.vendorLength) { 931 if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) { 932 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + 933 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); 934 UnlockDisplay(dpy); 935 SyncHandle(); 936 return False; 937 } 938 } else { 939 monitor->vendor = NULL; 940 } 941 if (rep.modelLength) { 942 if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { 943 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + 944 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); 945 if (monitor->vendor) 946 Xfree(monitor->vendor); 947 UnlockDisplay(dpy); 948 SyncHandle(); 949 return False; 950 } 951 } else { 952 monitor->model = NULL; 953 } 954 if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { 955 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + 956 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); 957 958 if (monitor->vendor) 959 Xfree(monitor->vendor); 960 if (monitor->model) 961 Xfree(monitor->model); 962 UnlockDisplay(dpy); 963 SyncHandle(); 964 return False; 965 } 966 if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { 967 _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + 968 ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3)); 969 if (monitor->vendor) 970 Xfree(monitor->vendor); 971 if (monitor->model) 972 Xfree(monitor->model); 973 Xfree(monitor->hsync); 974 UnlockDisplay(dpy); 975 SyncHandle(); 976 return False; 977 } 978 for (i = 0; i < rep.nhsync; i++) { 979 _XRead(dpy, (char *)&syncrange, 4); 980 monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; 981 monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0; 982 } 983 for (i = 0; i < rep.nvsync; i++) { 984 _XRead(dpy, (char *)&syncrange, 4); 985 monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0; 986 monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0; 987 } 988 if (rep.vendorLength) 989 _XReadPad(dpy, monitor->vendor, rep.vendorLength); 990 else 991 monitor->vendor = ""; 992 if (rep.modelLength) 993 _XReadPad(dpy, monitor->model, rep.modelLength); 994 else 995 monitor->model = ""; 996 997 UnlockDisplay(dpy); 998 SyncHandle(); 999 return True; 1000 } 1001 1002 Bool 1003 SDL_NAME(XF86VidModeGetViewPort)(dpy, screen, x, y) 1004 Display* dpy; 1005 int screen; 1006 int *x, *y; 1007 { 1008 XExtDisplayInfo *info = find_display (dpy); 1009 xXF86VidModeGetViewPortReply rep; 1010 xXF86VidModeGetViewPortReq *req; 1011 int majorVersion, minorVersion; 1012 Bool protocolBug = False; 1013 1014 XF86VidModeCheckExtension (dpy, info, False); 1015 1016 /* 1017 * Note: There was a bug in the protocol implementation in versions 1018 * 0.x with x < 8 (no reply was sent, so the client would hang) 1019 * Check the server's version, and don't wait for a reply with older 1020 * versions. 1021 */ 1022 1023 SDL_NAME(XF86VidModeQueryVersion)(dpy, &majorVersion, &minorVersion); 1024 if (majorVersion == 0 && minorVersion < 8) { 1025 protocolBug = True; 1026 #ifdef DEBUG 1027 fprintf(stderr, "XF86VidModeGetViewPort: Warning: Xserver is" 1028 "running an old version (%d.%d)\n", majorVersion, 1029 minorVersion); 1030 #endif 1031 } 1032 LockDisplay(dpy); 1033 GetReq(XF86VidModeGetViewPort, req); 1034 req->reqType = info->codes->major_opcode; 1035 req->xf86vidmodeReqType = X_XF86VidModeGetViewPort; 1036 req->screen = screen; 1037 if (protocolBug) { 1038 *x = 0; 1039 *y = 0; 1040 } else { 1041 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 1042 UnlockDisplay(dpy); 1043 SyncHandle(); 1044 return False; 1045 } 1046 *x = rep.x; 1047 *y = rep.y; 1048 } 1049 1050 UnlockDisplay(dpy); 1051 SyncHandle(); 1052 return True; 1053 } 1054 1055 Bool 1056 SDL_NAME(XF86VidModeSetViewPort)(dpy, screen, x, y) 1057 Display* dpy; 1058 int screen; 1059 int x, y; 1060 { 1061 XExtDisplayInfo *info = find_display (dpy); 1062 xXF86VidModeSetViewPortReq *req; 1063 1064 XF86VidModeCheckExtension (dpy, info, False); 1065 1066 LockDisplay(dpy); 1067 GetReq(XF86VidModeSetViewPort, req); 1068 req->reqType = info->codes->major_opcode; 1069 req->xf86vidmodeReqType = X_XF86VidModeSetViewPort; 1070 req->screen = screen; 1071 req->x = x; 1072 req->y = y; 1073 1074 UnlockDisplay(dpy); 1075 SyncHandle(); 1076 return True; 1077 } 1078 1079 Bool 1080 SDL_NAME(XF86VidModeGetDotClocks)(dpy, screen, 1081 flagsPtr, numclocksPtr, maxclocksPtr, clocksPtr) 1082 Display* dpy; 1083 int screen; 1084 int *flagsPtr, *numclocksPtr, *maxclocksPtr, *clocksPtr[]; 1085 { 1086 XExtDisplayInfo *info = find_display (dpy); 1087 xXF86VidModeGetDotClocksReply rep; 1088 xXF86VidModeGetDotClocksReq *req; 1089 int i, *dotclocks; 1090 CARD32 dotclk; 1091 1092 XF86VidModeCheckExtension (dpy, info, False); 1093 1094 LockDisplay(dpy); 1095 GetReq(XF86VidModeGetDotClocks, req); 1096 req->reqType = info->codes->major_opcode; 1097 req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; 1098 req->screen = screen; 1099 if (!_XReply(dpy, (xReply *)&rep, 1100 (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse)) 1101 { 1102 UnlockDisplay(dpy); 1103 SyncHandle(); 1104 return False; 1105 } 1106 *numclocksPtr = rep.clocks; 1107 *maxclocksPtr = rep.maxclocks; 1108 *flagsPtr = rep.flags; 1109 1110 if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) { 1111 _XEatData(dpy, (rep.clocks) * 4); 1112 Xfree(dotclocks); 1113 UnlockDisplay(dpy); 1114 SyncHandle(); 1115 return False; 1116 } 1117 1118 for (i = 0; i < rep.clocks; i++) { 1119 _XRead(dpy, (char*)&dotclk, 4); 1120 dotclocks[i] = dotclk; 1121 } 1122 *clocksPtr = dotclocks; 1123 UnlockDisplay(dpy); 1124 SyncHandle(); 1125 return True; 1126 } 1127 1128 Bool 1129 SDL_NAME(XF86VidModeSetGammaRamp) ( 1130 Display *dpy, 1131 int screen, 1132 int size, 1133 unsigned short *red, 1134 unsigned short *green, 1135 unsigned short *blue 1136 ) 1137 { 1138 int length = (size + 1) & ~1; 1139 XExtDisplayInfo *info = find_display (dpy); 1140 xXF86VidModeSetGammaRampReq *req; 1141 1142 XF86VidModeCheckExtension (dpy, info, False); 1143 LockDisplay(dpy); 1144 GetReq(XF86VidModeSetGammaRamp, req); 1145 req->reqType = info->codes->major_opcode; 1146 req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp; 1147 req->screen = screen; 1148 req->length += (length >> 1) * 3; 1149 req->size = size; 1150 _XSend(dpy, (char*)red, size * 2); 1151 _XSend(dpy, (char*)green, size * 2); 1152 _XSend(dpy, (char*)blue, size * 2); 1153 UnlockDisplay(dpy); 1154 SyncHandle(); 1155 return True; 1156 } 1157 1158 1159 Bool 1160 SDL_NAME(XF86VidModeGetGammaRamp) ( 1161 Display *dpy, 1162 int screen, 1163 int size, 1164 unsigned short *red, 1165 unsigned short *green, 1166 unsigned short *blue 1167 ) 1168 { 1169 XExtDisplayInfo *info = find_display (dpy); 1170 xXF86VidModeGetGammaRampReq *req; 1171 xXF86VidModeGetGammaRampReply rep; 1172 1173 XF86VidModeCheckExtension (dpy, info, False); 1174 1175 LockDisplay(dpy); 1176 GetReq(XF86VidModeGetGammaRamp, req); 1177 req->reqType = info->codes->major_opcode; 1178 req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; 1179 req->screen = screen; 1180 req->size = size; 1181 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { 1182 UnlockDisplay (dpy); 1183 SyncHandle (); 1184 return False; 1185 } 1186 if(rep.size) { 1187 _XRead(dpy, (char*)red, rep.size << 1); 1188 _XRead(dpy, (char*)green, rep.size << 1); 1189 _XRead(dpy, (char*)blue, rep.size << 1); 1190 } 1191 1192 UnlockDisplay(dpy); 1193 SyncHandle(); 1194 return True; 1195 } 1196 1197 Bool SDL_NAME(XF86VidModeGetGammaRampSize)( 1198 Display *dpy, 1199 int screen, 1200 int *size 1201 ) 1202 { 1203 XExtDisplayInfo *info = find_display (dpy); 1204 xXF86VidModeGetGammaRampSizeReq *req; 1205 xXF86VidModeGetGammaRampSizeReply rep; 1206 1207 *size = 0; 1208 1209 XF86VidModeCheckExtension (dpy, info, False); 1210 1211 LockDisplay(dpy); 1212 GetReq(XF86VidModeGetGammaRampSize, req); 1213 req->reqType = info->codes->major_opcode; 1214 req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; 1215 req->screen = screen; 1216 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 1217 UnlockDisplay (dpy); 1218 SyncHandle (); 1219 return False; 1220 } 1221 *size = rep.size; 1222 UnlockDisplay(dpy); 1223 SyncHandle(); 1224 return True; 1225 } 1226 1227