comparison src/video/Xext/Xinerama/Xinerama.c @ 1168:045f186426e1

Dynamically load X11 libraries like we currently do for alsa, esd, etc. This allows you to run an SDL program on a system without Xlib, since it'll just report the x11 target unavailable at runtime.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 05 Nov 2005 19:53:37 +0000
parents eadc0746dfaf
children d05306f0dc21
comparison
equal deleted inserted replaced
1167:435c2e481299 1168:045f186426e1
33 #include "extutil.h" /* in ../include */ 33 #include "extutil.h" /* in ../include */
34 #include "panoramiXext.h" 34 #include "panoramiXext.h"
35 #include "panoramiXproto.h" /* in ../include */ 35 #include "panoramiXproto.h" /* in ../include */
36 #include "Xinerama.h" 36 #include "Xinerama.h"
37 37
38 #include "../../x11/SDL_x11dyn.h"
39
40 /* Workaround code in headers... */
41 #define _XFlush p_XFlush
42 #define _XFlushGCCache p_XFlushGCCache
43 #define _XReply p_XReply
44 #define _XSend p_XSend
38 45
39 static XExtensionInfo _panoramiX_ext_info_data; 46 static XExtensionInfo _panoramiX_ext_info_data;
40 static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data; 47 static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
41 static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME; 48 static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME;
42 49
109 GetReq (PanoramiXQueryVersion, req); 116 GetReq (PanoramiXQueryVersion, req);
110 req->reqType = info->codes->major_opcode; 117 req->reqType = info->codes->major_opcode;
111 req->panoramiXReqType = X_PanoramiXQueryVersion; 118 req->panoramiXReqType = X_PanoramiXQueryVersion;
112 req->clientMajor = PANORAMIX_MAJOR_VERSION; 119 req->clientMajor = PANORAMIX_MAJOR_VERSION;
113 req->clientMinor = PANORAMIX_MINOR_VERSION; 120 req->clientMinor = PANORAMIX_MINOR_VERSION;
114 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 121 if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
115 UnlockDisplay (dpy); 122 UnlockDisplay (dpy);
116 SyncHandle (); 123 SyncHandle ();
117 return 0; 124 return 0;
118 } 125 }
119 *major_versionp = rep.majorVersion; 126 *major_versionp = rep.majorVersion;
143 LockDisplay (dpy); 150 LockDisplay (dpy);
144 GetReq (PanoramiXGetState, req); 151 GetReq (PanoramiXGetState, req);
145 req->reqType = info->codes->major_opcode; 152 req->reqType = info->codes->major_opcode;
146 req->panoramiXReqType = X_PanoramiXGetState; 153 req->panoramiXReqType = X_PanoramiXGetState;
147 req->window = drawable; 154 req->window = drawable;
148 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 155 if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
149 UnlockDisplay (dpy); 156 UnlockDisplay (dpy);
150 SyncHandle (); 157 SyncHandle ();
151 return 0; 158 return 0;
152 } 159 }
153 UnlockDisplay (dpy); 160 UnlockDisplay (dpy);
172 LockDisplay (dpy); 179 LockDisplay (dpy);
173 GetReq (PanoramiXGetScreenCount, req); 180 GetReq (PanoramiXGetScreenCount, req);
174 req->reqType = info->codes->major_opcode; 181 req->reqType = info->codes->major_opcode;
175 req->panoramiXReqType = X_PanoramiXGetScreenCount; 182 req->panoramiXReqType = X_PanoramiXGetScreenCount;
176 req->window = drawable; 183 req->window = drawable;
177 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 184 if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
178 UnlockDisplay (dpy); 185 UnlockDisplay (dpy);
179 SyncHandle (); 186 SyncHandle ();
180 return 0; 187 return 0;
181 } 188 }
182 UnlockDisplay (dpy); 189 UnlockDisplay (dpy);
203 GetReq (PanoramiXGetScreenSize, req); 210 GetReq (PanoramiXGetScreenSize, req);
204 req->reqType = info->codes->major_opcode; 211 req->reqType = info->codes->major_opcode;
205 req->panoramiXReqType = X_PanoramiXGetScreenSize; 212 req->panoramiXReqType = X_PanoramiXGetScreenSize;
206 req->window = drawable; 213 req->window = drawable;
207 req->screen = screen_num; /* need to define */ 214 req->screen = screen_num; /* need to define */
208 if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { 215 if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
209 UnlockDisplay (dpy); 216 UnlockDisplay (dpy);
210 SyncHandle (); 217 SyncHandle ();
211 return 0; 218 return 0;
212 } 219 }
213 UnlockDisplay (dpy); 220 UnlockDisplay (dpy);
283 290
284 LockDisplay (dpy); 291 LockDisplay (dpy);
285 GetReq (XineramaQueryScreens, req); 292 GetReq (XineramaQueryScreens, req);
286 req->reqType = info->codes->major_opcode; 293 req->reqType = info->codes->major_opcode;
287 req->panoramiXReqType = X_XineramaQueryScreens; 294 req->panoramiXReqType = X_XineramaQueryScreens;
288 if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { 295 if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
289 UnlockDisplay (dpy); 296 UnlockDisplay (dpy);
290 SyncHandle (); 297 SyncHandle ();
291 return NULL; 298 return NULL;
292 } 299 }
293 300
295 if((scrnInfo = Xmalloc(sizeof(SDL_NAME(XineramaScreenInfo)) * rep.number))) { 302 if((scrnInfo = Xmalloc(sizeof(SDL_NAME(XineramaScreenInfo)) * rep.number))) {
296 xXineramaScreenInfo scratch; 303 xXineramaScreenInfo scratch;
297 int i; 304 int i;
298 305
299 for(i = 0; i < rep.number; i++) { 306 for(i = 0; i < rep.number; i++) {
300 _XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo); 307 p_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
301 scrnInfo[i].screen_number = i; 308 scrnInfo[i].screen_number = i;
302 scrnInfo[i].x_org = scratch.x_org; 309 scrnInfo[i].x_org = scratch.x_org;
303 scrnInfo[i].y_org = scratch.y_org; 310 scrnInfo[i].y_org = scratch.y_org;
304 scrnInfo[i].width = scratch.width; 311 scrnInfo[i].width = scratch.width;
305 scrnInfo[i].height = scratch.height; 312 scrnInfo[i].height = scratch.height;
306 } 313 }
307 314
308 *number = rep.number; 315 *number = rep.number;
309 } else 316 } else
310 _XEatData(dpy, rep.length << 2); 317 p_XEatData(dpy, rep.length << 2);
311 } 318 }
312 319
313 UnlockDisplay (dpy); 320 UnlockDisplay (dpy);
314 SyncHandle (); 321 SyncHandle ();
315 return scrnInfo; 322 return scrnInfo;