aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-26 19:15:12 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-26 19:15:12 +1000
commit63d076dc2abba0cab6fb78bb2e36088f0b4f9ae5 (patch)
tree3d1d95e2c99911bb815aed18ed582aa3095b3811 /sway/input/seat.c
parentMerge pull request #2985 from mihaicmn/fix-retiling (diff)
downloadsway-63d076dc2abba0cab6fb78bb2e36088f0b4f9ae5.tar.gz
sway-63d076dc2abba0cab6fb78bb2e36088f0b4f9ae5.tar.zst
sway-63d076dc2abba0cab6fb78bb2e36088f0b4f9ae5.zip
Fix focus after a non-visible workspace's last container is destroyed
The code being changed is responsible for updating the focus stack when a container is destroyed in a different part of the tree to where the real focus is. It's attempting to set focus_inactive to a sibling (or parent if no siblings) of the container that is being destroyed, then put our real focus back on the end of the focus stack. The problem occurs when the container being destroyed is in a different workspace. For example: * Have a focused view on workspace 1 * Have workspace 2 not visible with a single view that is unmapping * The first call to seat_set_raw_focus sets focus to workspace 2 because it's the parent * Prior to this patch, the second call to seat_set_raw_focus would set focus to the view on workspace 1 * Later, when using output_get_active_workspace, this function would return workspace 2 because it's the first workspace it finds in the focus stack. To fix this, workspace 1 must be placed on the focus stack between workspace 2 and the focused view. That's what this patch does. Lastly, it also uses seat_get_focus_inactive to choose the focus. This fixes a crash when a view unmaps while a non-container is focused (eg. swaylock), because focus is NULL.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 577619a7..9d4dc7af 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -185,7 +185,11 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
185 seat_set_focus(seat, next_focus); 185 seat_set_focus(seat, next_focus);
186 } else { 186 } else {
187 // Setting focus_inactive 187 // Setting focus_inactive
188 focus = seat_get_focus_inactive(seat, &root->node);
188 seat_set_raw_focus(seat, next_focus); 189 seat_set_raw_focus(seat, next_focus);
190 if (focus->type == N_CONTAINER) {
191 seat_set_raw_focus(seat, &focus->sway_container->workspace->node);
192 }
189 seat_set_raw_focus(seat, focus); 193 seat_set_raw_focus(seat, focus);
190 } 194 }
191} 195}