aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-18 23:08:45 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-18 23:08:45 +1000
commit24a90e5d86441fc345356eb3767e5a6880dcedbd (patch)
treedbf14c684b7802c2f2876fc8b11636bec26abc3d /sway/input/seat.c
parentMerge pull request #2868 from emersion/xcursor-env (diff)
downloadsway-24a90e5d86441fc345356eb3767e5a6880dcedbd.tar.gz
sway-24a90e5d86441fc345356eb3767e5a6880dcedbd.tar.zst
sway-24a90e5d86441fc345356eb3767e5a6880dcedbd.zip
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.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c29
1 files changed, 4 insertions, 25 deletions
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) {
640 node_set_dirty(node_get_parent(node)); 640 node_set_dirty(node_get_parent(node));
641} 641}
642 642
643void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, 643void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
644 bool warp) {
645 if (seat->focused_layer) { 644 if (seat->focused_layer) {
646 return; 645 return;
647 } 646 }
648 647
649 struct sway_node *last_focus = seat_get_focus(seat); 648 struct sway_node *last_focus = seat_get_focus(seat);
649 seat->prev_focus = last_focus;
650 if (last_focus == node) { 650 if (last_focus == node) {
651 return; 651 return;
652 } 652 }
@@ -678,8 +678,6 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
678 } 678 }
679 } 679 }
680 680
681 struct sway_output *last_output = last_workspace ?
682 last_workspace->output : NULL;
683 struct sway_output *new_output = new_workspace->output; 681 struct sway_output *new_output = new_workspace->output;
684 682
685 if (last_workspace != new_workspace && new_output) { 683 if (last_workspace != new_workspace && new_output) {
@@ -774,21 +772,6 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
774 workspace_consider_destroy(last_workspace); 772 workspace_consider_destroy(last_workspace);
775 } 773 }
776 774
777 if (last_focus && warp) {
778 if (container && config->mouse_warping == WARP_CONTAINER) {
779 cursor_warp_to_container(seat->cursor, container);
780 cursor_send_pointer_motion(seat->cursor, 0, true);
781 } else if (new_output != last_output &&
782 config->mouse_warping >= WARP_OUTPUT) {
783 if (container) {
784 cursor_warp_to_container(seat->cursor, container);
785 } else {
786 cursor_warp_to_workspace(seat->cursor, new_workspace);
787 }
788 cursor_send_pointer_motion(seat->cursor, 0, true);
789 }
790 }
791
792 seat->has_focus = true; 775 seat->has_focus = true;
793 776
794 if (config->smart_gaps) { 777 if (config->smart_gaps) {
@@ -800,18 +783,14 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node,
800 update_debug_tree(); 783 update_debug_tree();
801} 784}
802 785
803void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
804 seat_set_focus_warp(seat, node, true);
805}
806
807void seat_set_focus_container(struct sway_seat *seat, 786void seat_set_focus_container(struct sway_seat *seat,
808 struct sway_container *con) { 787 struct sway_container *con) {
809 seat_set_focus_warp(seat, con ? &con->node : NULL, true); 788 seat_set_focus(seat, con ? &con->node : NULL);
810} 789}
811 790
812void seat_set_focus_workspace(struct sway_seat *seat, 791void seat_set_focus_workspace(struct sway_seat *seat,
813 struct sway_workspace *ws) { 792 struct sway_workspace *ws) {
814 seat_set_focus_warp(seat, ws ? &ws->node : NULL, true); 793 seat_set_focus(seat, ws ? &ws->node : NULL);
815} 794}
816 795
817void seat_set_focus_surface(struct sway_seat *seat, 796void seat_set_focus_surface(struct sway_seat *seat,