X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fwindow.c;h=dd04b1b9e822c851e56948775ef6e45364773de9;hb=94a09b3cac98a3bc1ed580fce16aa9869f83bbaa;hp=e406752a54c63fa5bd2f2b77ddb96419cef407c3;hpb=3b4ae812e3543681a331bb72e6ae50038c4ab7bc;p=i3%2Fi3 diff --git a/src/window.c b/src/window.c index e406752a..dd04b1b9 100644 --- a/src/window.c +++ b/src/window.c @@ -4,7 +4,7 @@ * 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). * @@ -26,14 +26,16 @@ void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool bef /* We cannot use asprintf here since this property contains two * 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 = 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) < (size_t)xcb_get_property_value_length(prop)) - 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", @@ -189,7 +191,7 @@ void window_update_strut_partial(i3Window *win, xcb_get_property_reply_t *prop) DLOG("Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n", strut[0], strut[1], strut[2], strut[3]); - win->reserved = (struct reservedpx) {strut[0], strut[1], strut[2], strut[3]}; + win->reserved = (struct reservedpx){strut[0], strut[1], strut[2], strut[3]}; free(prop); } @@ -227,6 +229,23 @@ void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool befo free(prop); } +/* + * Updates the _NET_WM_WINDOW_TYPE property. + * + */ +void window_update_type(i3Window *window, xcb_get_property_reply_t *reply) { + xcb_atom_t new_type = xcb_get_preferred_window_type(reply); + if (new_type == XCB_NONE) { + DLOG("cannot read _NET_WM_WINDOW_TYPE from window.\n"); + return; + } + + window->window_type = new_type; + LOG("_NET_WM_WINDOW_TYPE changed to %i.\n", window->window_type); + + run_assignments(window); +} + /* * Updates the WM_HINTS (we only care about the input focus handling part). * @@ -249,8 +268,10 @@ void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *ur 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);