From 2f334c3f59f0d9c2c679e8cef8a1771c748c826c Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 7 Jun 2009 19:09:39 +0200 Subject: [PATCH] =?UTF-8?q?Bugfix:=20Don=E2=80=99t=20set=20focus=20when=20?= =?UTF-8?q?unmapping=20clients=20if=20the=20workspace=20is=20not=20active?= =?UTF-8?q?=20(Thanks=20Mirko)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes ticket #53 because current workspace was set to the workspace which was deleted. --- src/commands.c | 2 +- src/handlers.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/commands.c b/src/commands.c index d84adf45..d1ee5c69 100644 --- a/src/commands.c +++ b/src/commands.c @@ -890,7 +890,7 @@ void parse_command(xcb_connection_t *conn, const char *command) { } if (*rest == '\0') { - /* No rest? This was a tag number, not a times specification */ + /* No rest? This was a workspace number, not a times specification */ show_workspace(conn, times); return; } diff --git a/src/handlers.c b/src/handlers.c index 250465d1..45cb37c1 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -578,25 +578,30 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti /* Let’s see how many clients there are left on the workspace to delete it if it’s empty */ bool workspace_empty = SLIST_EMPTY(&(client->workspace->focus_stack)); + bool workspace_active = false; Client *to_focus = (!workspace_empty ? SLIST_FIRST(&(client->workspace->focus_stack)) : NULL); /* If this workspace is currently active, we don’t delete it */ i3Screen *screen; TAILQ_FOREACH(screen, virtual_screens, screens) if (screen->current_workspace == client->workspace->num) { + workspace_active = true; workspace_empty = false; break; } - if (workspace_empty) + if (workspace_empty) { + LOG("setting ws to NULL for workspace %d (%p)\n", client->workspace->num, + client->workspace); client->workspace->screen = NULL; + } free(client); render_layout(conn); /* Ensure the focus is set to the next client in the focus stack */ - if (to_focus != NULL) + if (workspace_active && to_focus != NULL) set_focus(conn, to_focus, true); return 1;