Fixed bug #196
authorSam Lantinga <slouken@libsdl.org>
Fri, 05 May 2006 05:09:10 +0000
changeset 1767ae9f6be81810
parent 1766 410b1ed7fe28
child 1768 814f9f2c7a33
Fixed bug #196

Use the title and icon stored in the SDL video info, when creating X11 windows.
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11wm.c
src/video/x11/SDL_x11wm_c.h
     1.1 --- a/src/video/x11/SDL_x11video.c	Thu May 04 16:52:53 2006 +0000
     1.2 +++ b/src/video/x11/SDL_x11video.c	Fri May 05 05:09:10 2006 +0000
     1.3 @@ -311,18 +311,13 @@
     1.4  static void create_aux_windows(_THIS)
     1.5  {
     1.6      int x = 0, y = 0;
     1.7 -    Atom _NET_WM_NAME;
     1.8 -    Atom _NET_WM_ICON_NAME;
     1.9      char classname[1024];
    1.10      XSetWindowAttributes xattr;
    1.11      XWMHints *hints;
    1.12 -    XTextProperty titleprop, titlepropUTF8, iconprop, iconpropUTF8;
    1.13      int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen));
    1.14  
    1.15      /* Look up some useful Atoms */
    1.16      WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
    1.17 -    _NET_WM_NAME = XInternAtom(SDL_Display, "_NET_WM_NAME", False);
    1.18 -    _NET_WM_ICON_NAME = XInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False);
    1.19  
    1.20      /* Don't create any extra windows if we are being managed */
    1.21      if ( SDL_windowid ) {
    1.22 @@ -372,15 +367,9 @@
    1.23      }
    1.24  
    1.25      hints = NULL;
    1.26 -    titleprop.value = titlepropUTF8.value = NULL;
    1.27 -    iconprop.value = iconpropUTF8.value = NULL;
    1.28      if(WMwindow) {
    1.29  	/* All window attributes must survive the recreation */
    1.30  	hints = XGetWMHints(SDL_Display, WMwindow);
    1.31 -	XGetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
    1.32 -	XGetTextProperty(SDL_Display, WMwindow, &titlepropUTF8, _NET_WM_NAME);
    1.33 -	XGetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
    1.34 -	XGetTextProperty(SDL_Display, WMwindow, &iconpropUTF8, _NET_WM_ICON_NAME);
    1.35  	XDestroyWindow(SDL_Display, WMwindow);
    1.36      }
    1.37  
    1.38 @@ -400,22 +389,7 @@
    1.39      }
    1.40      XSetWMHints(SDL_Display, WMwindow, hints);
    1.41      XFree(hints);
    1.42 -    if(titleprop.value) {
    1.43 -	XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
    1.44 -	XFree(titleprop.value);
    1.45 -    }
    1.46 -    if(titlepropUTF8.value) {
    1.47 -	XSetTextProperty(SDL_Display, WMwindow, &titlepropUTF8, _NET_WM_NAME);
    1.48 -	XFree(titlepropUTF8.value);
    1.49 -    }
    1.50 -    if(iconprop.value) {
    1.51 -	XSetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
    1.52 -	XFree(iconprop.value);
    1.53 -    }
    1.54 -    if(iconpropUTF8.value) {
    1.55 -	XSetTextProperty(SDL_Display, WMwindow, &iconpropUTF8, _NET_WM_ICON_NAME);
    1.56 -	XFree(iconpropUTF8.value);
    1.57 -    }
    1.58 +    X11_SetCaptionNoLock(this, this->wm_title, this->wm_icon);
    1.59  
    1.60      XSelectInput(SDL_Display, WMwindow,
    1.61  		 FocusChangeMask | KeyPressMask | KeyReleaseMask
     2.1 --- a/src/video/x11/SDL_x11wm.c	Thu May 04 16:52:53 2006 +0000
     2.2 +++ b/src/video/x11/SDL_x11wm.c	Fri May 05 05:09:10 2006 +0000
     2.3 @@ -240,7 +240,7 @@
     2.4  	SDL_FreeSurface(sicon);
     2.5  }
     2.6  
     2.7 -void X11_SetCaption(_THIS, const char *title, const char *icon)
     2.8 +void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon)
     2.9  {
    2.10  	XTextProperty titleprop, iconprop;
    2.11  	Status status;
    2.12 @@ -256,9 +256,6 @@
    2.13  	}
    2.14  #endif
    2.15  
    2.16 -	/* Lock the event thread, in multi-threading environments */
    2.17 -	SDL_Lock_EventThread();
    2.18 -
    2.19  	if ( title != NULL ) {
    2.20  		char *title_latin1 = SDL_iconv_utf8_latin1((char *)title);
    2.21  		if ( !title_latin1 ) {
    2.22 @@ -306,7 +303,12 @@
    2.23  #endif
    2.24  	}
    2.25  	XSync(SDL_Display, False);
    2.26 +}
    2.27  
    2.28 +void X11_SetCaption(_THIS, const char *title, const char *icon)
    2.29 +{
    2.30 +	SDL_Lock_EventThread();
    2.31 +	X11_SetCaptionNoLock(this, title, icon);
    2.32  	SDL_Unlock_EventThread();
    2.33  }
    2.34  
    2.35 @@ -332,13 +334,6 @@
    2.36  	if ( ! SDL_Window ) {
    2.37  		return(mode);	/* Will be set later on mode switch */
    2.38  	}
    2.39 -#if SDL_VIDEO_DRIVER_X11_XINERAMA
    2.40 -        /* FIXME: Is this okay?
    2.41 -        if ( use_xinerama ) {
    2.42 -            mode &= ~SDL_GRAB_FULLSCREEN;
    2.43 -        }
    2.44 -        */
    2.45 -#endif
    2.46  	if ( mode == SDL_GRAB_OFF ) {
    2.47  		XUngrabPointer(SDL_Display, CurrentTime);
    2.48  		XUngrabKeyboard(SDL_Display, CurrentTime);
    2.49 @@ -351,7 +346,7 @@
    2.50  #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
    2.51  		for ( numtries = 0; numtries < 10; ++numtries ) {
    2.52  #else
    2.53 -		while ( 1 ) {
    2.54 +		for ( ; ; ) {
    2.55  #endif
    2.56  			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
    2.57  						GrabModeAsync, GrabModeAsync,
     3.1 --- a/src/video/x11/SDL_x11wm_c.h	Thu May 04 16:52:53 2006 +0000
     3.2 +++ b/src/video/x11/SDL_x11wm_c.h	Fri May 05 05:09:10 2006 +0000
     3.3 @@ -24,6 +24,7 @@
     3.4  #include "SDL_x11video.h"
     3.5  
     3.6  /* Functions to be exported */
     3.7 +extern void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon);
     3.8  extern void X11_SetCaption(_THIS, const char *title, const char *icon);
     3.9  extern void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
    3.10  extern int X11_IconifyWindow(_THIS);