diff --git a/src/commands.c b/src/commands.c index f15921b4..507fdf6d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -481,8 +481,10 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl floating_assign_to_workspace(client, t_ws); + bool target_invisible = t_ws->screen->current_workspace != t_ws->num; + /* If we’re moving it to an invisible screen, we need to unmap it */ - if (t_ws->screen->current_workspace != t_ws->num) { + if (target_invisible) { LOG("This workspace is not visible, unmapping\n"); xcb_unmap_window(conn, client->frame); } else { @@ -504,7 +506,8 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl render_layout(conn); - set_focus(conn, client, true); + if (!target_invisible) + set_focus(conn, client, true); } /* diff --git a/src/handlers.c b/src/handlers.c index 11c8e576..383207f8 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -598,6 +598,8 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti if ((con->currently_focused != NULL) && ((con == CUR_CELL) || client->fullscreen)) set_focus(conn, con->currently_focused, true); } else if (client_is_floating(client)) { + LOG("Removing from floating clients\n"); + TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients); SLIST_REMOVE(&(client->workspace->focus_stack), client, Client, focus_clients); } @@ -606,11 +608,6 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti SLIST_REMOVE(&(client->workspace->screen->dock_clients), client, Client, dock_clients); } - if (client->floating) { - LOG("Removing from floating clients\n"); - TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients); - } - LOG("child of 0x%08x.\n", client->frame); xcb_reparent_window(conn, client->child, root, 0, 0); xcb_destroy_window(conn, client->frame); diff --git a/src/util.c b/src/util.c index 9bb42872..bccb9941 100644 --- a/src/util.c +++ b/src/util.c @@ -258,6 +258,7 @@ void unmap_workspace(xcb_connection_t *conn, Workspace *u_ws) { int unmapped_clients = 0; FOR_TABLE(u_ws) CIRCLEQ_FOREACH(client, &(u_ws->table[cols][rows]->clients), clients) { + LOG("unmapping normal client %p / %p / %p\n", client, client->frame, client->child); xcb_unmap_window(conn, client->frame); unmapped_clients++; } @@ -267,6 +268,8 @@ void unmap_workspace(xcb_connection_t *conn, Workspace *u_ws) { if (!client_is_floating(client)) continue; + LOG("unmapping floating client %p / %p / %p\n", client, client->frame, client->child); + xcb_unmap_window(conn, client->frame); unmapped_clients++; }