From: Michael Stapelberg Date: Sun, 8 Mar 2009 18:07:33 +0000 (+0100) Subject: Bugfix: Use _NET_WM_NAME (UTF-8) rather than WM_NAME (COMPOUND_TEXT). Only render... X-Git-Tag: 3.a~61 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e74378dd0a8edf980d441a608658d41f997e5f9;p=i3%2Fi3 Bugfix: Use _NET_WM_NAME (UTF-8) rather than WM_NAME (COMPOUND_TEXT). Only render client titles, if they are set --- diff --git a/src/layout.c b/src/layout.c index 190dc04a..0aff8665 100644 --- a/src/layout.c +++ b/src/layout.c @@ -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); + } } /* diff --git a/src/mainx.c b/src/mainx.c index 55136576..75a45c53 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -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");