]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Use _NET_WM_NAME (UTF-8) rather than WM_NAME (COMPOUND_TEXT). Only render...
authorMichael Stapelberg <michael+x200@stapelberg.de>
Sun, 8 Mar 2009 18:07:33 +0000 (19:07 +0100)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Sun, 8 Mar 2009 18:07:33 +0000 (19:07 +0100)
src/layout.c
src/mainx.c

index 190dc04a839aa788a3675b7d3181e74d17f87dfe..0aff86652945d3b0d414030d299adf460ca832f2 100644 (file)
@@ -162,16 +162,19 @@ void decorate_window(xcb_connection_t *conn, Client *client, xcb_drawable_t draw
         xcb_draw_line(conn, drawable, gc, border_color, 2, offset + font->height + 3,
                       2 + client->rect.width, offset + font->height + 3);
 
-        /* Draw the font */
-        uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
-        uint32_t values[] = { text_color, background_color, font->id };
-        xcb_change_gc(conn, gc, mask, values);
-
-        int real_strlen;
-        char *ucs2_label = convert_utf8_to_ucs2(client->name, &real_strlen);
-        xcb_image_text_16(conn, real_strlen, drawable, gc, 3 /* X */,
-                          offset + font->height /* Y = baseline of font */, (xcb_char2b_t*)ucs2_label);
-        free(ucs2_label);
+        /* If the client has a title, we draw it */
+        if (client->name != NULL) {
+                /* Draw the font */
+                uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
+                uint32_t values[] = { text_color, background_color, font->id };
+                xcb_change_gc(conn, gc, mask, values);
+
+                int real_strlen;
+                char *ucs2_label = convert_utf8_to_ucs2(client->name, &real_strlen);
+                xcb_image_text_16(conn, real_strlen, drawable, gc, 3 /* X */,
+                                  offset + font->height /* Y = baseline of font */, (xcb_char2b_t*)ucs2_label);
+                free(ucs2_label);
+        }
 }
 
 /*
index 55136576fdb256ba0e47e1505d736bb195017379..75a45c5316014cf64ce9f6f836455e5a26c0a6dd 100644 (file)
@@ -105,7 +105,7 @@ void manage_window(xcb_property_handlers_t *prophs, xcb_connection_t *conn, xcb_
         if (attr && geom) {
                 reparent_window(conn, window, attr->visual, geom->root, geom->depth,
                                 geom->x, geom->y, geom->width, geom->height);
-                xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, WM_NAME);
+                xcb_property_changed(prophs, XCB_PROPERTY_NEW_VALUE, window, atoms[_NET_WM_NAME]);
         }
 
         free(geom);
@@ -415,9 +415,6 @@ int main(int argc, char *argv[], char *env[]) {
         /* Initialize the property handlers */
         xcb_property_handlers_init(&prophs, &evenths);
 
-        /* Watch the WM_NAME (= title of the window) property */
-        xcb_watch_wm_name(&prophs, 128, handle_windowname_change, 0);
-
         /* Watch size hints (to obey correct aspect ratio) */
         xcb_property_set_handler(&prophs, WM_NORMAL_HINTS, UINT_MAX, handle_normal_hints, NULL);
 
@@ -458,6 +455,9 @@ int main(int argc, char *argv[], char *env[]) {
         xcb_property_set_handler(&prophs, atoms[_NET_WM_WINDOW_TYPE], UINT_MAX, window_type_handler, NULL);
         /* TODO: In order to comply with EWMH, we have to watch _NET_WM_STRUT_PARTIAL */
 
+        /* Watch _NET_WM_NAME (= title of the window in UTF-8) property */
+        xcb_property_set_handler(&prophs, atoms[_NET_WM_NAME], 128, handle_windowname_change, NULL);
+
         /* Set up the atoms we support */
         check_error(conn, xcb_change_property_checked(conn, XCB_PROP_MODE_REPLACE, root, atoms[_NET_SUPPORTED],
                        ATOM, 32, 7, atoms), "Could not set _NET_SUPPORTED");