comparison src/video/Xext/Xxf86vm/XF86VMode.c @ 1895:c121d94672cb

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