From: Michael Stapelberg Date: Sat, 30 May 2009 09:35:32 +0000 (+0200) Subject: Bugfix: Correctly cleanup stack_windows when setting clients to floating X-Git-Tag: 3.b~89 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b1eb93326f02b47cf9811c3ec6ed761c8402efb0;p=i3%2Fi3 Bugfix: Correctly cleanup stack_windows when setting clients to floating This fixes ticket #44 --- diff --git a/include/client.h b/include/client.h index 2547c52f..252f3619 100644 --- a/include/client.h +++ b/include/client.h @@ -20,7 +20,7 @@ * one or because it was unmapped * */ -void client_remove_from_container(xcb_connection_t *conn, Client *client, Container *container); +void client_remove_from_container(xcb_connection_t *conn, Client *client, Container *container, bool remove_from_focusstack); /** * Warps the pointer into the given client (in the middle of it, to be specific), therefore diff --git a/src/client.c b/src/client.c index f4df06ae..9eb34565 100644 --- a/src/client.c +++ b/src/client.c @@ -29,10 +29,11 @@ * one or because it was unmapped * */ -void client_remove_from_container(xcb_connection_t *conn, Client *client, Container *container) { +void client_remove_from_container(xcb_connection_t *conn, Client *client, Container *container, bool remove_from_focusstack) { CIRCLEQ_REMOVE(&(container->clients), client, clients); - SLIST_REMOVE(&(container->workspace->focus_stack), client, Client, focus_clients); + if (remove_from_focusstack) + SLIST_REMOVE(&(container->workspace->focus_stack), client, Client, focus_clients); /* If the container will be empty now and is in stacking mode, we need to unmap the stack_win */ diff --git a/src/commands.c b/src/commands.c index d3ef90f2..811f1676 100644 --- a/src/commands.c +++ b/src/commands.c @@ -242,7 +242,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 */ - client_remove_from_container(conn, current_client, container); + client_remove_from_container(conn, current_client, container, true); if (new->currently_focused != NULL) CIRCLEQ_INSERT_AFTER(&(new->clients), new->currently_focused, current_client, clients); @@ -505,7 +505,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa assert(to_container != NULL); - client_remove_from_container(conn, current_client, container); + client_remove_from_container(conn, current_client, container, true); if (container->workspace->fullscreen_client == current_client) container->workspace->fullscreen_client = NULL; diff --git a/src/floating.c b/src/floating.c index 3e8c1c07..7ee53638 100644 --- a/src/floating.c +++ b/src/floating.c @@ -23,6 +23,7 @@ #include "xcb.h" #include "debug.h" #include "layout.h" +#include "client.h" /* On which border was the dragging initiated? */ typedef enum { BORDER_LEFT, BORDER_RIGHT, BORDER_TOP, BORDER_BOTTOM} border_t; @@ -78,7 +79,7 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client) { LOG("Entering floating for client %08x\n", client->child); /* Remove the client of its container */ - CIRCLEQ_REMOVE(&(con->clients), client, clients); + client_remove_from_container(conn, client, con, false); client->container = NULL; if (con->currently_focused == client) { diff --git a/src/handlers.c b/src/handlers.c index 8f164cd2..7682aaf0 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -534,7 +534,7 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti con->workspace->fullscreen_client = NULL; /* Remove the client from the list of clients */ - client_remove_from_container(conn, client, con); + client_remove_from_container(conn, client, con, true); /* Set focus to the last focused client in this container */ con->currently_focused = get_last_focused_client(conn, con, NULL);