comparison src/video/x11/SDL_x11wm.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
32 #include "../../events/SDL_events_c.h" 32 #include "../../events/SDL_events_c.h"
33 #include "SDL_x11modes_c.h" 33 #include "SDL_x11modes_c.h"
34 #include "SDL_x11wm_c.h" 34 #include "SDL_x11wm_c.h"
35 35
36 static Uint8 36 static Uint8
37 reverse_byte (Uint8 x) 37 reverse_byte(Uint8 x)
38 { 38 {
39 x = (x & 0xaa) >> 1 | (x & 0x55) << 1; 39 x = (x & 0xaa) >> 1 | (x & 0x55) << 1;
40 x = (x & 0xcc) >> 2 | (x & 0x33) << 2; 40 x = (x & 0xcc) >> 2 | (x & 0x33) << 2;
41 x = (x & 0xf0) >> 4 | (x & 0x0f) << 4; 41 x = (x & 0xf0) >> 4 | (x & 0x0f) << 4;
42 return x; 42 return x;
43 } 43 }
44 44
45 void 45 void
46 X11_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) 46 X11_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask)
47 { 47 {
48 SDL_Surface *sicon; 48 SDL_Surface *sicon;
49 XWMHints *wmhints; 49 XWMHints *wmhints;
50 XImage *icon_image; 50 XImage *icon_image;
51 Pixmap icon_pixmap; 51 Pixmap icon_pixmap;
58 Uint8 *LSBmask; 58 Uint8 *LSBmask;
59 Visual *dvis; 59 Visual *dvis;
60 char *p; 60 char *p;
61 int masksize; 61 int masksize;
62 62
63 SDL_Lock_EventThread (); 63 SDL_Lock_EventThread();
64 64
65 /* The icon must use the default visual, depth and colormap of the 65 /* The icon must use the default visual, depth and colormap of the
66 screen, so it might need a conversion */ 66 screen, so it might need a conversion */
67 dvis = DefaultVisual (SDL_Display, SDL_Screen); 67 dvis = DefaultVisual(SDL_Display, SDL_Screen);
68 dbpp = DefaultDepth (SDL_Display, SDL_Screen); 68 dbpp = DefaultDepth(SDL_Display, SDL_Screen);
69 for (i = 0; i < this->hidden->nvisuals; i++) { 69 for (i = 0; i < this->hidden->nvisuals; i++) {
70 if (this->hidden->visuals[i].visual == dvis) { 70 if (this->hidden->visuals[i].visual == dvis) {
71 dbpp = this->hidden->visuals[i].bpp; 71 dbpp = this->hidden->visuals[i].bpp;
72 break; 72 break;
73 } 73 }
74 } 74 }
75 75
76 /* The Visual struct is supposed to be opaque but we cheat a little */ 76 /* The Visual struct is supposed to be opaque but we cheat a little */
77 sicon = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h, 77 sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
78 dbpp, 78 dbpp,
79 dvis->red_mask, dvis->green_mask, 79 dvis->red_mask, dvis->green_mask,
80 dvis->blue_mask, 0); 80 dvis->blue_mask, 0);
81 if (sicon == NULL) 81 if (sicon == NULL)
82 goto done; 82 goto done;
83 83
84 if (dbpp == 8) { 84 if (dbpp == 8) {
85 /* Default visual is 8bit; we need to allocate colours from 85 /* Default visual is 8bit; we need to allocate colours from
86 the default colormap */ 86 the default colormap */
87 SDL_Color want[256], got[256]; 87 SDL_Color want[256], got[256];
88 int nwant; 88 int nwant;
89 Colormap dcmap; 89 Colormap dcmap;
90 int missing; 90 int missing;
91 dcmap = DefaultColormap (SDL_Display, SDL_Screen); 91 dcmap = DefaultColormap(SDL_Display, SDL_Screen);
92 if (icon->format->palette) { 92 if (icon->format->palette) {
93 /* The icon has a palette as well - we just have to 93 /* The icon has a palette as well - we just have to
94 find those colours */ 94 find those colours */
95 nwant = icon->format->palette->ncolors; 95 nwant = icon->format->palette->ncolors;
96 SDL_memcpy (want, icon->format->palette->colors, 96 SDL_memcpy(want, icon->format->palette->colors,
97 nwant * sizeof want[0]); 97 nwant * sizeof want[0]);
98 } else { 98 } else {
99 /* try the standard 6x6x6 cube for lack of better 99 /* try the standard 6x6x6 cube for lack of better
100 ideas */ 100 ideas */
101 int r, g, b, i; 101 int r, g, b, i;
102 for (r = i = 0; r < 256; r += 0x33) 102 for (r = i = 0; r < 256; r += 0x33)
116 while (SDL_iconcolors[i]) { 116 while (SDL_iconcolors[i]) {
117 freelist[nfree++] = i; 117 freelist[nfree++] = i;
118 SDL_iconcolors[i]--; 118 SDL_iconcolors[i]--;
119 } 119 }
120 } 120 }
121 XFreeColors (GFX_Display, dcmap, freelist, nfree, 0); 121 XFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
122 } 122 }
123 if (!SDL_iconcolors) 123 if (!SDL_iconcolors)
124 SDL_iconcolors = SDL_malloc (256 * sizeof *SDL_iconcolors); 124 SDL_iconcolors = SDL_malloc(256 * sizeof *SDL_iconcolors);
125 SDL_memset (SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors); 125 SDL_memset(SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors);
126 126
127 /* try to allocate the colours */ 127 /* try to allocate the colours */
128 SDL_memset (got, 0, sizeof got); 128 SDL_memset(got, 0, sizeof got);
129 missing = 0; 129 missing = 0;
130 for (i = 0; i < nwant; i++) { 130 for (i = 0; i < nwant; i++) {
131 XColor c; 131 XColor c;
132 c.red = want[i].r << 8; 132 c.red = want[i].r << 8;
133 c.green = want[i].g << 8; 133 c.green = want[i].g << 8;
134 c.blue = want[i].b << 8; 134 c.blue = want[i].b << 8;
135 c.flags = DoRed | DoGreen | DoBlue; 135 c.flags = DoRed | DoGreen | DoBlue;
136 if (XAllocColor (GFX_Display, dcmap, &c)) { 136 if (XAllocColor(GFX_Display, dcmap, &c)) {
137 /* got the colour */ 137 /* got the colour */
138 SDL_iconcolors[c.pixel]++; 138 SDL_iconcolors[c.pixel]++;
139 got[c.pixel] = want[i]; 139 got[c.pixel] = want[i];
140 } else { 140 } else {
141 missing = 1; 141 missing = 1;
145 /* Some colours were apparently missing, so we just 145 /* Some colours were apparently missing, so we just
146 allocate all the rest as well */ 146 allocate all the rest as well */
147 XColor cols[256]; 147 XColor cols[256];
148 for (i = 0; i < 256; i++) 148 for (i = 0; i < 256; i++)
149 cols[i].pixel = i; 149 cols[i].pixel = i;
150 XQueryColors (GFX_Display, dcmap, cols, 256); 150 XQueryColors(GFX_Display, dcmap, cols, 256);
151 for (i = 0; i < 256; i++) { 151 for (i = 0; i < 256; i++) {
152 got[i].r = cols[i].red >> 8; 152 got[i].r = cols[i].red >> 8;
153 got[i].g = cols[i].green >> 8; 153 got[i].g = cols[i].green >> 8;
154 got[i].b = cols[i].blue >> 8; 154 got[i].b = cols[i].blue >> 8;
155 if (!SDL_iconcolors[i]) { 155 if (!SDL_iconcolors[i]) {
156 if (XAllocColor (GFX_Display, dcmap, cols + i)) { 156 if (XAllocColor(GFX_Display, dcmap, cols + i)) {
157 SDL_iconcolors[i] = 1; 157 SDL_iconcolors[i] = 1;
158 } else { 158 } else {
159 /* index not available */ 159 /* index not available */
160 got[i].r = 0; 160 got[i].r = 0;
161 got[i].g = 0; 161 got[i].g = 0;
163 } 163 }
164 } 164 }
165 } 165 }
166 } 166 }
167 167
168 SDL_SetColors (sicon, got, 0, 256); 168 SDL_SetColors(sicon, got, 0, 256);
169 } 169 }
170 170
171 bounds.x = 0; 171 bounds.x = 0;
172 bounds.y = 0; 172 bounds.y = 0;
173 bounds.w = icon->w; 173 bounds.w = icon->w;
174 bounds.h = icon->h; 174 bounds.h = icon->h;
175 if (SDL_LowerBlit (icon, &bounds, sicon, &bounds) < 0) 175 if (SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0)
176 goto done; 176 goto done;
177 177
178 /* We need the mask as given, except in LSBfirst format instead of 178 /* We need the mask as given, except in LSBfirst format instead of
179 MSBfirst. Reverse the bits in each byte. */ 179 MSBfirst. Reverse the bits in each byte. */
180 masksize = ((sicon->w + 7) >> 3) * sicon->h; 180 masksize = ((sicon->w + 7) >> 3) * sicon->h;
181 LSBmask = SDL_malloc (masksize); 181 LSBmask = SDL_malloc(masksize);
182 if (LSBmask == NULL) { 182 if (LSBmask == NULL) {
183 goto done; 183 goto done;
184 } 184 }
185 SDL_memset (LSBmask, 0, masksize); 185 SDL_memset(LSBmask, 0, masksize);
186 for (i = 0; i < masksize; i++) 186 for (i = 0; i < masksize; i++)
187 LSBmask[i] = reverse_byte (mask[i]); 187 LSBmask[i] = reverse_byte(mask[i]);
188 mask_pixmap = XCreatePixmapFromBitmapData (SDL_Display, WMwindow, 188 mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
189 (char *) LSBmask, 189 (char *) LSBmask,
190 sicon->w, sicon->h, 1L, 0L, 1); 190 sicon->w, sicon->h, 1L, 0L, 1);
191 191
192 /* Transfer the image to an X11 pixmap */ 192 /* Transfer the image to an X11 pixmap */
193 icon_image = XCreateImage (SDL_Display, 193 icon_image = XCreateImage(SDL_Display,
194 DefaultVisual (SDL_Display, SDL_Screen), 194 DefaultVisual(SDL_Display, SDL_Screen),
195 DefaultDepth (SDL_Display, SDL_Screen), 195 DefaultDepth(SDL_Display, SDL_Screen),
196 ZPixmap, 0, sicon->pixels, 196 ZPixmap, 0, sicon->pixels,
197 sicon->w, sicon->h, 32, 0); 197 sicon->w, sicon->h, 32, 0);
198 icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) 198 icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN)
199 ? MSBFirst : LSBFirst; 199 ? MSBFirst : LSBFirst;
200 icon_pixmap = XCreatePixmap (SDL_Display, SDL_Root, sicon->w, sicon->h, 200 icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
201 DefaultDepth (SDL_Display, SDL_Screen)); 201 DefaultDepth(SDL_Display, SDL_Screen));
202 gc = XCreateGC (SDL_Display, icon_pixmap, 0, &GCvalues); 202 gc = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
203 XPutImage (SDL_Display, icon_pixmap, gc, icon_image, 203 XPutImage(SDL_Display, icon_pixmap, gc, icon_image,
204 0, 0, 0, 0, sicon->w, sicon->h); 204 0, 0, 0, 0, sicon->w, sicon->h);
205 XFreeGC (SDL_Display, gc); 205 XFreeGC(SDL_Display, gc);
206 XDestroyImage (icon_image); 206 XDestroyImage(icon_image);
207 SDL_free (LSBmask); 207 SDL_free(LSBmask);
208 sicon->pixels = NULL; 208 sicon->pixels = NULL;
209 209
210 /* Some buggy window managers (some versions of Enlightenment, it 210 /* Some buggy window managers (some versions of Enlightenment, it
211 seems) need an icon window *and* icon pixmap to work properly, while 211 seems) need an icon window *and* icon pixmap to work properly, while
212 it screws up others. The default is only to use a pixmap. */ 212 it screws up others. The default is only to use a pixmap. */
213 p = SDL_getenv ("SDL_VIDEO_X11_ICONWIN"); 213 p = SDL_getenv("SDL_VIDEO_X11_ICONWIN");
214 if (p && *p) { 214 if (p && *p) {
215 icon_window = XCreateSimpleWindow (SDL_Display, SDL_Root, 215 icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
216 0, 0, sicon->w, sicon->h, 0, 216 0, 0, sicon->w, sicon->h, 0,
217 CopyFromParent, CopyFromParent); 217 CopyFromParent, CopyFromParent);
218 XSetWindowBackgroundPixmap (SDL_Display, icon_window, icon_pixmap); 218 XSetWindowBackgroundPixmap(SDL_Display, icon_window, icon_pixmap);
219 XClearWindow (SDL_Display, icon_window); 219 XClearWindow(SDL_Display, icon_window);
220 } 220 }
221 221
222 /* Set the window icon to the icon pixmap (and icon window) */ 222 /* Set the window icon to the icon pixmap (and icon window) */
223 wmhints = XAllocWMHints (); 223 wmhints = XAllocWMHints();
224 wmhints->flags = (IconPixmapHint | IconMaskHint); 224 wmhints->flags = (IconPixmapHint | IconMaskHint);
225 wmhints->icon_pixmap = icon_pixmap; 225 wmhints->icon_pixmap = icon_pixmap;
226 wmhints->icon_mask = mask_pixmap; 226 wmhints->icon_mask = mask_pixmap;
227 if (icon_window != None) { 227 if (icon_window != None) {
228 wmhints->flags |= IconWindowHint; 228 wmhints->flags |= IconWindowHint;
229 wmhints->icon_window = icon_window; 229 wmhints->icon_window = icon_window;
230 } 230 }
231 XSetWMHints (SDL_Display, WMwindow, wmhints); 231 XSetWMHints(SDL_Display, WMwindow, wmhints);
232 XFree (wmhints); 232 XFree(wmhints);
233 XSync (SDL_Display, False); 233 XSync(SDL_Display, False);
234 234
235 done: 235 done:
236 SDL_Unlock_EventThread (); 236 SDL_Unlock_EventThread();
237 SDL_FreeSurface (sicon); 237 SDL_FreeSurface(sicon);
238 } 238 }
239 239
240 void 240 void
241 X11_SetCaptionNoLock (_THIS, const char *title, const char *icon) 241 X11_SetCaptionNoLock(_THIS, const char *title, const char *icon)
242 { 242 {
243 XTextProperty titleprop, iconprop; 243 XTextProperty titleprop, iconprop;
244 Status status; 244 Status status;
245 245
246 #ifdef X_HAVE_UTF8_STRING 246 #ifdef X_HAVE_UTF8_STRING
247 Atom _NET_WM_NAME; 247 Atom _NET_WM_NAME;
248 Atom _NET_WM_ICON_NAME; 248 Atom _NET_WM_ICON_NAME;
249 249
250 /* Look up some useful Atoms */ 250 /* Look up some useful Atoms */
251 if (SDL_X11_HAVE_UTF8) { 251 if (SDL_X11_HAVE_UTF8) {
252 _NET_WM_NAME = XInternAtom (SDL_Display, "_NET_WM_NAME", False); 252 _NET_WM_NAME = XInternAtom(SDL_Display, "_NET_WM_NAME", False);
253 _NET_WM_ICON_NAME = 253 _NET_WM_ICON_NAME =
254 XInternAtom (SDL_Display, "_NET_WM_ICON_NAME", False); 254 XInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False);
255 } 255 }
256 #endif 256 #endif
257 257
258 if (title != NULL) { 258 if (title != NULL) {
259 char *title_latin1 = SDL_iconv_utf8_latin1 ((char *) title); 259 char *title_latin1 = SDL_iconv_utf8_latin1((char *) title);
260 if (!title_latin1) { 260 if (!title_latin1) {
261 SDL_OutOfMemory (); 261 SDL_OutOfMemory();
262 return; 262 return;
263 } 263 }
264 status = XStringListToTextProperty (&title_latin1, 1, &titleprop); 264 status = XStringListToTextProperty(&title_latin1, 1, &titleprop);
265 SDL_free (title_latin1); 265 SDL_free(title_latin1);
266 if (status) { 266 if (status) {
267 XSetTextProperty (SDL_Display, WMwindow, &titleprop, XA_WM_NAME); 267 XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
268 XFree (titleprop.value); 268 XFree(titleprop.value);
269 } 269 }
270 #ifdef X_HAVE_UTF8_STRING 270 #ifdef X_HAVE_UTF8_STRING
271 if (SDL_X11_HAVE_UTF8) { 271 if (SDL_X11_HAVE_UTF8) {
272 status = Xutf8TextListToTextProperty (SDL_Display, 272 status = Xutf8TextListToTextProperty(SDL_Display,
273 (char **) &title, 1, 273 (char **) &title, 1,
274 XUTF8StringStyle, 274 XUTF8StringStyle,
275 &titleprop); 275 &titleprop);
276 if (status == Success) { 276 if (status == Success) {
277 XSetTextProperty (SDL_Display, WMwindow, &titleprop, 277 XSetTextProperty(SDL_Display, WMwindow, &titleprop,
278 _NET_WM_NAME); 278 _NET_WM_NAME);
279 XFree (titleprop.value); 279 XFree(titleprop.value);
280 } 280 }
281 } 281 }
282 #endif 282 #endif
283 } 283 }
284 if (icon != NULL) { 284 if (icon != NULL) {
285 char *icon_latin1 = SDL_iconv_utf8_latin1 ((char *) icon); 285 char *icon_latin1 = SDL_iconv_utf8_latin1((char *) icon);
286 if (!icon_latin1) { 286 if (!icon_latin1) {
287 SDL_OutOfMemory (); 287 SDL_OutOfMemory();
288 return; 288 return;
289 } 289 }
290 status = XStringListToTextProperty (&icon_latin1, 1, &iconprop); 290 status = XStringListToTextProperty(&icon_latin1, 1, &iconprop);
291 SDL_free (icon_latin1); 291 SDL_free(icon_latin1);
292 if (status) { 292 if (status) {
293 XSetTextProperty (SDL_Display, WMwindow, &iconprop, 293 XSetTextProperty(SDL_Display, WMwindow, &iconprop,
294 XA_WM_ICON_NAME); 294 XA_WM_ICON_NAME);
295 XFree (iconprop.value); 295 XFree(iconprop.value);
296 } 296 }
297 #ifdef X_HAVE_UTF8_STRING 297 #ifdef X_HAVE_UTF8_STRING
298 if (SDL_X11_HAVE_UTF8) { 298 if (SDL_X11_HAVE_UTF8) {
299 status = Xutf8TextListToTextProperty (SDL_Display, 299 status = Xutf8TextListToTextProperty(SDL_Display,
300 (char **) &icon, 1, 300 (char **) &icon, 1,
301 XUTF8StringStyle, 301 XUTF8StringStyle, &iconprop);
302 &iconprop);
303 if (status == Success) { 302 if (status == Success) {
304 XSetTextProperty (SDL_Display, WMwindow, &iconprop, 303 XSetTextProperty(SDL_Display, WMwindow, &iconprop,
305 _NET_WM_ICON_NAME); 304 _NET_WM_ICON_NAME);
306 XFree (iconprop.value); 305 XFree(iconprop.value);
307 } 306 }
308 } 307 }
309 #endif 308 #endif
310 } 309 }
311 XSync (SDL_Display, False); 310 XSync(SDL_Display, False);
312 } 311 }
313 312
314 void 313 void
315 X11_SetCaption (_THIS, const char *title, const char *icon) 314 X11_SetCaption(_THIS, const char *title, const char *icon)
316 { 315 {
317 SDL_Lock_EventThread (); 316 SDL_Lock_EventThread();
318 X11_SetCaptionNoLock (this, title, icon); 317 X11_SetCaptionNoLock(this, title, icon);
319 SDL_Unlock_EventThread (); 318 SDL_Unlock_EventThread();
320 } 319 }
321 320
322 /* Iconify the window */ 321 /* Iconify the window */
323 int 322 int
324 X11_IconifyWindow (_THIS) 323 X11_IconifyWindow(_THIS)
325 { 324 {
326 int result; 325 int result;
327 326
328 SDL_Lock_EventThread (); 327 SDL_Lock_EventThread();
329 result = XIconifyWindow (SDL_Display, WMwindow, SDL_Screen); 328 result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
330 XSync (SDL_Display, False); 329 XSync(SDL_Display, False);
331 SDL_Unlock_EventThread (); 330 SDL_Unlock_EventThread();
332 return (result); 331 return (result);
333 } 332 }
334 333
335 SDL_GrabMode 334 SDL_GrabMode
336 X11_GrabInputNoLock (_THIS, SDL_GrabMode mode) 335 X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
337 { 336 {
338 int result; 337 int result;
339 338
340 if (SDL_VideoSurface == NULL) { 339 if (SDL_VideoSurface == NULL) {
341 return (SDL_GRAB_OFF); 340 return (SDL_GRAB_OFF);
342 } 341 }
343 if (!SDL_Window) { 342 if (!SDL_Window) {
344 return (mode); /* Will be set later on mode switch */ 343 return (mode); /* Will be set later on mode switch */
345 } 344 }
346 if (mode == SDL_GRAB_OFF) { 345 if (mode == SDL_GRAB_OFF) {
347 XUngrabPointer (SDL_Display, CurrentTime); 346 XUngrabPointer(SDL_Display, CurrentTime);
348 XUngrabKeyboard (SDL_Display, CurrentTime); 347 XUngrabKeyboard(SDL_Display, CurrentTime);
349 } else { 348 } else {
350 if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { 349 if (SDL_VideoSurface->flags & SDL_FULLSCREEN) {
351 /* Unbind the mouse from the fullscreen window */ 350 /* Unbind the mouse from the fullscreen window */
352 XUngrabPointer (SDL_Display, CurrentTime); 351 XUngrabPointer(SDL_Display, CurrentTime);
353 } 352 }
354 /* Try to grab the mouse */ 353 /* Try to grab the mouse */
355 #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */ 354 #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
356 for (numtries = 0; numtries < 10; ++numtries) { 355 for (numtries = 0; numtries < 10; ++numtries) {
357 #else 356 #else
358 for (;;) { 357 for (;;) {
359 #endif 358 #endif
360 result = XGrabPointer (SDL_Display, SDL_Window, True, 0, 359 result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
361 GrabModeAsync, GrabModeAsync, 360 GrabModeAsync, GrabModeAsync,
362 SDL_Window, None, CurrentTime); 361 SDL_Window, None, CurrentTime);
363 if (result == GrabSuccess) { 362 if (result == GrabSuccess) {
364 break; 363 break;
365 } 364 }
366 SDL_Delay (100); 365 SDL_Delay(100);
367 } 366 }
368 if (result != GrabSuccess) { 367 if (result != GrabSuccess) {
369 /* Uh, oh, what do we do here? */ ; 368 /* Uh, oh, what do we do here? */ ;
370 } 369 }
371 /* Now grab the keyboard */ 370 /* Now grab the keyboard */
372 XGrabKeyboard (SDL_Display, WMwindow, True, 371 XGrabKeyboard(SDL_Display, WMwindow, True,
373 GrabModeAsync, GrabModeAsync, CurrentTime); 372 GrabModeAsync, GrabModeAsync, CurrentTime);
374 373
375 /* Raise the window if we grab the mouse */ 374 /* Raise the window if we grab the mouse */
376 if (!(SDL_VideoSurface->flags & SDL_FULLSCREEN)) 375 if (!(SDL_VideoSurface->flags & SDL_FULLSCREEN))
377 XRaiseWindow (SDL_Display, WMwindow); 376 XRaiseWindow(SDL_Display, WMwindow);
378 377
379 /* Make sure we register input focus */ 378 /* Make sure we register input focus */
380 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); 379 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
381 } 380 }
382 XSync (SDL_Display, False); 381 XSync(SDL_Display, False);
383 382
384 return (mode); 383 return (mode);
385 } 384 }
386 385
387 SDL_GrabMode 386 SDL_GrabMode
388 X11_GrabInput (_THIS, SDL_GrabMode mode) 387 X11_GrabInput(_THIS, SDL_GrabMode mode)
389 { 388 {
390 SDL_Lock_EventThread (); 389 SDL_Lock_EventThread();
391 mode = X11_GrabInputNoLock (this, mode); 390 mode = X11_GrabInputNoLock(this, mode);
392 SDL_Unlock_EventThread (); 391 SDL_Unlock_EventThread();
393 392
394 return (mode); 393 return (mode);
395 } 394 }
396 395
397 /* If 'info' is the right version, this function fills it and returns 1. 396 /* If 'info' is the right version, this function fills it and returns 1.
398 Otherwise, in case of a version mismatch, it returns -1. 397 Otherwise, in case of a version mismatch, it returns -1.
399 */ 398 */
400 static void 399 static void
401 lock_display (void) 400 lock_display(void)
402 { 401 {
403 SDL_Lock_EventThread (); 402 SDL_Lock_EventThread();
404 } 403 }
405 static void 404 static void
406 unlock_display (void) 405 unlock_display(void)
407 { 406 {
408 /* Make sure any X11 transactions are completed */ 407 /* Make sure any X11 transactions are completed */
409 SDL_VideoDevice *this = current_video; 408 SDL_VideoDevice *this = current_video;
410 XSync (SDL_Display, False); 409 XSync(SDL_Display, False);
411 SDL_Unlock_EventThread (); 410 SDL_Unlock_EventThread();
412 } 411 }
413 412
414 int 413 int
415 X11_GetWMInfo (_THIS, SDL_SysWMinfo * info) 414 X11_GetWMInfo(_THIS, SDL_SysWMinfo * info)
416 { 415 {
417 if (info->version.major <= SDL_MAJOR_VERSION) { 416 if (info->version.major <= SDL_MAJOR_VERSION) {
418 info->subsystem = SDL_SYSWM_X11; 417 info->subsystem = SDL_SYSWM_X11;
419 info->info.x11.display = SDL_Display; 418 info->info.x11.display = SDL_Display;
420 info->info.x11.window = SDL_Window; 419 info->info.x11.window = SDL_Window;
421 if (SDL_VERSIONNUM (info->version.major, 420 if (SDL_VERSIONNUM(info->version.major,
422 info->version.minor, 421 info->version.minor,
423 info->version.patch) >= 1002) { 422 info->version.patch) >= 1002) {
424 info->info.x11.fswindow = FSwindow; 423 info->info.x11.fswindow = FSwindow;
425 info->info.x11.wmwindow = WMwindow; 424 info->info.x11.wmwindow = WMwindow;
426 } 425 }
427 info->info.x11.lock_func = lock_display; 426 info->info.x11.lock_func = lock_display;
428 info->info.x11.unlock_func = unlock_display; 427 info->info.x11.unlock_func = unlock_display;
429 return (1); 428 return (1);
430 } else { 429 } else {
431 SDL_SetError ("Application not compiled with SDL %d.%d\n", 430 SDL_SetError("Application not compiled with SDL %d.%d\n",
432 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); 431 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
433 return (-1); 432 return (-1);
434 } 433 }
435 } 434 }
436 435
437 /* vi: set ts=4 sw=4 expandtab: */ 436 /* vi: set ts=4 sw=4 expandtab: */