Browse Source

x11: attempt to fix UTF-8 window titles (see #209)

rdb 1 year ago
parent
commit
a655784d8d

+ 1 - 0
panda/src/x11display/x11GraphicsPipe.cxx

@@ -340,6 +340,7 @@ x11GraphicsPipe(const std::string &display) :
 
 
   // Get some X atom numbers.
   // Get some X atom numbers.
   _wm_delete_window = XInternAtom(_display, "WM_DELETE_WINDOW", false);
   _wm_delete_window = XInternAtom(_display, "WM_DELETE_WINDOW", false);
+  _net_wm_name = XInternAtom(_display, "_NET_WM_NAME", false);
   _net_wm_pid = XInternAtom(_display, "_NET_WM_PID", false);
   _net_wm_pid = XInternAtom(_display, "_NET_WM_PID", false);
   _net_wm_window_type = XInternAtom(_display, "_NET_WM_WINDOW_TYPE", false);
   _net_wm_window_type = XInternAtom(_display, "_NET_WM_WINDOW_TYPE", false);
   _net_wm_window_type_splash = XInternAtom(_display, "_NET_WM_WINDOW_TYPE_SPLASH", false);
   _net_wm_window_type_splash = XInternAtom(_display, "_NET_WM_WINDOW_TYPE_SPLASH", false);

+ 1 - 0
panda/src/x11display/x11GraphicsPipe.h

@@ -125,6 +125,7 @@ public:
 public:
 public:
   // Atom specifications.
   // Atom specifications.
   Atom _wm_delete_window;
   Atom _wm_delete_window;
+  Atom _net_wm_name;
   Atom _net_wm_pid;
   Atom _net_wm_pid;
   Atom _net_wm_window_type;
   Atom _net_wm_window_type;
   Atom _net_wm_window_type_splash;
   Atom _net_wm_window_type_splash;

+ 9 - 0
panda/src/x11display/x11GraphicsWindow.cxx

@@ -1188,6 +1188,15 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) {
     if (XStringListToTextProperty((char **)&name, 1, &window_name) != 0) {
     if (XStringListToTextProperty((char **)&name, 1, &window_name) != 0) {
       window_name_p = &window_name;
       window_name_p = &window_name;
     }
     }
+
+#ifdef X_HAVE_UTF8_STRING
+    XTextProperty wm_name;
+    if (Xutf8TextListToTextProperty(_display, (char **)&name, 1,
+                                    XUTF8StringStyle, &wm_name) == Success) {
+      XSetTextProperty(_display, _xwindow, &wm_name, x11_pipe->_net_wm_name);
+      XFree(wm_name.value);
+    }
+#endif
   }
   }
 
 
   // The size hints request a window of a particular size andor a particular
   // The size hints request a window of a particular size andor a particular