comparison src/video/x11/SDL_x11video.c @ 1659:14717b52abc0 SDL-1.3

Merge trunk-1.3-3
author Sam Lantinga <slouken@libsdl.org>
date Wed, 17 May 2006 08:18:28 +0000
parents e49147870aac
children 782fd950bd46
comparison
equal deleted inserted replaced
1658:e49147870aac 1659:14717b52abc0
195 */ 195 */
196 if ( (vm_error >= 0) && 196 if ( (vm_error >= 0) &&
197 (((e->error_code == BadRequest)&&(e->request_code == vm_error)) || 197 (((e->error_code == BadRequest)&&(e->request_code == vm_error)) ||
198 ((e->error_code > vm_error) && 198 ((e->error_code > vm_error) &&
199 (e->error_code <= (vm_error+XF86VidModeNumberErrors)))) ) { 199 (e->error_code <= (vm_error+XF86VidModeNumberErrors)))) ) {
200 #ifdef XFREE86_DEBUG 200 #ifdef X11_DEBUG
201 { char errmsg[1024]; 201 { char errmsg[1024];
202 XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg)); 202 XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
203 printf("VidMode error: %s\n", errmsg); 203 printf("VidMode error: %s\n", errmsg);
204 } 204 }
205 #endif 205 #endif
210 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE 210 #if SDL_VIDEO_DRIVER_X11_DGAMOUSE
211 /* DGA errors can be non-fatal. :) */ 211 /* DGA errors can be non-fatal. :) */
212 if ( (dga_error >= 0) && 212 if ( (dga_error >= 0) &&
213 ((e->error_code > dga_error) && 213 ((e->error_code > dga_error) &&
214 (e->error_code <= (dga_error+XF86DGANumberErrors))) ) { 214 (e->error_code <= (dga_error+XF86DGANumberErrors))) ) {
215 #ifdef XFREE86_DEBUG 215 #ifdef X11_DEBUG
216 { char errmsg[1024]; 216 { char errmsg[1024];
217 XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg)); 217 XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
218 printf("DGA error: %s\n", errmsg); 218 printf("DGA error: %s\n", errmsg);
219 } 219 }
220 #endif 220 #endif
242 } 242 }
243 243
244 static int (*Xext_handler)(Display *, _Xconst char *, _Xconst char *) = NULL; 244 static int (*Xext_handler)(Display *, _Xconst char *, _Xconst char *) = NULL;
245 static int xext_errhandler(Display *d, _Xconst char *ext, _Xconst char *reason) 245 static int xext_errhandler(Display *d, _Xconst char *ext, _Xconst char *reason)
246 { 246 {
247 #ifdef XFREE86_DEBUG 247 #ifdef X11_DEBUG
248 printf("Xext error inside SDL (may be harmless):\n"); 248 printf("Xext error inside SDL (may be harmless):\n");
249 printf(" Extension \"%s\" %s on display \"%s\".\n", 249 printf(" Extension \"%s\" %s on display \"%s\".\n",
250 ext, reason, XDisplayString(d)); 250 ext, reason, XDisplayString(d));
251 #endif 251 #endif
252 252
308 } 308 }
309 309
310 /* Create auxiliary (toplevel) windows with the current visual */ 310 /* Create auxiliary (toplevel) windows with the current visual */
311 static void create_aux_windows(_THIS) 311 static void create_aux_windows(_THIS)
312 { 312 {
313 Atom _NET_WM_NAME; 313 int x = 0, y = 0;
314 Atom _NET_WM_ICON_NAME;
315 char classname[1024]; 314 char classname[1024];
316 XSetWindowAttributes xattr; 315 XSetWindowAttributes xattr;
317 XWMHints *hints; 316 XWMHints *hints;
318 XTextProperty titleprop, titlepropUTF8, iconprop, iconpropUTF8;
319 int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)); 317 int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen));
320 318
321 /* Look up some useful Atoms */ 319 /* Look up some useful Atoms */
322 WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); 320 WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
323 _NET_WM_NAME = XInternAtom(SDL_Display, "_NET_WM_NAME", False);
324 _NET_WM_ICON_NAME = XInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False);
325 321
326 /* Don't create any extra windows if we are being managed */ 322 /* Don't create any extra windows if we are being managed */
327 if ( SDL_windowid ) { 323 if ( SDL_windowid ) {
328 FSwindow = 0; 324 FSwindow = 0;
329 WMwindow = SDL_strtol(SDL_windowid, NULL, 0); 325 WMwindow = SDL_strtol(SDL_windowid, NULL, 0);
331 } 327 }
332 328
333 if(FSwindow) 329 if(FSwindow)
334 XDestroyWindow(SDL_Display, FSwindow); 330 XDestroyWindow(SDL_Display, FSwindow);
335 331
332 #if SDL_VIDEO_DRIVER_X11_VIDMODE
333 if ( use_xinerama ) {
334 x = xinerama_info.x_org;
335 y = xinerama_info.y_org;
336 }
337 #endif
336 xattr.override_redirect = True; 338 xattr.override_redirect = True;
337 xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0; 339 xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0;
338 xattr.border_pixel = 0; 340 xattr.border_pixel = 0;
339 xattr.colormap = SDL_XColorMap; 341 xattr.colormap = SDL_XColorMap;
340 342
341 FSwindow = XCreateWindow(SDL_Display, SDL_Root, 343 FSwindow = XCreateWindow(SDL_Display, SDL_Root,
342 xinerama_x, xinerama_y, 32, 32, 0, 344 x, y, 32, 32, 0,
343 this->hidden->depth, InputOutput, SDL_Visual, 345 this->hidden->depth, InputOutput, SDL_Visual,
344 CWOverrideRedirect | CWBackPixel | CWBorderPixel 346 CWOverrideRedirect | CWBackPixel | CWBorderPixel
345 | CWColormap, 347 | CWColormap,
346 &xattr); 348 &xattr);
347 349
363 mask = SubstructureRedirectMask; 365 mask = SubstructureRedirectMask;
364 XSendEvent(SDL_Display, SDL_Root, False, mask, &ev); 366 XSendEvent(SDL_Display, SDL_Root, False, mask, &ev);
365 } 367 }
366 368
367 hints = NULL; 369 hints = NULL;
368 titleprop.value = titlepropUTF8.value = NULL;
369 iconprop.value = iconpropUTF8.value = NULL;
370 if(WMwindow) { 370 if(WMwindow) {
371 /* All window attributes must survive the recreation */ 371 /* All window attributes must survive the recreation */
372 hints = XGetWMHints(SDL_Display, WMwindow); 372 hints = XGetWMHints(SDL_Display, WMwindow);
373 XGetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
374 XGetTextProperty(SDL_Display, WMwindow, &titlepropUTF8, _NET_WM_NAME);
375 XGetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
376 XGetTextProperty(SDL_Display, WMwindow, &iconpropUTF8, _NET_WM_ICON_NAME);
377 XDestroyWindow(SDL_Display, WMwindow); 373 XDestroyWindow(SDL_Display, WMwindow);
378 } 374 }
379 375
380 /* Create the window for windowed management */ 376 /* Create the window for windowed management */
381 /* (reusing the xattr structure above) */ 377 /* (reusing the xattr structure above) */
382 WMwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0, 378 WMwindow = XCreateWindow(SDL_Display, SDL_Root,
379 x, y, 32, 32, 0,
383 this->hidden->depth, InputOutput, SDL_Visual, 380 this->hidden->depth, InputOutput, SDL_Visual,
384 CWBackPixel | CWBorderPixel | CWColormap, 381 CWBackPixel | CWBorderPixel | CWColormap,
385 &xattr); 382 &xattr);
386 383
387 /* Set the input hints so we get keyboard input */ 384 /* Set the input hints so we get keyboard input */
390 hints->input = True; 387 hints->input = True;
391 hints->flags = InputHint; 388 hints->flags = InputHint;
392 } 389 }
393 XSetWMHints(SDL_Display, WMwindow, hints); 390 XSetWMHints(SDL_Display, WMwindow, hints);
394 XFree(hints); 391 XFree(hints);
395 if(titleprop.value) { 392 X11_SetCaptionNoLock(this, this->wm_title, this->wm_icon);
396 XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
397 XFree(titleprop.value);
398 }
399 if(titlepropUTF8.value) {
400 XSetTextProperty(SDL_Display, WMwindow, &titlepropUTF8, _NET_WM_NAME);
401 XFree(titlepropUTF8.value);
402 }
403 if(iconprop.value) {
404 XSetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
405 XFree(iconprop.value);
406 }
407 if(iconpropUTF8.value) {
408 XSetTextProperty(SDL_Display, WMwindow, &iconpropUTF8, _NET_WM_ICON_NAME);
409 XFree(iconpropUTF8.value);
410 }
411 393
412 XSelectInput(SDL_Display, WMwindow, 394 XSelectInput(SDL_Display, WMwindow,
413 FocusChangeMask | KeyPressMask | KeyReleaseMask 395 FocusChangeMask | KeyPressMask | KeyReleaseMask
414 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask); 396 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask);
415 397
559 } 541 }
560 if ( this->hidden->depth == 32 ) { 542 if ( this->hidden->depth == 32 ) {
561 vformat->Amask = (0xFFFFFFFF & ~(vformat->Rmask|vformat->Gmask|vformat->Bmask)); 543 vformat->Amask = (0xFFFFFFFF & ~(vformat->Rmask|vformat->Gmask|vformat->Bmask));
562 } 544 }
563 X11_SaveVidModeGamma(this); 545 X11_SaveVidModeGamma(this);
546
547 /* Save DPMS and screensaver settings */
548 X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled);
549 X11_DisableScreenSaver(SDL_Display);
564 550
565 /* See if we have been passed a window to use */ 551 /* See if we have been passed a window to use */
566 SDL_windowid = SDL_getenv("SDL_WINDOWID"); 552 SDL_windowid = SDL_getenv("SDL_WINDOWID");
567 553
568 /* Create the fullscreen and managed windows */ 554 /* Create the fullscreen and managed windows */
1380 } 1366 }
1381 } 1367 }
1382 SDL_free(SDL_iconcolors); 1368 SDL_free(SDL_iconcolors);
1383 SDL_iconcolors = NULL; 1369 SDL_iconcolors = NULL;
1384 } 1370 }
1371
1385 /* Restore gamma settings if they've changed */ 1372 /* Restore gamma settings if they've changed */
1386 if ( SDL_GetAppState() & SDL_APPACTIVE ) { 1373 if ( SDL_GetAppState() & SDL_APPACTIVE ) {
1387 X11_SwapVidModeGamma(this); 1374 X11_SwapVidModeGamma(this);
1388 } 1375 }
1376
1377 /* Restore DPMS and screensaver settings */
1378 X11_RestoreScreenSaver(SDL_Display, screensaver_timeout, dpms_enabled);
1389 1379
1390 /* Free that blank cursor */ 1380 /* Free that blank cursor */
1391 if ( SDL_BlankCursor != NULL ) { 1381 if ( SDL_BlankCursor != NULL ) {
1392 this->FreeWMCursor(this, SDL_BlankCursor); 1382 this->FreeWMCursor(this, SDL_BlankCursor);
1393 SDL_BlankCursor = NULL; 1383 SDL_BlankCursor = NULL;