Commit 572d530a authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #196

Use the title and icon stored in the SDL video info, when creating X11 windows.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401726
parent 732fcc2a
...@@ -311,18 +311,13 @@ static char *get_classname(char *classname, int maxlen) ...@@ -311,18 +311,13 @@ static char *get_classname(char *classname, int maxlen)
static void create_aux_windows(_THIS) static void create_aux_windows(_THIS)
{ {
int x = 0, y = 0; int x = 0, y = 0;
Atom _NET_WM_NAME;
Atom _NET_WM_ICON_NAME;
char classname[1024]; char classname[1024];
XSetWindowAttributes xattr; XSetWindowAttributes xattr;
XWMHints *hints; XWMHints *hints;
XTextProperty titleprop, titlepropUTF8, iconprop, iconpropUTF8;
int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)); int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen));
/* Look up some useful Atoms */ /* Look up some useful Atoms */
WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
_NET_WM_NAME = XInternAtom(SDL_Display, "_NET_WM_NAME", False);
_NET_WM_ICON_NAME = XInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False);
/* Don't create any extra windows if we are being managed */ /* Don't create any extra windows if we are being managed */
if ( SDL_windowid ) { if ( SDL_windowid ) {
...@@ -372,15 +367,9 @@ static void create_aux_windows(_THIS) ...@@ -372,15 +367,9 @@ static void create_aux_windows(_THIS)
} }
hints = NULL; hints = NULL;
titleprop.value = titlepropUTF8.value = NULL;
iconprop.value = iconpropUTF8.value = NULL;
if(WMwindow) { if(WMwindow) {
/* All window attributes must survive the recreation */ /* All window attributes must survive the recreation */
hints = XGetWMHints(SDL_Display, WMwindow); hints = XGetWMHints(SDL_Display, WMwindow);
XGetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
XGetTextProperty(SDL_Display, WMwindow, &titlepropUTF8, _NET_WM_NAME);
XGetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
XGetTextProperty(SDL_Display, WMwindow, &iconpropUTF8, _NET_WM_ICON_NAME);
XDestroyWindow(SDL_Display, WMwindow); XDestroyWindow(SDL_Display, WMwindow);
} }
...@@ -400,22 +389,7 @@ static void create_aux_windows(_THIS) ...@@ -400,22 +389,7 @@ static void create_aux_windows(_THIS)
} }
XSetWMHints(SDL_Display, WMwindow, hints); XSetWMHints(SDL_Display, WMwindow, hints);
XFree(hints); XFree(hints);
if(titleprop.value) { X11_SetCaptionNoLock(this, this->wm_title, this->wm_icon);
XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
XFree(titleprop.value);
}
if(titlepropUTF8.value) {
XSetTextProperty(SDL_Display, WMwindow, &titlepropUTF8, _NET_WM_NAME);
XFree(titlepropUTF8.value);
}
if(iconprop.value) {
XSetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
XFree(iconprop.value);
}
if(iconpropUTF8.value) {
XSetTextProperty(SDL_Display, WMwindow, &iconpropUTF8, _NET_WM_ICON_NAME);
XFree(iconpropUTF8.value);
}
XSelectInput(SDL_Display, WMwindow, XSelectInput(SDL_Display, WMwindow,
FocusChangeMask | KeyPressMask | KeyReleaseMask FocusChangeMask | KeyPressMask | KeyReleaseMask
......
...@@ -240,7 +240,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -240,7 +240,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
SDL_FreeSurface(sicon); SDL_FreeSurface(sicon);
} }
void X11_SetCaption(_THIS, const char *title, const char *icon) void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon)
{ {
XTextProperty titleprop, iconprop; XTextProperty titleprop, iconprop;
Status status; Status status;
...@@ -256,9 +256,6 @@ void X11_SetCaption(_THIS, const char *title, const char *icon) ...@@ -256,9 +256,6 @@ void X11_SetCaption(_THIS, const char *title, const char *icon)
} }
#endif #endif
/* Lock the event thread, in multi-threading environments */
SDL_Lock_EventThread();
if ( title != NULL ) { if ( title != NULL ) {
char *title_latin1 = SDL_iconv_utf8_latin1((char *)title); char *title_latin1 = SDL_iconv_utf8_latin1((char *)title);
if ( !title_latin1 ) { if ( !title_latin1 ) {
...@@ -306,7 +303,12 @@ void X11_SetCaption(_THIS, const char *title, const char *icon) ...@@ -306,7 +303,12 @@ void X11_SetCaption(_THIS, const char *title, const char *icon)
#endif #endif
} }
XSync(SDL_Display, False); XSync(SDL_Display, False);
}
void X11_SetCaption(_THIS, const char *title, const char *icon)
{
SDL_Lock_EventThread();
X11_SetCaptionNoLock(this, title, icon);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
...@@ -332,13 +334,6 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -332,13 +334,6 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
if ( ! SDL_Window ) { if ( ! SDL_Window ) {
return(mode); /* Will be set later on mode switch */ return(mode); /* Will be set later on mode switch */
} }
#if SDL_VIDEO_DRIVER_X11_XINERAMA
/* FIXME: Is this okay?
if ( use_xinerama ) {
mode &= ~SDL_GRAB_FULLSCREEN;
}
*/
#endif
if ( mode == SDL_GRAB_OFF ) { if ( mode == SDL_GRAB_OFF ) {
XUngrabPointer(SDL_Display, CurrentTime); XUngrabPointer(SDL_Display, CurrentTime);
XUngrabKeyboard(SDL_Display, CurrentTime); XUngrabKeyboard(SDL_Display, CurrentTime);
...@@ -351,7 +346,7 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -351,7 +346,7 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
#if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */ #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
for ( numtries = 0; numtries < 10; ++numtries ) { for ( numtries = 0; numtries < 10; ++numtries ) {
#else #else
while ( 1 ) { for ( ; ; ) {
#endif #endif
result = XGrabPointer(SDL_Display, SDL_Window, True, 0, result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "SDL_x11video.h" #include "SDL_x11video.h"
/* Functions to be exported */ /* Functions to be exported */
extern void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon);
extern void X11_SetCaption(_THIS, const char *title, const char *icon); extern void X11_SetCaption(_THIS, const char *title, const char *icon);
extern void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask); extern void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
extern int X11_IconifyWindow(_THIS); extern int X11_IconifyWindow(_THIS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment