Bugfix: Don’t set focus when unmapping clients if the workspace is not active (Thanks Mirko)

This fixes ticket  because current workspace was set to the
workspace which was deleted.
This commit is contained in:
Michael Stapelberg
2009-06-07 19:09:39 +02:00
parent 2330c20092
commit 2f334c3f59
2 changed files with 8 additions and 3 deletions

@ -578,25 +578,30 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
/* Lets see how many clients there are left on the workspace to delete it if its 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 dont 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;