From a411ed24cb5692e3d7e24398378b886b2a617d8a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 6 Mar 2009 19:08:59 +0100 Subject: [PATCH] Bugfix: Correctly check for empty containers and unmap the stack_win --- include/util.h | 1 + src/commands.c | 2 +- src/handlers.c | 10 +--------- src/util.c | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/util.h b/include/util.h index 4e4e3d05..c17f7d01 100644 --- a/include/util.h +++ b/include/util.h @@ -34,6 +34,7 @@ void *scalloc(size_t size); char *sstrdup(const char *str); void start_application(const char *command); void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_message); +void remove_client_from_container(xcb_connection_t *conn, Client *client, Container *container); void set_focus(xcb_connection_t *conn, Client *client); void leave_stack_mode(xcb_connection_t *conn, Container *container); void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode); diff --git a/src/commands.c b/src/commands.c index d7d0fa90..77b3e58f 100644 --- a/src/commands.c +++ b/src/commands.c @@ -217,7 +217,7 @@ static void move_current_window(xcb_connection_t *conn, direction_t direction) { } /* Remove it from the old container and put it into the new one */ - CIRCLEQ_REMOVE(&(container->clients), current_client, clients); + remove_client_from_container(conn, current_client, container); CIRCLEQ_INSERT_TAIL(&(new->clients), current_client, clients); /* Update data structures */ diff --git a/src/handlers.c b/src/handlers.c index 939fe636..88b09b6b 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -433,16 +433,8 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti if (client->fullscreen) con->workspace->fullscreen_client = NULL; - /* If the container will be empty now and is in stacking mode, we need to - correctly resize the stack_win */ - if (CIRCLEQ_EMPTY(&(con->clients)) && con->mode == MODE_STACK) { - struct Stack_Window *stack_win = &(con->stack_win); - stack_win->rect.height = 0; - xcb_unmap_window(conn, stack_win->window); - } - /* Remove the client from the list of clients */ - CIRCLEQ_REMOVE(&(con->clients), client, clients); + remove_client_from_container(conn, client, con); /* Remove from the focus stack */ LOG("Removing from focus stack\n"); diff --git a/src/util.c b/src/util.c index 5642ca59..c1cb9571 100644 --- a/src/util.c +++ b/src/util.c @@ -135,6 +135,23 @@ void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_mes } } +/* + * Removes the given client from the container, either because it will be inserted into another + * one or because it was unmapped + * + */ +void remove_client_from_container(xcb_connection_t *conn, Client *client, Container *container) { + CIRCLEQ_REMOVE(&(container->clients), client, clients); + + /* If the container will be empty now and is in stacking mode, we need to + unmap the stack_win */ + if (CIRCLEQ_EMPTY(&(container->clients)) && container->mode == MODE_STACK) { + struct Stack_Window *stack_win = &(container->stack_win); + stack_win->rect.height = 0; + xcb_unmap_window(conn, stack_win->window); + } +} + /* * Sets the given client as focused by updating the data structures correctly, * updating the X input focus and finally re-decorating both windows (to signalize -- 2.39.5