2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009-2010 Michael Stapelberg and contributors (see also: LICENSE)
10 void window_update_class(i3Window *win, xcb_get_property_reply_t *prop) {
11 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
12 DLOG("empty property, not updating\n");
16 /* We cannot use asprintf here since this property contains two
17 * null-terminated strings (for compatibility reasons). Instead, we
18 * use strdup() on both strings */
19 char *new_class = xcb_get_property_value(prop);
21 FREE(win->class_instance);
22 FREE(win->class_class);
24 win->class_instance = strdup(new_class);
25 if ((strlen(new_class) + 1) < xcb_get_property_value_length(prop))
26 win->class_class = strdup(new_class + strlen(new_class) + 1);
27 else win->class_class = NULL;
28 LOG("WM_CLASS changed to %s (instance), %s (class)\n",
29 win->class_instance, win->class_class);
32 void window_update_name(i3Window *win, xcb_get_property_reply_t *prop) {
33 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
34 DLOG("_NET_WM_NAME not specified, not changing\n");
38 /* Save the old pointer to make the update atomic */
40 asprintf(&win->name_utf8, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop));
41 /* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */
42 win->name_ucs2 = convert_utf8_to_ucs2(win->name_utf8, &win->name_len);
43 LOG("_NET_WM_NAME changed to \"%s\"\n", win->name_utf8);
45 win->uses_net_wm_name = true;