Skip to content

Commit

Permalink
x11: Fix message box titles with Unicode chars on some window managers.
Browse files Browse the repository at this point in the history
Fixes Bugzilla #2971.
  • Loading branch information
icculus committed Aug 13, 2017
1 parent bfd5a13 commit 0a1b905
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/video/x11/SDL_x11messagebox.c
Expand Up @@ -378,10 +378,11 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
int x, y;
XSizeHints *sizehints;
XSetWindowAttributes wnd_attr;
Atom _NET_WM_WINDOW_TYPE, _NET_WM_WINDOW_TYPE_DIALOG, _NET_WM_NAME, UTF8_STRING;
Atom _NET_WM_WINDOW_TYPE, _NET_WM_WINDOW_TYPE_DIALOG, _NET_WM_NAME;
Display *display = data->display;
SDL_WindowData *windowdata = NULL;
const SDL_MessageBoxData *messageboxdata = data->messageboxdata;
char *title_locale = NULL;

if ( messageboxdata->window ) {
SDL_DisplayData *displaydata =
Expand Down Expand Up @@ -414,10 +415,30 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )

X11_XStoreName( display, data->window, messageboxdata->title );
_NET_WM_NAME = X11_XInternAtom(display, "_NET_WM_NAME", False);
UTF8_STRING = X11_XInternAtom(display, "UTF8_STRING", False);
X11_XChangeProperty(display, data->window, _NET_WM_NAME, UTF8_STRING, 8,
PropModeReplace, (unsigned char *) messageboxdata->title,
strlen(messageboxdata->title) + 1 );

title_locale = SDL_iconv_utf8_locale(messageboxdata->title);
if (title_locale) {
XTextProperty titleprop;
Status status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
SDL_free(title_locale);
if (status) {
X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
X11_XFree(titleprop.value);
}
}

#ifdef X_HAVE_UTF8_STRING
if (SDL_X11_HAVE_UTF8) {
XTextProperty titleprop;
status = X11_Xutf8TextListToTextProperty(display, (char **) &messageboxdata->title, 1,
XUTF8StringStyle, &titleprop);
if (status == Success) {
X11_XSetTextProperty(display, data->window, &titleprop,
_NET_WM_NAME);
X11_XFree(titleprop.value);
}
}
#endif

/* Let the window manager know this is a dialog box */
_NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
Expand Down

0 comments on commit 0a1b905

Please sign in to comment.