diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/focus.c | 29 | ||||
-rw-r--r-- | sway/commands/swap.c | 4 |
2 files changed, 26 insertions, 7 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 44adb95b..46304ae0 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -34,6 +34,24 @@ static bool parse_movement_direction(const char *name, return true; } +static void consider_warp_to_focus(struct sway_seat *seat) { + struct sway_node *focus = seat_get_focus(seat); + if (config->mouse_warping == WARP_NO || !focus || !seat->prev_focus) { + return; + } + if (config->mouse_warping == WARP_OUTPUT && + node_get_output(focus) == node_get_output(seat->prev_focus)) { + return; + } + + if (focus->type == N_CONTAINER) { + cursor_warp_to_container(seat->cursor, focus->sway_container); + } else { + cursor_warp_to_workspace(seat->cursor, focus->sway_workspace); + } + cursor_send_pointer_motion(seat->cursor, 0, false); +} + /** * Get node in the direction of newly entered output. */ @@ -181,7 +199,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws, } if (new_focus) { seat_set_focus_container(seat, new_focus); - cursor_send_pointer_motion(seat->cursor, 0, true); + consider_warp_to_focus(seat); } else { return cmd_results_new(CMD_FAILURE, "focus", "Failed to find a %s container in workspace", @@ -214,7 +232,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat, free(identifier); if (output) { seat_set_focus(seat, seat_get_focus_inactive(seat, &output->node)); - cursor_send_pointer_motion(seat->cursor, 0, true); + consider_warp_to_focus(seat); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); @@ -235,6 +253,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { if (argc == 0 && container) { seat_set_focus_container(seat, container); + consider_warp_to_focus(seat); cursor_send_pointer_motion(seat->cursor, 0, true); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -264,7 +283,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { struct sway_node *focus = seat_get_active_tiling_child(seat, node); if (focus) { seat_set_focus(seat, focus); - cursor_send_pointer_motion(seat->cursor, 0, true); + consider_warp_to_focus(seat); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -284,7 +303,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { struct sway_node *node = get_node_in_output_direction(new_output, direction); seat_set_focus(seat, node); - cursor_send_pointer_motion(seat->cursor, 0, true); + consider_warp_to_focus(seat); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -292,7 +311,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { node_get_in_direction(container, seat, direction); if (next_focus) { seat_set_focus(seat, next_focus); - cursor_send_pointer_motion(seat->cursor, 0, true); + consider_warp_to_focus(seat); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 9cc0d5c2..8a6dfdbd 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -61,13 +61,13 @@ static void swap_focus(struct sway_container *con1, enum sway_container_layout layout2 = container_parent_layout(con2); if (focus == con1 && (layout2 == L_TABBED || layout2 == L_STACKED)) { if (workspace_is_visible(ws2)) { - seat_set_focus_warp(seat, &con2->node, false); + seat_set_focus(seat, &con2->node); } seat_set_focus_container(seat, ws1 != ws2 ? con2 : con1); } else if (focus == con2 && (layout1 == L_TABBED || layout1 == L_STACKED)) { if (workspace_is_visible(ws1)) { - seat_set_focus_warp(seat, &con1->node, false); + seat_set_focus(seat, &con1->node); } seat_set_focus_container(seat, ws1 != ws2 ? con1 : con2); } else if (ws1 != ws2) { |