From: Peter Bui Date: Mon, 8 Aug 2011 21:55:37 +0000 (-0400) Subject: Fix two focus issues when switching/moving workspaces X-Git-Tag: 4.0.2~46^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d8cf36ce83d2d9d6653ff08b1b2308c6f1bf1acd;p=i3%2Fi3 Fix two focus issues when switching/moving workspaces 1. Fix focus when moving to same workspace. If we have a single window on a workspace and we switch to the same worksapce, focus_next will be the workspace container, rather than the current window, so simply call con_descend_focused to ensure we set the focus to a window. 2. Fix focus when moving a container to a visible workspace. Call workspace_show before we attaching to new visible workspace, so we don't get in the weird situation where target workspace has focused window, but it isn't considered focused. --- diff --git a/src/con.c b/src/con.c index b8b652b3..b867e964 100644 --- a/src/con.c +++ b/src/con.c @@ -585,6 +585,14 @@ void con_move_to_workspace(Con *con, Con *workspace) { next = ws; } + /* If moving to a visible workspace, call show so it can be considered + * focused. Must do before attaching because workspace_show checks to see + * if focused container is in its area. */ + if (source_output != dest_output && + workspace_is_visible(workspace)) { + workspace_show(workspace->name); + } + DLOG("Re-attaching container to %p / %s\n", next, next->name); /* 5: re-attach the con to the parent of this focused container */ Con *parent = con->parent; @@ -597,7 +605,7 @@ void con_move_to_workspace(Con *con, Con *workspace) { 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) */ + * calling tree_render(), so for the "real" focus this is a no-op). */ con_focus(con); /* 8: when moving to a visible workspace on a different output, we keep the @@ -607,7 +615,11 @@ void con_move_to_workspace(Con *con, Con *workspace) { workspace_is_visible(workspace)) { DLOG("Moved to a different output, focusing target\n"); } else { - con_focus(focus_next); + /* Descend focus stack in case focus_next is a workspace which can + * occur if we move to the same workspace. Also show current workspace + * to ensure it is focused. */ + workspace_show(con_get_workspace(focus_next)->name); + con_focus(con_descend_focused(focus_next)); } CALL(parent, on_remove_child);