From: Michael Stapelberg Date: Sun, 14 Nov 2010 17:52:40 +0000 (+0100) Subject: resize/unmap container x11 windows on demand (makes background images visible again) X-Git-Tag: tree-pr1~104 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5d7344af8af0fe06fa3d07e25daa0c3577e881f9;p=i3%2Fi3 resize/unmap container x11 windows on demand (makes background images visible again) --- diff --git a/src/x.c b/src/x.c index fe7ce8e0..41707bf7 100644 --- a/src/x.c +++ b/src/x.c @@ -372,6 +372,7 @@ void x_draw_decoration(Con *con) { static void x_push_node(Con *con) { Con *current; con_state *state; + Rect rect = con->rect; LOG("Pushing changes for node %p / %s\n", con, con->name); state = state_for_frame(con->frame); @@ -384,6 +385,28 @@ static void x_push_node(Con *con) { FREE(state->name); } + if (con->window == NULL) { + /* Calculate the height of all window decorations which will be drawn on to + * this frame. */ + uint32_t max_y = 0, max_height = 0; + TAILQ_FOREACH(current, &(con->nodes_head), nodes) { + DLOG("Child's decoration is %d x %d, from (%d, %d)\n", + current->deco_rect.width, current->deco_rect.height, + current->deco_rect.x, current->deco_rect.y); + Rect *dr = &(current->deco_rect); + if (dr->y >= max_y && dr->height >= max_height) { + max_y = dr->y; + max_height = dr->height; + } + } + DLOG("bottom of decorations is %d\n", max_y + max_height); + rect.height = max_y + max_height; + if (rect.height == 0) { + DLOG("Unmapping container because it does not contain anything atm.\n"); + con->mapped = false; + } + } + /* reparent the child window (when the window was moved due to a sticky * container) */ if (state->need_reparent && con->window != NULL) { @@ -452,10 +475,10 @@ static void x_push_node(Con *con) { bool fake_notify = false; /* set new position if rect changed */ - if (memcmp(&(state->rect), &(con->rect), sizeof(Rect)) != 0) { - LOG("setting rect (%d, %d, %d, %d)\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height); - xcb_set_window_rect(conn, con->frame, con->rect); - memcpy(&(state->rect), &(con->rect), sizeof(Rect)); + if (memcmp(&(state->rect), &rect, sizeof(Rect)) != 0) { + LOG("setting rect (%d, %d, %d, %d)\n", rect.x, rect.y, rect.width, rect.height); + xcb_set_window_rect(conn, con->frame, rect); + memcpy(&(state->rect), &rect, sizeof(Rect)); fake_notify = true; }