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.
next
Peter Bui 2011-08-08 17:55:37 -04:00 committed by Michael Stapelberg
parent 042b10e068
commit d8cf36ce83
1 changed files with 14 additions and 2 deletions

View File

@ -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);