From 31e8d7f2f81f115f70c1fc3eb404b0cfbc13ddf4 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 29 Sep 2012 00:02:41 +0200 Subject: [PATCH] Bugfix: Correctly move floating windows to invisible workspaces cross-output (Thanks swh) --- src/con.c | 13 ++++++++++--- src/x.c | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/con.c b/src/con.c index f5ccfcdd..0f7a5cbb 100644 --- a/src/con.c +++ b/src/con.c @@ -666,13 +666,20 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool con->percent = 0.0; con_fix_percent(next); - /* 7: focus the con on the target workspace (the X focus is only updated by - * calling tree_render(), so for the "real" focus this is a no-op). + /* 7: focus the con on the target workspace, but only within that + * workspace, that is, don’t move focus away if the target workspace is + * invisible. * We don’t focus the con for i3 pseudo workspaces like __i3_scratch and * we don’t focus when there is a fullscreen con on that workspace. */ if ((workspace->name[0] != '_' || workspace->name[1] != '_') && - con_get_fullscreen_con(workspace, CF_OUTPUT) == NULL) + con_get_fullscreen_con(workspace, CF_OUTPUT) == NULL) { + /* We need to save focus on workspace level and restore it afterwards. + * Otherwise, we might focus a different workspace without actually + * switching workspaces. */ + Con *old_focus = TAILQ_FIRST(&(output_get_content(dest_output)->focus_head)); con_focus(con_descend_focused(con)); + con_focus(old_focus); + } /* 8: when moving to a visible workspace on a different output, we keep the * con focused. Otherwise, we leave the focus on the current workspace as we diff --git a/src/x.c b/src/x.c index 7cb28c1a..a3f42b6a 100644 --- a/src/x.c +++ b/src/x.c @@ -792,7 +792,7 @@ static void x_push_node_unmaps(Con *con) { } cookie = xcb_unmap_window(conn, con->frame); - DLOG("unmapping container (serial %d)\n", cookie.sequence); + DLOG("unmapping container %p / %s (serial %d)\n", con, con->name, cookie.sequence); /* we need to increase ignore_unmap for this container (if it * contains a window) and for every window "under" this one which * contains a window */ -- 2.39.5