]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Correctly unmap/remap the stack_win when a container becomes empty
authorMichael Stapelberg <michael+git@stapelberg.de>
Sat, 28 Feb 2009 00:38:53 +0000 (01:38 +0100)
committerMichael Stapelberg <michael+git@stapelberg.de>
Sat, 28 Feb 2009 00:38:53 +0000 (01:38 +0100)
src/handlers.c
src/layout.c

index 580ba1f94b1b7e5395f67fb192d6510f80a3e87c..32b0b03cef673c4b00158f29ab98366d218ef2a0 100644 (file)
@@ -334,20 +334,34 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_
         }
 
         if (client->container != NULL) {
-                Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(client->container->clients), client, clients);
-                if (to_focus == NULL)
-                        to_focus = CIRCLEQ_PREV_OR_NULL(&(client->container->clients), client, clients);
-
-                /* Set focus in data structure to the next/previous window, if any (else NULL) */
-                if (client->container->currently_focused == client)
-                        client->container->currently_focused = to_focus;
+                Client *to_focus = NULL;
+                Container *con = client->container;
+
+                /* If the client which is being unmapped was the currently active, we need to find
+                   the next possible window to focus in this container */
+                if (con->currently_focused == client) {
+                        to_focus = CIRCLEQ_NEXT_OR_NULL(&(con->clients), client, clients);
+                        if (to_focus == NULL)
+                                to_focus = CIRCLEQ_PREV_OR_NULL(&(con->clients), client, clients);
+
+                        /* Set focus in data structure to the next/previous window, if any (else NULL) */
+                        con->currently_focused = to_focus;
+                }
 
                 /* If this was the fullscreen client, we need to unset it */
-                if (client->container->workspace->fullscreen_client == client)
-                        client->container->workspace->fullscreen_client = NULL;
+                if (con->workspace->fullscreen_client == client)
+                        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 (con->currently_focused == NULL && con->mode == MODE_STACK) {
+                        struct Stack_Window *stack_win = &(con->stack_win);
+                        stack_win->height = 0;
+                        xcb_unmap_window(c, stack_win->window);
+                }
 
                 /* Remove the client from the list of clients */
-                CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
+                CIRCLEQ_REMOVE(&(con->clients), client, clients);
 
                 /* Actually set focus, if there is a window which should get it */
                 if (to_focus != NULL)
index b3eb14f0c9c2246162d26ffae95bab8e1656961e..18d431e36b235cabcccbb8eb9cb80a97b1739042 100644 (file)
@@ -221,6 +221,11 @@ void render_container(xcb_connection_t *connection, Container *container) {
                 int decoration_height = (font->height + 2 + 2);
                 struct Stack_Window *stack_win = &(container->stack_win);
 
+                /* Check if we need to remap our stack title window, it gets unmapped when the container
+                   is empty in src/handlers.c:unmap_notify() */
+                if (stack_win->height == 0)
+                        xcb_map_window(connection, stack_win->window);
+
                 /* Check if we need to reconfigure our stack title window */
                 if ((stack_win->width != (stack_win->width = container->width)) |
                     (stack_win->height != (stack_win->height = decoration_height * num_clients)))