comparison src/video/Xext/Xxf86vm/XF86VMode.c @ 292:eadc0746dfaf

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