[Commits] SDL: x11: Fix message box titles with Unicode chars on some wind...

libsdl.org revision control commits-owner at libsdl.org
Sat Aug 12 21:58:47 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/931e9d3a452e
changeset: 11259:931e9d3a452e
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Sun Aug 13 00:58:23 2017 -0400
description:
x11: Fix message box titles with Unicode chars on some window managers.

Fixes Bugzilla #2971.

diffstat:

 src/video/x11/SDL_x11messagebox.c |  31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r 9fc2e83124ba -r 931e9d3a452e src/video/x11/SDL_x11messagebox.c
--- a/src/video/x11/SDL_x11messagebox.c	Sat Aug 12 20:25:49 2017 -0700
+++ b/src/video/x11/SDL_x11messagebox.c	Sun Aug 13 00:58:23 2017 -0400
@@ -378,10 +378,11 @@
     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 =
@@ -414,10 +415,30 @@
 
     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);


More information about the commits mailing list