comparison src/video/Xext/XME/xme.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents ecba4bbaf9c2
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
47 #define sz_xXiGMiscQueryResolutionsReply 32 47 #define sz_xXiGMiscQueryResolutionsReply 32
48 #define sz_xXiGMiscQueryFullScreenReply 32 48 #define sz_xXiGMiscQueryFullScreenReply 32
49 49
50 /*******************************************************************/ 50 /*******************************************************************/
51 51
52 typedef struct { 52 typedef struct
53 CARD8 reqType; /* always codes->major_opcode */ 53 {
54 CARD8 xigmiscReqType; /* always X_XiGMiscQueryVersion */ 54 CARD8 reqType; /* always codes->major_opcode */
55 CARD16 length; 55 CARD8 xigmiscReqType; /* always X_XiGMiscQueryVersion */
56 CARD16 major; 56 CARD16 length;
57 CARD16 minor; 57 CARD16 major;
58 CARD16 minor;
58 } xXiGMiscQueryVersionReq; 59 } xXiGMiscQueryVersionReq;
59 60
60 typedef struct { 61 typedef struct
61 CARD8 reqType; /* always codes->major_opcode */ 62 {
62 CARD8 xigmiscReqType; /* always X_XiGMiscQueryViews */ 63 CARD8 reqType; /* always codes->major_opcode */
63 CARD16 length; 64 CARD8 xigmiscReqType; /* always X_XiGMiscQueryViews */
64 CARD8 screen; 65 CARD16 length;
65 CARD8 pad0; 66 CARD8 screen;
66 CARD16 pad1; 67 CARD8 pad0;
68 CARD16 pad1;
67 } xXiGMiscQueryViewsReq; 69 } xXiGMiscQueryViewsReq;
68 70
69 typedef struct { 71 typedef struct
70 CARD8 reqType; /* always codes->major_opcode */ 72 {
71 CARD8 xigmiscReqType; /* always X_XiGMiscQueryResolutions */ 73 CARD8 reqType; /* always codes->major_opcode */
72 CARD16 length; 74 CARD8 xigmiscReqType; /* always X_XiGMiscQueryResolutions */
73 CARD8 screen; 75 CARD16 length;
74 CARD8 view; 76 CARD8 screen;
75 CARD16 pad0; 77 CARD8 view;
78 CARD16 pad0;
76 } xXiGMiscQueryResolutionsReq; 79 } xXiGMiscQueryResolutionsReq;
77 80
78 typedef struct { 81 typedef struct
79 CARD8 reqType; /* always codes->major_opcode */ 82 {
80 CARD8 xigmiscReqType; /* always X_XiGMiscChangeResolution */ 83 CARD8 reqType; /* always codes->major_opcode */
81 CARD16 length; 84 CARD8 xigmiscReqType; /* always X_XiGMiscChangeResolution */
82 CARD8 screen; 85 CARD16 length;
83 CARD8 view; 86 CARD8 screen;
84 CARD16 pad0; 87 CARD8 view;
85 CARD16 width; 88 CARD16 pad0;
86 CARD16 height; 89 CARD16 width;
87 INT32 refresh; 90 CARD16 height;
91 INT32 refresh;
88 } xXiGMiscChangeResolutionReq; 92 } xXiGMiscChangeResolutionReq;
89 93
90 typedef struct { 94 typedef struct
91 CARD8 reqType; /* always codes->major_opcode */ 95 {
92 CARD8 xigmiscReqType; /* always X_XiGMiscFullScreen */ 96 CARD8 reqType; /* always codes->major_opcode */
93 CARD16 length; 97 CARD8 xigmiscReqType; /* always X_XiGMiscFullScreen */
94 CARD8 screen; 98 CARD16 length;
95 CARD8 pad0; 99 CARD8 screen;
96 CARD16 pad1; 100 CARD8 pad0;
97 CARD32 window; 101 CARD16 pad1;
98 CARD32 cmap; 102 CARD32 window;
103 CARD32 cmap;
99 } xXiGMiscFullScreenReq; 104 } xXiGMiscFullScreenReq;
100 105
101 /*******************************************************************/ 106 /*******************************************************************/
102 107
103 typedef struct { 108 typedef struct
104 BYTE type; /* X_Reply */ 109 {
105 CARD8 pad0; 110 BYTE type; /* X_Reply */
106 CARD16 sequenceNumber; 111 CARD8 pad0;
107 CARD32 length; 112 CARD16 sequenceNumber;
108 CARD16 major; 113 CARD32 length;
109 CARD16 minor; 114 CARD16 major;
110 CARD32 pad1; 115 CARD16 minor;
111 CARD32 pad2; 116 CARD32 pad1;
112 CARD32 pad3; 117 CARD32 pad2;
113 CARD32 pad4; 118 CARD32 pad3;
114 CARD32 pad5; 119 CARD32 pad4;
120 CARD32 pad5;
115 } xXiGMiscQueryVersionReply; 121 } xXiGMiscQueryVersionReply;
116 122
117 typedef struct { 123 typedef struct
118 BYTE type; /* X_Reply */ 124 {
119 CARD8 pad0; 125 BYTE type; /* X_Reply */
120 CARD16 sequenceNumber; 126 CARD8 pad0;
121 CARD32 length; 127 CARD16 sequenceNumber;
122 CARD32 nviews; 128 CARD32 length;
123 CARD32 pad1; 129 CARD32 nviews;
124 CARD32 pad2; 130 CARD32 pad1;
125 CARD32 pad3; 131 CARD32 pad2;
126 CARD32 pad4; 132 CARD32 pad3;
127 CARD32 pad5; 133 CARD32 pad4;
134 CARD32 pad5;
128 } xXiGMiscQueryViewsReply; 135 } xXiGMiscQueryViewsReply;
129 136
130 typedef struct { 137 typedef struct
131 BYTE type; /* X_Reply */ 138 {
132 CARD8 pad0; 139 BYTE type; /* X_Reply */
133 CARD16 sequenceNumber; 140 CARD8 pad0;
134 CARD32 length; 141 CARD16 sequenceNumber;
135 CARD16 active; 142 CARD32 length;
136 CARD16 nresolutions; 143 CARD16 active;
137 CARD32 pad1; 144 CARD16 nresolutions;
138 CARD32 pad2; 145 CARD32 pad1;
139 CARD32 pad3; 146 CARD32 pad2;
140 CARD32 pad4; 147 CARD32 pad3;
141 CARD32 pad5; 148 CARD32 pad4;
149 CARD32 pad5;
142 } xXiGMiscQueryResolutionsReply; 150 } xXiGMiscQueryResolutionsReply;
143 151
144 typedef struct { 152 typedef struct
145 BYTE type; /* X_Reply */ 153 {
146 BOOL success; 154 BYTE type; /* X_Reply */
147 CARD16 sequenceNumber; 155 BOOL success;
148 CARD32 length; 156 CARD16 sequenceNumber;
149 CARD32 pad1; 157 CARD32 length;
150 CARD32 pad2; 158 CARD32 pad1;
151 CARD32 pad3; 159 CARD32 pad2;
152 CARD32 pad4; 160 CARD32 pad3;
153 CARD32 pad5; 161 CARD32 pad4;
154 CARD32 pad6; 162 CARD32 pad5;
163 CARD32 pad6;
155 } xXiGMiscFullScreenReply; 164 } xXiGMiscFullScreenReply;
156 165
157 /*******************************************************************/ 166 /*******************************************************************/
158 167
159 typedef struct { 168 typedef struct
160 INT16 x; 169 {
161 INT16 y; 170 INT16 x;
162 CARD16 w; 171 INT16 y;
163 CARD16 h; 172 CARD16 w;
173 CARD16 h;
164 } XiGMiscViewInfo; 174 } XiGMiscViewInfo;
165 175
166 typedef struct { 176 typedef struct
167 CARD16 width; 177 {
168 CARD16 height; 178 CARD16 width;
169 INT32 refresh; 179 CARD16 height;
180 INT32 refresh;
170 } XiGMiscResolutionInfo; 181 } XiGMiscResolutionInfo;
171 182
172 /*****************************************************************************/ 183 /*****************************************************************************/
173 184
174 static XExtensionInfo *xigmisc_info = NULL; 185 static XExtensionInfo *xigmisc_info = NULL;
199 210
200 211
201 /* 212 /*
202 * find_display - locate the display info block 213 * find_display - locate the display info block
203 */ 214 */
204 static int XiGMiscCloseDisplay(); 215 static int XiGMiscCloseDisplay ();
205 216
206 static XExtensionHooks xigmisc_extension_hooks = { 217 static XExtensionHooks xigmisc_extension_hooks = {
207 NULL, /* create_gc */ 218 NULL, /* create_gc */
208 NULL, /* copy_gc */ 219 NULL, /* copy_gc */
209 NULL, /* flush_gc */ 220 NULL, /* flush_gc */
210 NULL, /* free_gc */ 221 NULL, /* free_gc */
211 NULL, /* create_font */ 222 NULL, /* create_font */
212 NULL, /* free_font */ 223 NULL, /* free_font */
213 XiGMiscCloseDisplay, /* close_display */ 224 XiGMiscCloseDisplay, /* close_display */
214 NULL, /* wire_to_event */ 225 NULL, /* wire_to_event */
215 NULL, /* event_to_wire */ 226 NULL, /* event_to_wire */
216 NULL, /* error */ 227 NULL, /* error */
217 NULL, /* error_string */ 228 NULL, /* error_string */
218 }; 229 };
219 230
220 231
221 static XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info) 232 static
222 233 XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info)
223 static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info, 234 static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info,
224 xigmisc_extension_name, 235 xigmisc_extension_name,
225 &xigmisc_extension_hooks, XiGMiscNumberEvents, NULL) 236 &xigmisc_extension_hooks,
226 237 XiGMiscNumberEvents, NULL)
227
228 /*****************************************************************************/ 238 /*****************************************************************************/
229 239 Bool XiGMiscQueryVersion (Display * dpy, int *major, int *minor)
230 Bool XiGMiscQueryVersion(Display *dpy, int *major, int *minor) 240 {
231 { 241 int opcode, event, error;
232 int opcode, event, error; 242 xXiGMiscQueryVersionReq *req;
233 xXiGMiscQueryVersionReq *req; 243 xXiGMiscQueryVersionReply rep;
234 xXiGMiscQueryVersionReply rep; 244 XExtDisplayInfo *info = XiGMiscFindDisplay (dpy);
235 XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); 245
236 246 if (!XQueryExtension
237 if (!XQueryExtension(dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) 247 (dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error))
238 return xFalse; 248 return xFalse;
239 249
240 XiGMiscCheckExtension(dpy, info, xFalse); 250 XiGMiscCheckExtension (dpy, info, xFalse);
241 251
242 LockDisplay (dpy); 252 LockDisplay (dpy);
243 XiGMiscGetReq (XiGMiscQueryVersion, req, info); 253 XiGMiscGetReq (XiGMiscQueryVersion, req, info);
244 254
245 req->major = XIGMISC_MAJOR_VERSION; 255 req->major = XIGMISC_MAJOR_VERSION;
246 req->minor = XIGMISC_MINOR_VERSION; 256 req->minor = XIGMISC_MINOR_VERSION;
247 257
248 if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) { 258 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) {
249 UnlockDisplay(dpy); 259 UnlockDisplay (dpy);
250 SyncHandle(); 260 SyncHandle ();
251 return xFalse; 261 return xFalse;
252 } 262 }
253 263
254 *major = rep.major; 264 *major = rep.major;
255 *minor = rep.minor; 265 *minor = rep.minor;
256 UnlockDisplay(dpy); 266 UnlockDisplay (dpy);
257 SyncHandle(); 267 SyncHandle ();
258 268
259 return xTrue; 269 return xTrue;
260 } 270 }
261 271
262 int XiGMiscQueryViews(Display *dpy, int screen, XiGMiscViewInfo **pviews) 272 int
263 { 273 XiGMiscQueryViews (Display * dpy, int screen, XiGMiscViewInfo ** pviews)
264 int n, size; 274 {
265 XiGMiscViewInfo *views; 275 int n, size;
266 xXiGMiscQueryViewsReq *req; 276 XiGMiscViewInfo *views;
267 xXiGMiscQueryViewsReply rep; 277 xXiGMiscQueryViewsReq *req;
268 XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); 278 xXiGMiscQueryViewsReply rep;
269 XiGMiscCheckExtension(dpy, info, 0); 279 XExtDisplayInfo *info = XiGMiscFindDisplay (dpy);
270 280 XiGMiscCheckExtension (dpy, info, 0);
271 LockDisplay (dpy); 281
272 XiGMiscGetReq (XiGMiscQueryViews, req, info); 282 LockDisplay (dpy);
273 req->screen = screen; 283 XiGMiscGetReq (XiGMiscQueryViews, req, info);
274 284 req->screen = screen;
275 if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { 285
276 UnlockDisplay(dpy); 286 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) {
277 SyncHandle(); 287 UnlockDisplay (dpy);
278 return 0; 288 SyncHandle ();
279 } 289 return 0;
280 290 }
281 n = rep.nviews; 291
282 292 n = rep.nviews;
283 if (n > 0) { 293
284 size = sizeof(XiGMiscViewInfo) * n; 294 if (n > 0) {
285 views = (XiGMiscViewInfo*)Xmalloc(size); 295 size = sizeof (XiGMiscViewInfo) * n;
286 if (!views) { 296 views = (XiGMiscViewInfo *) Xmalloc (size);
287 _XEatData(dpy, (unsigned long)size); 297 if (!views) {
288 UnlockDisplay(dpy); 298 _XEatData (dpy, (unsigned long) size);
289 SyncHandle(); 299 UnlockDisplay (dpy);
290 return 0; 300 SyncHandle ();
291 } 301 return 0;
292 302 }
293 _XReadPad(dpy, (void*)views, size); 303
294 304 _XReadPad (dpy, (void *) views, size);
295 *pviews = views; 305
296 } 306 *pviews = views;
297 307 }
298 UnlockDisplay(dpy); 308
299 SyncHandle(); 309 UnlockDisplay (dpy);
300 310 SyncHandle ();
301 return n; 311
312 return n;
302 } 313 }
303 314
304 int XiGMiscQueryResolutions(Display *dpy, int screen, int view, int *pactive, XiGMiscResolutionInfo **presolutions) 315 int
305 { 316 XiGMiscQueryResolutions (Display * dpy, int screen, int view, int *pactive,
306 int n, size; 317 XiGMiscResolutionInfo ** presolutions)
307 XiGMiscResolutionInfo *resolutions; 318 {
308 xXiGMiscQueryResolutionsReq *req; 319 int n, size;
309 xXiGMiscQueryResolutionsReply rep; 320 XiGMiscResolutionInfo *resolutions;
310 XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); 321 xXiGMiscQueryResolutionsReq *req;
311 XiGMiscCheckExtension(dpy, info, 0); 322 xXiGMiscQueryResolutionsReply rep;
312 323 XExtDisplayInfo *info = XiGMiscFindDisplay (dpy);
313 LockDisplay (dpy); 324 XiGMiscCheckExtension (dpy, info, 0);
314 XiGMiscGetReq (XiGMiscQueryResolutions, req, info); 325
315 req->screen = screen; 326 LockDisplay (dpy);
316 req->view = view; 327 XiGMiscGetReq (XiGMiscQueryResolutions, req, info);
317 328 req->screen = screen;
318 if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { 329 req->view = view;
319 UnlockDisplay(dpy); 330
320 SyncHandle(); 331 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) {
321 return 0; 332 UnlockDisplay (dpy);
322 } 333 SyncHandle ();
323 334 return 0;
324 n = rep.nresolutions; 335 }
325 336
326 if (n > 0) { 337 n = rep.nresolutions;
327 size = sizeof(XiGMiscResolutionInfo) * n; 338
328 resolutions = (XiGMiscResolutionInfo*)Xmalloc(size); 339 if (n > 0) {
329 if (!resolutions) { 340 size = sizeof (XiGMiscResolutionInfo) * n;
330 _XEatData(dpy, (unsigned long)size); 341 resolutions = (XiGMiscResolutionInfo *) Xmalloc (size);
331 UnlockDisplay(dpy); 342 if (!resolutions) {
332 SyncHandle(); 343 _XEatData (dpy, (unsigned long) size);
333 return 0; 344 UnlockDisplay (dpy);
334 } 345 SyncHandle ();
335 346 return 0;
336 _XReadPad(dpy, (void*)resolutions, size); 347 }
337 348
338 *presolutions = resolutions; 349 _XReadPad (dpy, (void *) resolutions, size);
339 *pactive = rep.active; 350
340 } 351 *presolutions = resolutions;
341 352 *pactive = rep.active;
342 UnlockDisplay(dpy); 353 }
343 SyncHandle(); 354
344 355 UnlockDisplay (dpy);
345 return n; 356 SyncHandle ();
357
358 return n;
346 } 359 }
347 360
348 void XiGMiscChangeResolution(Display *dpy, int screen, int view, int width, int height, int refresh) 361 void
349 { 362 XiGMiscChangeResolution (Display * dpy, int screen, int view, int width,
350 xXiGMiscChangeResolutionReq *req; 363 int height, int refresh)
351 XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); 364 {
352 365 xXiGMiscChangeResolutionReq *req;
353 XiGMiscSimpleCheckExtension(dpy, info); 366 XExtDisplayInfo *info = XiGMiscFindDisplay (dpy);
354 367
355 LockDisplay (dpy); 368 XiGMiscSimpleCheckExtension (dpy, info);
356 XiGMiscGetReq (XiGMiscChangeResolution, req, info); 369
357 req->screen = screen; 370 LockDisplay (dpy);
358 req->view = view; 371 XiGMiscGetReq (XiGMiscChangeResolution, req, info);
359 req->width = width; 372 req->screen = screen;
360 req->height = height; 373 req->view = view;
361 req->refresh = refresh; 374 req->width = width;
362 375 req->height = height;
363 UnlockDisplay(dpy); 376 req->refresh = refresh;
364 SyncHandle(); 377
378 UnlockDisplay (dpy);
379 SyncHandle ();
365 } 380 }
366 381
367 382
368 Bool XiGMiscFullScreen(Display *dpy, int screen, XID window, XID cmap) 383 Bool
369 { 384 XiGMiscFullScreen (Display * dpy, int screen, XID window, XID cmap)
370 xXiGMiscFullScreenReq *req; 385 {
371 xXiGMiscFullScreenReply rep; 386 xXiGMiscFullScreenReq *req;
372 XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); 387 xXiGMiscFullScreenReply rep;
373 388 XExtDisplayInfo *info = XiGMiscFindDisplay (dpy);
374 XiGMiscCheckExtension(dpy, info, xFalse); 389
375 390 XiGMiscCheckExtension (dpy, info, xFalse);
376 LockDisplay (dpy); 391
377 XiGMiscGetReq (XiGMiscFullScreen, req, info); 392 LockDisplay (dpy);
378 req->screen = screen; 393 XiGMiscGetReq (XiGMiscFullScreen, req, info);
379 req->pad0 = 0; 394 req->screen = screen;
380 req->pad1 = 0; 395 req->pad0 = 0;
381 req->window = window; 396 req->pad1 = 0;
382 req->cmap = cmap; 397 req->window = window;
383 398 req->cmap = cmap;
384 if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) { 399
385 UnlockDisplay(dpy); 400 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) {
386 SyncHandle(); 401 UnlockDisplay (dpy);
387 return xFalse; 402 SyncHandle ();
388 } 403 return xFalse;
389 404 }
390 UnlockDisplay(dpy); 405
391 SyncHandle(); 406 UnlockDisplay (dpy);
392 407 SyncHandle ();
393 return (rep.success ? xTrue : xFalse); 408
409 return (rep.success ? xTrue : xFalse);
394 } 410 }
395 411
412 /* vi: set ts=4 sw=4 expandtab: */