diff options
author | Daniel De Graaf <code@danieldg.net> | 2022-04-30 00:46:53 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-10-28 19:41:24 +0200 |
commit | 8aa89dc27736fc4940f3811ef15bb3135e629a8c (patch) | |
tree | 2ca6878657ed22e6150f478ace9651b3d61e5ebe /sway | |
parent | 8f7bb145b72209724f05b0182dee33c0e47d2357 (diff) |
Fix focus tracking when session lock is active
Remove the incorrect attempt to block focus changes when an input grab
is present and replace it with the same logic used for layer_shell-based
screen lockers: restore the focus after changing it.
This fixes a use-after-free of seat->workspace if outputs are destroyed
while a screen lock is enabled.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/seat.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index a7408287..43b20779 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1134,15 +1134,7 @@ void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node) { } } -void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { - if (seat->focused_layer) { - struct wlr_layer_surface_v1 *layer = seat->focused_layer; - seat_set_focus_layer(seat, NULL); - seat_set_focus(seat, node); - seat_set_focus_layer(seat, layer); - return; - } - +static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *node) { struct sway_node *last_focus = seat_get_focus(seat); if (last_focus == node) { return; @@ -1176,11 +1168,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { return; } - // Deny setting focus when an input grab or lockscreen is active - if (container && container->view && !seat_is_input_allowed(seat, container->view->surface)) { - return; - } - struct sway_output *new_output = new_workspace ? new_workspace->output : NULL; @@ -1280,6 +1267,20 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { } } +void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { + if (seat->focused_layer) { + struct wlr_layer_surface_v1 *layer = seat->focused_layer; + seat_set_focus_layer(seat, NULL); + seat_set_workspace_focus(seat, node); + seat_set_focus_layer(seat, layer); + } else { + seat_set_workspace_focus(seat, node); + } + if (server.session_lock.locked) { + seat_set_focus_surface(seat, server.session_lock.focused, false); + } +} + void seat_set_focus_container(struct sway_seat *seat, struct sway_container *con) { seat_set_focus(seat, con ? &con->node : NULL); |