Fix focus bug

When changing focus from a view in one workspace to an empty workspace
using `focus <direction>`, the view in the previous workspace would keep
focused styling. This is because the check to unfocus it was only done
in the container case and not workspace case, so it's been moved out of
both.
This commit is contained in:
Ryan Dwyer 2018-09-01 07:57:07 +10:00
parent 3133d0c03c
commit fb9b0f7a08

View file

@ -614,6 +614,13 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
new_output_last_ws = output_get_active_workspace(new_output); new_output_last_ws = output_get_active_workspace(new_output);
} }
// Unfocus the previous focus
if (last_focus) {
seat_send_unfocus(last_focus, seat);
node_set_dirty(last_focus);
node_set_dirty(node_get_parent(last_focus));
}
// Put the container parents on the focus stack, then the workspace, then // Put the container parents on the focus stack, then the workspace, then
// the focused container. // the focused container.
if (container) { if (container) {
@ -640,15 +647,6 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
wl_list_remove(&seat_node->link); wl_list_remove(&seat_node->link);
wl_list_insert(&seat->focus_stack, &seat_node->link); wl_list_insert(&seat->focus_stack, &seat_node->link);
node_set_dirty(&container->node); node_set_dirty(&container->node);
if (last_focus) {
seat_send_unfocus(last_focus, seat);
node_set_dirty(last_focus);
struct sway_node *last_parent = node_get_parent(last_focus);
if (last_parent) {
node_set_dirty(last_parent);
}
}
seat_send_focus(&container->node, seat); seat_send_focus(&container->node, seat);
} }