* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
* window.c: Updates window attributes (X11 hints/properties).
*
* null-terminated strings (for compatibility reasons). Instead, we
* use strdup() on both strings */
const size_t prop_length = xcb_get_property_value_length(prop);
- char *new_class = smalloc(prop_length + 1);
- memcpy(new_class, xcb_get_property_value(prop), prop_length);
- new_class[prop_length] = '\0';
+ char *new_class = xcb_get_property_value(prop);
+ const size_t class_class_index = strnlen(new_class, prop_length) + 1;
FREE(win->class_instance);
FREE(win->class_class);
- win->class_instance = sstrdup(new_class);
- if ((strlen(new_class) + 1) < prop_length)
- win->class_class = sstrdup(new_class + strlen(new_class) + 1);
+ win->class_instance = sstrndup(new_class, prop_length);
+ if (class_class_index < prop_length)
+ win->class_class = sstrndup(new_class + class_class_index, prop_length - class_class_index);
else
win->class_class = NULL;
LOG("WM_CLASS changed to %s (instance), %s (class)\n",
win->class_instance, win->class_class);
if (before_mgmt) {
- free(new_class);
free(prop);
return;
}
run_assignments(win);
- free(new_class);
free(prop);
}
}
window->window_type = new_type;
- LOG("_NET_WM_WINDOW_TYPE changed to %i", window->window_type);
+ LOG("_NET_WM_WINDOW_TYPE changed to %i.\n", window->window_type);
run_assignments(window);
}
return;
}
- win->doesnt_accept_focus = !hints.input;
- LOG("WM_HINTS.input changed to \"%d\"\n", hints.input);
+ if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
+ win->doesnt_accept_focus = !hints.input;
+ LOG("WM_HINTS.input changed to \"%d\"\n", hints.input);
+ }
if (urgency_hint != NULL)
*urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);