aboutsummaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 052789ca..5fae2f7a 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -842,12 +842,13 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
842 return EVENT_PASSTHROUGH; 842 return EVENT_PASSTHROUGH;
843} 843}
844 844
845static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_point *origin) { 845static bool handle_pointer_motion(wlc_handle handle, uint32_t time, double x, double y) {
846 if (desktop_shell.is_locked) { 846 if (desktop_shell.is_locked) {
847 return EVENT_PASSTHROUGH; 847 return EVENT_PASSTHROUGH;
848 } 848 }
849 849
850 struct wlc_point new_origin = *origin; 850 double new_x = x;
851 double new_y = y;
851 // Switch to adjacent output if touching output edge. 852 // Switch to adjacent output if touching output edge.
852 // 853 //
853 // Since this doesn't currently support moving windows between outputs we 854 // Since this doesn't currently support moving windows between outputs we
@@ -856,45 +857,43 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
856 !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) { 857 !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) {
857 858
858 swayc_t *output = swayc_active_output(), *adjacent = NULL; 859 swayc_t *output = swayc_active_output(), *adjacent = NULL;
859 struct wlc_point abs_pos = *origin; 860 struct wlc_point abs_pos = { .x = x + output->x, .y = y + output->y };
860 abs_pos.x += output->x; 861 if (x <= 0) { // Left edge
861 abs_pos.y += output->y;
862 if (origin->x == 0) { // Left edge
863 if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT, &abs_pos, false))) { 862 if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT, &abs_pos, false))) {
864 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 863 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
865 new_origin.x = adjacent->width; 864 new_x = adjacent->width;
866 // adjust for differently aligned outputs (well, this is 865 // adjust for differently aligned outputs (well, this is
867 // only correct when the two outputs have the same 866 // only correct when the two outputs have the same
868 // resolution or the same dpi I guess, it should take 867 // resolution or the same dpi I guess, it should take
869 // physical attributes into account) 868 // physical attributes into account)
870 new_origin.y += (output->y - adjacent->y); 869 new_y += (output->y - adjacent->y);
871 } 870 }
872 } 871 }
873 } else if ((double)origin->x == output->width) { // Right edge 872 } else if (x >= output->width) { // Right edge
874 if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT, &abs_pos, false))) { 873 if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT, &abs_pos, false))) {
875 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 874 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
876 new_origin.x = 0; 875 new_x = 0;
877 new_origin.y += (output->y - adjacent->y); 876 new_y += (output->y - adjacent->y);
878 } 877 }
879 } 878 }
880 } else if (origin->y == 0) { // Top edge 879 } else if (y <= 0) { // Top edge
881 if ((adjacent = swayc_adjacent_output(output, MOVE_UP, &abs_pos, false))) { 880 if ((adjacent = swayc_adjacent_output(output, MOVE_UP, &abs_pos, false))) {
882 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 881 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
883 new_origin.y = adjacent->height; 882 new_y = adjacent->height;
884 new_origin.x += (output->x - adjacent->x); 883 new_x += (output->x - adjacent->x);
885 } 884 }
886 } 885 }
887 } else if ((double)origin->y == output->height) { // Bottom edge 886 } else if (y >= output->height) { // Bottom edge
888 if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN, &abs_pos, false))) { 887 if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN, &abs_pos, false))) {
889 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 888 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
890 new_origin.y = 0; 889 new_y = 0;
891 new_origin.x += (output->x - adjacent->x); 890 new_x += (output->x - adjacent->x);
892 } 891 }
893 } 892 }
894 } 893 }
895 } 894 }
896 895
897 pointer_position_set(&new_origin, false); 896 pointer_position_set(new_x, new_y, false);
898 897
899 swayc_t *focused = get_focused_container(&root_container); 898 swayc_t *focused = get_focused_container(&root_container);
900 if (focused->type == C_VIEW) { 899 if (focused->type == C_VIEW) {
@@ -1122,7 +1121,7 @@ void register_wlc_handlers() {
1122 wlc_set_view_request_state_cb(handle_view_state_request); 1121 wlc_set_view_request_state_cb(handle_view_state_request);
1123 wlc_set_view_properties_updated_cb(handle_view_properties_updated); 1122 wlc_set_view_properties_updated_cb(handle_view_properties_updated);
1124 wlc_set_keyboard_key_cb(handle_key); 1123 wlc_set_keyboard_key_cb(handle_key);
1125 wlc_set_pointer_motion_cb(handle_pointer_motion); 1124 wlc_set_pointer_motion_cb_v2(handle_pointer_motion);
1126 wlc_set_pointer_button_cb(handle_pointer_button); 1125 wlc_set_pointer_button_cb(handle_pointer_button);
1127 wlc_set_pointer_scroll_cb(handle_pointer_scroll); 1126 wlc_set_pointer_scroll_cb(handle_pointer_scroll);
1128 wlc_set_compositor_ready_cb(handle_wlc_ready); 1127 wlc_set_compositor_ready_cb(handle_wlc_ready);