From 84ec8f92a69feb303e0e521f482b75b2cd12c4aa Mon Sep 17 00:00:00 2001 From: Thomas Hebb Date: Wed, 20 May 2020 21:20:19 -0400 Subject: [PATCH] Use new wlroots API for clearing keyboard/pointer focus during grabs We are not allowed to do what we did in #5222 and pass a `NULL` surface wlr_seat_pointer_notify_enter(), and it's causing crashes when an xdg-shell popup is active (see #5294 and swaywm/wlroots#2161). Instead, solve #5220 using the new wlroots API introduced in swaywm/wlroots#2217. --- sway/config/output.c | 2 +- sway/input/cursor.c | 2 +- sway/input/seat.c | 6 +++--- sway/input/seatop_default.c | 6 ++---- sway/input/seatop_move_floating.c | 2 +- sway/input/seatop_move_tiling.c | 2 +- sway/input/seatop_resize_floating.c | 2 +- sway/input/seatop_resize_tiling.c | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/sway/config/output.c b/sway/config/output.c index 5aaa4d93..713cd219 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -645,7 +645,7 @@ void apply_output_config_to_outputs(struct output_config *oc) { struct sway_seat *seat; wl_list_for_each(seat, &server.input->seats, link) { - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); cursor_rebase(seat->cursor); } } diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 1a211c3b..8e39dac1 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -236,7 +236,7 @@ void cursor_update_image(struct sway_cursor *cursor, static void cursor_hide(struct sway_cursor *cursor) { wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); cursor->hidden = true; - wlr_seat_pointer_clear_focus(cursor->seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(cursor->seat->wlr_seat); } static int hide_notify(void *data) { diff --git a/sway/input/seat.c b/sway/input/seat.c index e5f15613..73a8deac 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -698,7 +698,7 @@ static void seat_configure_keyboard(struct sway_seat *seat, struct sway_node *focus = seat_get_focus(seat); if (focus && node_is_view(focus)) { // force notify reenter to pick up the new configuration - wlr_seat_keyboard_clear_focus(seat->wlr_seat); + wlr_seat_keyboard_notify_clear_focus(seat->wlr_seat); seat_keyboard_notify_enter(seat, focus->sway_container->view->surface); } } @@ -963,7 +963,7 @@ static void send_unfocus(struct sway_container *con, void *data) { // Unfocus the container and any children (eg. when leaving `focus parent`) static void seat_send_unfocus(struct sway_node *node, struct sway_seat *seat) { sway_cursor_constrain(seat->cursor, NULL); - wlr_seat_keyboard_clear_focus(seat->wlr_seat); + wlr_seat_keyboard_notify_clear_focus(seat->wlr_seat); if (node->type == N_WORKSPACE) { workspace_for_each_container(node->sway_workspace, send_unfocus, seat); } else { @@ -1230,7 +1230,7 @@ void seat_set_exclusive_client(struct sway_seat *seat, } if (seat->wlr_seat->pointer_state.focused_client) { if (seat->wlr_seat->pointer_state.focused_client->client != client) { - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); } } struct timespec now; diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 072f4396..2bce2f77 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -483,8 +483,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec, } } else { cursor_update_image(cursor, node); - wlr_seat_pointer_notify_enter(seat->wlr_seat, NULL, 0, 0); - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); } struct sway_drag_icon *drag_icon; @@ -664,8 +663,7 @@ static void handle_rebase(struct sway_seat *seat, uint32_t time_msec) { } } else { cursor_update_image(cursor, e->previous_node); - wlr_seat_pointer_notify_enter(seat->wlr_seat, NULL, 0, 0); - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); } } diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c index a04fd457..21a2a966 100644 --- a/sway/input/seatop_move_floating.c +++ b/sway/input/seatop_move_floating.c @@ -65,5 +65,5 @@ void seatop_begin_move_floating(struct sway_seat *seat, container_raise_floating(con); cursor_set_image(cursor, "grab", NULL); - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); } diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 3f31e4b1..a1aa5245 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c @@ -336,7 +336,7 @@ void seatop_begin_move_tiling_threshold(struct sway_seat *seat, seat->seatop_data = e; container_raise_floating(con); - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); } void seatop_begin_move_tiling(struct sway_seat *seat, diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index 80df63ce..ec10cfc8 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c @@ -175,5 +175,5 @@ void seatop_begin_resize_floating(struct sway_seat *seat, const char *image = edge == WLR_EDGE_NONE ? "se-resize" : wlr_xcursor_get_resize_name(edge); cursor_set_image(seat->cursor, image, NULL); - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); } diff --git a/sway/input/seatop_resize_tiling.c b/sway/input/seatop_resize_tiling.c index 825f5044..f6f106ef 100644 --- a/sway/input/seatop_resize_tiling.c +++ b/sway/input/seatop_resize_tiling.c @@ -106,5 +106,5 @@ void seatop_begin_resize_tiling(struct sway_seat *seat, seat->seatop_impl = &seatop_impl; seat->seatop_data = e; - wlr_seat_pointer_clear_focus(seat->wlr_seat); + wlr_seat_pointer_notify_clear_focus(seat->wlr_seat); }