From 24a90e5d86441fc345356eb3767e5a6880dcedbd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 18 Oct 2018 23:08:45 +1000 Subject: Remove cursor warping from seat_set_focus Because cursor warping was the default behaviour in seat_set_focus, there may be cases where we may have been warping the cursor unintentionally. This patch removes cursor warping from seat_set_focus and only does it in the focus command. This is managed by a static function in focus.c. To know whether to warp or not, we need to know which node had focus previously. To keep track of this easily, seat->prev_focus has been introduced and is set to the previous in seat_set_focus. --- sway/input/cursor.c | 6 +++--- sway/input/seat.c | 29 ++++------------------------- 2 files changed, 7 insertions(+), 28 deletions(-) (limited to 'sway/input') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 925190d6..688fc230 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -597,7 +597,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, struct sway_output *focused_output = node_get_output(focus); struct sway_output *output = node_get_output(node); if (output != focused_output) { - seat_set_focus_warp(seat, node, false); + seat_set_focus(seat, node); } } else if (node->type == N_CONTAINER && node->sway_container->view) { // Focus node if the following are true: @@ -607,14 +607,14 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, if (!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && node != prev_node && view_is_visible(node->sway_container->view)) { - seat_set_focus_warp(seat, node, false); + seat_set_focus(seat, node); } else { struct sway_node *next_focus = seat_get_focus_inactive(seat, &root->node); if (next_focus && next_focus->type == N_CONTAINER && next_focus->sway_container->view && view_is_visible(next_focus->sway_container->view)) { - seat_set_focus_warp(seat, next_focus, false); + seat_set_focus(seat, next_focus); } } } diff --git a/sway/input/seat.c b/sway/input/seat.c index d8d2f3a4..60ee27d0 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -640,13 +640,13 @@ void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node) { node_set_dirty(node_get_parent(node)); } -void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, - bool warp) { +void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { if (seat->focused_layer) { return; } struct sway_node *last_focus = seat_get_focus(seat); + seat->prev_focus = last_focus; if (last_focus == node) { return; } @@ -678,8 +678,6 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, } } - struct sway_output *last_output = last_workspace ? - last_workspace->output : NULL; struct sway_output *new_output = new_workspace->output; if (last_workspace != new_workspace && new_output) { @@ -774,21 +772,6 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, workspace_consider_destroy(last_workspace); } - if (last_focus && warp) { - if (container && config->mouse_warping == WARP_CONTAINER) { - cursor_warp_to_container(seat->cursor, container); - cursor_send_pointer_motion(seat->cursor, 0, true); - } else if (new_output != last_output && - config->mouse_warping >= WARP_OUTPUT) { - if (container) { - cursor_warp_to_container(seat->cursor, container); - } else { - cursor_warp_to_workspace(seat->cursor, new_workspace); - } - cursor_send_pointer_motion(seat->cursor, 0, true); - } - } - seat->has_focus = true; if (config->smart_gaps) { @@ -800,18 +783,14 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, update_debug_tree(); } -void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { - seat_set_focus_warp(seat, node, true); -} - void seat_set_focus_container(struct sway_seat *seat, struct sway_container *con) { - seat_set_focus_warp(seat, con ? &con->node : NULL, true); + seat_set_focus(seat, con ? &con->node : NULL); } void seat_set_focus_workspace(struct sway_seat *seat, struct sway_workspace *ws) { - seat_set_focus_warp(seat, ws ? &ws->node : NULL, true); + seat_set_focus(seat, ws ? &ws->node : NULL); } void seat_set_focus_surface(struct sway_seat *seat, -- cgit v1.2.3