Hi all,

I'm sorry to make my first mail to the list a bug report, but I noticed that  
the window title is being set incorrectly, namely by way of the XStoreName() 
function. Unfortunately, that function does not respect the character set of 
the supplied string (which on my system is UTF-8), and sets the WM_NAME 
property to be of type STRING.

OpenBox (the WM I'm using) will then reinterpret the UTF-8 string as being 
Latin1, with the expected results, namely garbage in the title bar.

The patch for that is simple enough for me to provide a patch (apologies for 
additional line breaks, but I'm currently at work and don't have anything 
better than GMX's webmail to send this). The patch also includes build fixes 
(undefined variables) and a warning fixed (setenv() not defined due to a 
feature test macro being undefined):

diff --git a/tabbed.c b/tabbed.c
index a4127db..d35ddf4 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -2,6 +2,7 @@
  * See LICENSE file for copyright and license details.
  */
 
+#define _POSIX_C_SOURCE 200112L
 #include <sys/wait.h>
 #include <locale.h>
 #include <stdarg.h>
@@ -148,13 +149,13 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
 static int bh, wx, wy, ww, wh;
 static unsigned int numlockmask = 0;
 static Bool running = True, nextfocus, doinitspawn = True,
-           fillagain = False, closelastclient = False;
+           fillagain = False, closelastclient = False, npisrelative = False;
 static Display *dpy;
 static DC dc;
 static Atom wmatom[WMLast];
 static Window root, win;
 static Client **clients = NULL;
-static int nclients = 0, sel = -1, lastsel = -1;
+static int nclients = 0, sel = -1, lastsel = -1, newposition = 0;
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static char winid[64];
 static char **cmd = NULL;
@@ -413,6 +414,16 @@ expose(const XEvent *e) {
                drawbar();
 }
 
+void xsettitle(Display *d, Window w, const char* str) {
+    XTextProperty xtp;
+
+    if (XmbTextListToTextProperty(d, (char**)&str, 1, XCompoundTextStyle, 
&xtp) == Success) {
+        XSetTextProperty(d, w, &xtp, wmatom[WMName]);
+        XSetTextProperty(d, w, &xtp, XA_WM_NAME);
+        XFree(xtp.value);
+    }
+}
+
 void
 focus(int c) {
        char buf[BUFSIZ] = "tabbed-"VERSION" ::";
@@ -423,7 +434,7 @@ focus(int c) {
                for(i = 0, n = strlen(buf); cmd[i] && n < sizeof(buf); i++)
                        n += snprintf(&buf[n], sizeof(buf) - n, " %s", cmd[i]);
 
-               XStoreName(dpy, win, buf);
+               xsettitle(dpy, win, buf);
                XRaiseWindow(dpy, win);
 
                return;
@@ -437,7 +448,7 @@ focus(int c) {
        XSetInputFocus(dpy, clients[c]->win, RevertToParent, CurrentTime);
        sendxembed(c, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0);
        sendxembed(c, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
-       XStoreName(dpy, win, clients[c]->name);
+       xsettitle(dpy, win, clients[c]->name);
 
        /* If sel is already c, change nothing. */
        if(sel != c) {
@@ -1051,7 +1062,7 @@ updatetitle(int c) {
                                clients[c]->name, sizeof(clients[c]->name));
        }
        if(sel == c)
-               XStoreName(dpy, win, clients[c]->name);
+               xsettitle(dpy, win, clients[c]->name);
        drawbar();
 }
 
HTH,
Markus

Reply via email to