Mercurial > sdl-ios-xcode
comparison src/video/Xext/Xinerama/Xinerama.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
43 #define PanoramiXCheckExtension(dpy,i,val) \ | 43 #define PanoramiXCheckExtension(dpy,i,val) \ |
44 XextCheckExtension (dpy, i, panoramiX_extension_name, val) | 44 XextCheckExtension (dpy, i, panoramiX_extension_name, val) |
45 #define PanoramiXSimpleCheckExtension(dpy,i) \ | 45 #define PanoramiXSimpleCheckExtension(dpy,i) \ |
46 XextSimpleCheckExtension (dpy, i, panoramiX_extension_name) | 46 XextSimpleCheckExtension (dpy, i, panoramiX_extension_name) |
47 | 47 |
48 static int close_display (); | 48 static int close_display(); |
49 static /* const */ XExtensionHooks panoramiX_extension_hooks = { | 49 static /* const */ XExtensionHooks panoramiX_extension_hooks = { |
50 NULL, /* create_gc */ | 50 NULL, /* create_gc */ |
51 NULL, /* copy_gc */ | 51 NULL, /* copy_gc */ |
52 NULL, /* flush_gc */ | 52 NULL, /* flush_gc */ |
53 NULL, /* free_gc */ | 53 NULL, /* free_gc */ |
59 NULL, /* error */ | 59 NULL, /* error */ |
60 NULL, /* error_string */ | 60 NULL, /* error_string */ |
61 }; | 61 }; |
62 | 62 |
63 static | 63 static |
64 XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info, | 64 XEXT_GENERATE_FIND_DISPLAY(find_display, panoramiX_ext_info, |
65 panoramiX_extension_name, | 65 panoramiX_extension_name, |
66 &panoramiX_extension_hooks, 0, NULL) | 66 &panoramiX_extension_hooks, 0, NULL) |
67 static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info) | 67 static XEXT_GENERATE_CLOSE_DISPLAY(close_display, panoramiX_ext_info) |
68 /**************************************************************************** | 68 /**************************************************************************** |
69 * * | 69 * * |
70 * PanoramiX public interfaces * | 70 * PanoramiX public interfaces * |
71 * * | 71 * * |
72 ****************************************************************************/ | 72 ****************************************************************************/ |
73 Bool SDL_NAME (XPanoramiXQueryExtension) (Display * dpy, | 73 Bool SDL_NAME(XPanoramiXQueryExtension) (Display * dpy, |
74 int *event_basep, | 74 int *event_basep, |
75 int *error_basep) | 75 int *error_basep) |
76 { | 76 { |
77 XExtDisplayInfo *info = find_display (dpy); | 77 XExtDisplayInfo *info = find_display(dpy); |
78 | 78 |
79 if (XextHasExtension (info)) { | 79 if (XextHasExtension(info)) { |
80 *event_basep = info->codes->first_event; | 80 *event_basep = info->codes->first_event; |
81 *error_basep = info->codes->first_error; | 81 *error_basep = info->codes->first_error; |
82 return True; | 82 return True; |
83 } else { | 83 } else { |
84 return False; | 84 return False; |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 Status SDL_NAME (XPanoramiXQueryVersion) (Display * dpy, | 89 Status SDL_NAME(XPanoramiXQueryVersion) (Display * dpy, |
90 int *major_versionp, | 90 int *major_versionp, |
91 int *minor_versionp) | 91 int *minor_versionp) |
92 { | 92 { |
93 XExtDisplayInfo *info = find_display (dpy); | 93 XExtDisplayInfo *info = find_display(dpy); |
94 xPanoramiXQueryVersionReply rep; | 94 xPanoramiXQueryVersionReply rep; |
95 register xPanoramiXQueryVersionReq *req; | 95 register xPanoramiXQueryVersionReq *req; |
96 | 96 |
97 PanoramiXCheckExtension (dpy, info, 0); | 97 PanoramiXCheckExtension(dpy, info, 0); |
98 | 98 |
99 LockDisplay (dpy); | 99 LockDisplay(dpy); |
100 GetReq (PanoramiXQueryVersion, req); | 100 GetReq(PanoramiXQueryVersion, req); |
101 req->reqType = info->codes->major_opcode; | 101 req->reqType = info->codes->major_opcode; |
102 req->panoramiXReqType = X_PanoramiXQueryVersion; | 102 req->panoramiXReqType = X_PanoramiXQueryVersion; |
103 req->clientMajor = PANORAMIX_MAJOR_VERSION; | 103 req->clientMajor = PANORAMIX_MAJOR_VERSION; |
104 req->clientMinor = PANORAMIX_MINOR_VERSION; | 104 req->clientMinor = PANORAMIX_MINOR_VERSION; |
105 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { | 105 if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { |
106 UnlockDisplay (dpy); | 106 UnlockDisplay(dpy); |
107 SyncHandle (); | 107 SyncHandle(); |
108 return 0; | 108 return 0; |
109 } | 109 } |
110 *major_versionp = rep.majorVersion; | 110 *major_versionp = rep.majorVersion; |
111 *minor_versionp = rep.minorVersion; | 111 *minor_versionp = rep.minorVersion; |
112 UnlockDisplay (dpy); | 112 UnlockDisplay(dpy); |
113 SyncHandle (); | 113 SyncHandle(); |
114 return 1; | 114 return 1; |
115 } | 115 } |
116 | 116 |
117 SDL_NAME (XPanoramiXInfo) * SDL_NAME (XPanoramiXAllocInfo) (void) | 117 SDL_NAME(XPanoramiXInfo) * SDL_NAME(XPanoramiXAllocInfo) (void) |
118 { | 118 { |
119 return (SDL_NAME (XPanoramiXInfo) *) | 119 return (SDL_NAME(XPanoramiXInfo) *) |
120 Xmalloc (sizeof (SDL_NAME (XPanoramiXInfo))); | 120 Xmalloc(sizeof(SDL_NAME(XPanoramiXInfo))); |
121 } | 121 } |
122 | 122 |
123 Status SDL_NAME (XPanoramiXGetState) (Display * dpy, | 123 Status SDL_NAME(XPanoramiXGetState) (Display * dpy, |
124 Drawable drawable, | 124 Drawable drawable, |
125 SDL_NAME (XPanoramiXInfo) * | 125 SDL_NAME(XPanoramiXInfo) * |
126 panoramiX_info) | 126 panoramiX_info) |
127 { | 127 { |
128 XExtDisplayInfo *info = find_display (dpy); | 128 XExtDisplayInfo *info = find_display(dpy); |
129 xPanoramiXGetStateReply rep; | 129 xPanoramiXGetStateReply rep; |
130 register xPanoramiXGetStateReq *req; | 130 register xPanoramiXGetStateReq *req; |
131 | 131 |
132 PanoramiXCheckExtension (dpy, info, 0); | 132 PanoramiXCheckExtension(dpy, info, 0); |
133 | 133 |
134 LockDisplay (dpy); | 134 LockDisplay(dpy); |
135 GetReq (PanoramiXGetState, req); | 135 GetReq(PanoramiXGetState, req); |
136 req->reqType = info->codes->major_opcode; | 136 req->reqType = info->codes->major_opcode; |
137 req->panoramiXReqType = X_PanoramiXGetState; | 137 req->panoramiXReqType = X_PanoramiXGetState; |
138 req->window = drawable; | 138 req->window = drawable; |
139 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { | 139 if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { |
140 UnlockDisplay (dpy); | 140 UnlockDisplay(dpy); |
141 SyncHandle (); | 141 SyncHandle(); |
142 return 0; | 142 return 0; |
143 } | 143 } |
144 UnlockDisplay (dpy); | 144 UnlockDisplay(dpy); |
145 SyncHandle (); | 145 SyncHandle(); |
146 panoramiX_info->window = rep.window; | 146 panoramiX_info->window = rep.window; |
147 panoramiX_info->State = rep.state; | 147 panoramiX_info->State = rep.state; |
148 return 1; | 148 return 1; |
149 } | 149 } |
150 | 150 |
151 Status SDL_NAME (XPanoramiXGetScreenCount) (Display * dpy, | 151 Status SDL_NAME(XPanoramiXGetScreenCount) (Display * dpy, |
152 Drawable drawable, | 152 Drawable drawable, |
153 SDL_NAME (XPanoramiXInfo) * | 153 SDL_NAME(XPanoramiXInfo) * |
154 panoramiX_info) | 154 panoramiX_info) |
155 { | 155 { |
156 XExtDisplayInfo *info = find_display (dpy); | 156 XExtDisplayInfo *info = find_display(dpy); |
157 xPanoramiXGetScreenCountReply rep; | 157 xPanoramiXGetScreenCountReply rep; |
158 register xPanoramiXGetScreenCountReq *req; | 158 register xPanoramiXGetScreenCountReq *req; |
159 | 159 |
160 PanoramiXCheckExtension (dpy, info, 0); | 160 PanoramiXCheckExtension(dpy, info, 0); |
161 | 161 |
162 LockDisplay (dpy); | 162 LockDisplay(dpy); |
163 GetReq (PanoramiXGetScreenCount, req); | 163 GetReq(PanoramiXGetScreenCount, req); |
164 req->reqType = info->codes->major_opcode; | 164 req->reqType = info->codes->major_opcode; |
165 req->panoramiXReqType = X_PanoramiXGetScreenCount; | 165 req->panoramiXReqType = X_PanoramiXGetScreenCount; |
166 req->window = drawable; | 166 req->window = drawable; |
167 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { | 167 if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { |
168 UnlockDisplay (dpy); | 168 UnlockDisplay(dpy); |
169 SyncHandle (); | 169 SyncHandle(); |
170 return 0; | 170 return 0; |
171 } | 171 } |
172 UnlockDisplay (dpy); | 172 UnlockDisplay(dpy); |
173 SyncHandle (); | 173 SyncHandle(); |
174 panoramiX_info->window = rep.window; | 174 panoramiX_info->window = rep.window; |
175 panoramiX_info->ScreenCount = rep.ScreenCount; | 175 panoramiX_info->ScreenCount = rep.ScreenCount; |
176 return 1; | 176 return 1; |
177 } | 177 } |
178 | 178 |
179 Status SDL_NAME (XPanoramiXGetScreenSize) (Display * dpy, | 179 Status SDL_NAME(XPanoramiXGetScreenSize) (Display * dpy, |
180 Drawable drawable, | 180 Drawable drawable, |
181 int screen_num, | 181 int screen_num, |
182 SDL_NAME (XPanoramiXInfo) * | 182 SDL_NAME(XPanoramiXInfo) * |
183 panoramiX_info) | 183 panoramiX_info) |
184 { | 184 { |
185 XExtDisplayInfo *info = find_display (dpy); | 185 XExtDisplayInfo *info = find_display(dpy); |
186 xPanoramiXGetScreenSizeReply rep; | 186 xPanoramiXGetScreenSizeReply rep; |
187 register xPanoramiXGetScreenSizeReq *req; | 187 register xPanoramiXGetScreenSizeReq *req; |
188 | 188 |
189 PanoramiXCheckExtension (dpy, info, 0); | 189 PanoramiXCheckExtension(dpy, info, 0); |
190 | 190 |
191 LockDisplay (dpy); | 191 LockDisplay(dpy); |
192 GetReq (PanoramiXGetScreenSize, req); | 192 GetReq(PanoramiXGetScreenSize, req); |
193 req->reqType = info->codes->major_opcode; | 193 req->reqType = info->codes->major_opcode; |
194 req->panoramiXReqType = X_PanoramiXGetScreenSize; | 194 req->panoramiXReqType = X_PanoramiXGetScreenSize; |
195 req->window = drawable; | 195 req->window = drawable; |
196 req->screen = screen_num; /* need to define */ | 196 req->screen = screen_num; /* need to define */ |
197 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { | 197 if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { |
198 UnlockDisplay (dpy); | 198 UnlockDisplay(dpy); |
199 SyncHandle (); | 199 SyncHandle(); |
200 return 0; | 200 return 0; |
201 } | 201 } |
202 UnlockDisplay (dpy); | 202 UnlockDisplay(dpy); |
203 SyncHandle (); | 203 SyncHandle(); |
204 panoramiX_info->window = rep.window; | 204 panoramiX_info->window = rep.window; |
205 panoramiX_info->screen = rep.screen; | 205 panoramiX_info->screen = rep.screen; |
206 panoramiX_info->width = rep.width; | 206 panoramiX_info->width = rep.width; |
207 panoramiX_info->height = rep.height; | 207 panoramiX_info->height = rep.height; |
208 return 1; | 208 return 1; |
212 Alternate interface to make up for shortcomings in the original, | 212 Alternate interface to make up for shortcomings in the original, |
213 namely, the omission of the screen origin. The new interface is | 213 namely, the omission of the screen origin. The new interface is |
214 in the "Xinerama" namespace instead of "PanoramiX". | 214 in the "Xinerama" namespace instead of "PanoramiX". |
215 \*******************************************************************/ | 215 \*******************************************************************/ |
216 | 216 |
217 Bool SDL_NAME (XineramaQueryExtension) (Display * dpy, | 217 Bool SDL_NAME(XineramaQueryExtension) (Display * dpy, |
218 int *event_base, int *error_base) | 218 int *event_base, int *error_base) |
219 { | 219 { |
220 return SDL_NAME (XPanoramiXQueryExtension) (dpy, event_base, error_base); | 220 return SDL_NAME(XPanoramiXQueryExtension) (dpy, event_base, error_base); |
221 } | 221 } |
222 | 222 |
223 Status SDL_NAME (XineramaQueryVersion) (Display * dpy, int *major, int *minor) | 223 Status SDL_NAME(XineramaQueryVersion) (Display * dpy, int *major, int *minor) |
224 { | 224 { |
225 return SDL_NAME (XPanoramiXQueryVersion) (dpy, major, minor); | 225 return SDL_NAME(XPanoramiXQueryVersion) (dpy, major, minor); |
226 } | 226 } |
227 | 227 |
228 Bool SDL_NAME (XineramaIsActive) (Display * dpy) | 228 Bool SDL_NAME(XineramaIsActive) (Display * dpy) |
229 { | 229 { |
230 xXineramaIsActiveReply rep; | 230 xXineramaIsActiveReply rep; |
231 xXineramaIsActiveReq *req; | 231 xXineramaIsActiveReq *req; |
232 XExtDisplayInfo *info = find_display (dpy); | 232 XExtDisplayInfo *info = find_display(dpy); |
233 | 233 |
234 if (!XextHasExtension (info)) | 234 if (!XextHasExtension(info)) |
235 return False; /* server doesn't even have the extension */ | 235 return False; /* server doesn't even have the extension */ |
236 | 236 |
237 LockDisplay (dpy); | 237 LockDisplay(dpy); |
238 GetReq (XineramaIsActive, req); | 238 GetReq(XineramaIsActive, req); |
239 req->reqType = info->codes->major_opcode; | 239 req->reqType = info->codes->major_opcode; |
240 req->panoramiXReqType = X_XineramaIsActive; | 240 req->panoramiXReqType = X_XineramaIsActive; |
241 if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { | 241 if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { |
242 UnlockDisplay (dpy); | 242 UnlockDisplay(dpy); |
243 SyncHandle (); | 243 SyncHandle(); |
244 return False; | 244 return False; |
245 } | 245 } |
246 UnlockDisplay (dpy); | 246 UnlockDisplay(dpy); |
247 SyncHandle (); | 247 SyncHandle(); |
248 return rep.state; | 248 return rep.state; |
249 } | 249 } |
250 | 250 |
251 #include <stdio.h> | 251 #include <stdio.h> |
252 | 252 |
253 SDL_NAME (XineramaScreenInfo) * | 253 SDL_NAME(XineramaScreenInfo) * |
254 SDL_NAME (XineramaQueryScreens) (Display * dpy, int *number) | 254 SDL_NAME(XineramaQueryScreens) (Display * dpy, int *number) |
255 { | 255 { |
256 XExtDisplayInfo *info = find_display (dpy); | 256 XExtDisplayInfo *info = find_display(dpy); |
257 xXineramaQueryScreensReply rep; | 257 xXineramaQueryScreensReply rep; |
258 xXineramaQueryScreensReq *req; | 258 xXineramaQueryScreensReq *req; |
259 SDL_NAME (XineramaScreenInfo) * scrnInfo = NULL; | 259 SDL_NAME(XineramaScreenInfo) * scrnInfo = NULL; |
260 | 260 |
261 PanoramiXCheckExtension (dpy, info, 0); | 261 PanoramiXCheckExtension(dpy, info, 0); |
262 | 262 |
263 LockDisplay (dpy); | 263 LockDisplay(dpy); |
264 GetReq (XineramaQueryScreens, req); | 264 GetReq(XineramaQueryScreens, req); |
265 req->reqType = info->codes->major_opcode; | 265 req->reqType = info->codes->major_opcode; |
266 req->panoramiXReqType = X_XineramaQueryScreens; | 266 req->panoramiXReqType = X_XineramaQueryScreens; |
267 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { | 267 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { |
268 UnlockDisplay (dpy); | 268 UnlockDisplay(dpy); |
269 SyncHandle (); | 269 SyncHandle(); |
270 return NULL; | 270 return NULL; |
271 } | 271 } |
272 | 272 |
273 if (rep.number) { | 273 if (rep.number) { |
274 if ((scrnInfo = | 274 if ((scrnInfo = |
275 Xmalloc (sizeof (SDL_NAME (XineramaScreenInfo)) * rep.number))) { | 275 Xmalloc(sizeof(SDL_NAME(XineramaScreenInfo)) * rep.number))) { |
276 xXineramaScreenInfo scratch; | 276 xXineramaScreenInfo scratch; |
277 int i; | 277 int i; |
278 | 278 |
279 for (i = 0; i < rep.number; i++) { | 279 for (i = 0; i < rep.number; i++) { |
280 _XRead (dpy, (char *) (&scratch), sz_XineramaScreenInfo); | 280 _XRead(dpy, (char *) (&scratch), sz_XineramaScreenInfo); |
281 scrnInfo[i].screen_number = i; | 281 scrnInfo[i].screen_number = i; |
282 scrnInfo[i].x_org = scratch.x_org; | 282 scrnInfo[i].x_org = scratch.x_org; |
283 scrnInfo[i].y_org = scratch.y_org; | 283 scrnInfo[i].y_org = scratch.y_org; |
284 scrnInfo[i].width = scratch.width; | 284 scrnInfo[i].width = scratch.width; |
285 scrnInfo[i].height = scratch.height; | 285 scrnInfo[i].height = scratch.height; |
286 } | 286 } |
287 | 287 |
288 *number = rep.number; | 288 *number = rep.number; |
289 } else | 289 } else |
290 _XEatData (dpy, rep.length << 2); | 290 _XEatData(dpy, rep.length << 2); |
291 } | 291 } |
292 | 292 |
293 UnlockDisplay (dpy); | 293 UnlockDisplay(dpy); |
294 SyncHandle (); | 294 SyncHandle(); |
295 return scrnInfo; | 295 return scrnInfo; |
296 } | 296 } |
297 | 297 |
298 /* vi: set ts=4 sw=4 expandtab: */ | 298 /* vi: set ts=4 sw=4 expandtab: */ |