diff options
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index c539df40..d89f64d8 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #elif __FreeBSD__ | 5 | #elif __FreeBSD__ |
6 | #include <dev/evdev/input-event-codes.h> | 6 | #include <dev/evdev/input-event-codes.h> |
7 | #endif | 7 | #endif |
8 | #include <float.h> | ||
8 | #include <limits.h> | 9 | #include <limits.h> |
9 | #include <wlr/types/wlr_cursor.h> | 10 | #include <wlr/types/wlr_cursor.h> |
10 | #include <wlr/types/wlr_xcursor_manager.h> | 11 | #include <wlr/types/wlr_xcursor_manager.h> |
@@ -63,7 +64,7 @@ static struct sway_node *node_at_coords( | |||
63 | struct sway_seat *seat, double lx, double ly, | 64 | struct sway_seat *seat, double lx, double ly, |
64 | struct wlr_surface **surface, double *sx, double *sy) { | 65 | struct wlr_surface **surface, double *sx, double *sy) { |
65 | // check for unmanaged views first | 66 | // check for unmanaged views first |
66 | #ifdef HAVE_XWAYLAND | 67 | #if HAVE_XWAYLAND |
67 | struct wl_list *unmanaged = &root->xwayland_unmanaged; | 68 | struct wl_list *unmanaged = &root->xwayland_unmanaged; |
68 | struct sway_xwayland_unmanaged *unmanaged_surface; | 69 | struct sway_xwayland_unmanaged *unmanaged_surface; |
69 | wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { | 70 | wl_list_for_each_reverse(unmanaged_surface, unmanaged, link) { |
@@ -348,7 +349,7 @@ static void handle_move_tiling_motion(struct sway_seat *seat, | |||
348 | } | 349 | } |
349 | 350 | ||
350 | // Find the closest edge | 351 | // Find the closest edge |
351 | size_t thickness = fmin(con->view->width, con->view->height) * 0.3; | 352 | size_t thickness = fmin(con->content_width, con->content_height) * 0.3; |
352 | size_t closest_dist = INT_MAX; | 353 | size_t closest_dist = INT_MAX; |
353 | size_t dist; | 354 | size_t dist; |
354 | seat->op_target_edge = WLR_EDGE_NONE; | 355 | seat->op_target_edge = WLR_EDGE_NONE; |
@@ -374,10 +375,10 @@ static void handle_move_tiling_motion(struct sway_seat *seat, | |||
374 | } | 375 | } |
375 | 376 | ||
376 | seat->op_target_node = node; | 377 | seat->op_target_node = node; |
377 | seat->op_drop_box.x = con->view->x; | 378 | seat->op_drop_box.x = con->content_x; |
378 | seat->op_drop_box.y = con->view->y; | 379 | seat->op_drop_box.y = con->content_y; |
379 | seat->op_drop_box.width = con->view->width; | 380 | seat->op_drop_box.width = con->content_width; |
380 | seat->op_drop_box.height = con->view->height; | 381 | seat->op_drop_box.height = con->content_height; |
381 | resize_box(&seat->op_drop_box, seat->op_target_edge, thickness); | 382 | resize_box(&seat->op_drop_box, seat->op_target_edge, thickness); |
382 | desktop_damage_box(&seat->op_drop_box); | 383 | desktop_damage_box(&seat->op_drop_box); |
383 | } | 384 | } |
@@ -498,13 +499,10 @@ static void handle_resize_floating_motion(struct sway_seat *seat, | |||
498 | con->width += relative_grow_width; | 499 | con->width += relative_grow_width; |
499 | con->height += relative_grow_height; | 500 | con->height += relative_grow_height; |
500 | 501 | ||
501 | if (con->view) { | 502 | con->content_x += relative_grow_x; |
502 | struct sway_view *view = con->view; | 503 | con->content_y += relative_grow_y; |
503 | view->x += relative_grow_x; | 504 | con->content_width += relative_grow_width; |
504 | view->y += relative_grow_y; | 505 | con->content_height += relative_grow_height; |
505 | view->width += relative_grow_width; | ||
506 | view->height += relative_grow_height; | ||
507 | } | ||
508 | 506 | ||
509 | arrange_container(con); | 507 | arrange_container(con); |
510 | } | 508 | } |
@@ -637,7 +635,8 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
637 | cursor->previous.y = cursor->cursor->y; | 635 | cursor->previous.y = cursor->cursor->y; |
638 | cursor->previous.node = node; | 636 | cursor->previous.node = node; |
639 | 637 | ||
640 | if (node && config->focus_follows_mouse) { | 638 | if (node && (config->focus_follows_mouse == FOLLOWS_YES || |
639 | config->focus_follows_mouse == FOLLOWS_ALWAYS)) { | ||
641 | struct sway_node *focus = seat_get_focus(seat); | 640 | struct sway_node *focus = seat_get_focus(seat); |
642 | if (focus && node->type == N_WORKSPACE) { | 641 | if (focus && node->type == N_WORKSPACE) { |
643 | // Only follow the mouse if it would move to a new output | 642 | // Only follow the mouse if it would move to a new output |
@@ -652,9 +651,10 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
652 | // - cursor is over a new view, i.e. entered a new window; and | 651 | // - cursor is over a new view, i.e. entered a new window; and |
653 | // - the new view is visible, i.e. not hidden in a stack or tab; and | 652 | // - the new view is visible, i.e. not hidden in a stack or tab; and |
654 | // - the seat does not have a keyboard grab | 653 | // - the seat does not have a keyboard grab |
655 | if (!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && | 654 | if ((!wlr_seat_keyboard_has_grab(cursor->seat->wlr_seat) && |
656 | node != prev_node && | 655 | node != prev_node && |
657 | view_is_visible(node->sway_container->view)) { | 656 | view_is_visible(node->sway_container->view)) || |
657 | config->focus_follows_mouse == FOLLOWS_ALWAYS) { | ||
658 | seat_set_focus(seat, node); | 658 | seat_set_focus(seat, node); |
659 | } else { | 659 | } else { |
660 | struct sway_node *next_focus = | 660 | struct sway_node *next_focus = |
@@ -861,8 +861,8 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
861 | } | 861 | } |
862 | 862 | ||
863 | // Handle tiling resize via border | 863 | // Handle tiling resize via border |
864 | if (resize_edge && button == BTN_LEFT && state == WLR_BUTTON_PRESSED && | 864 | if (cont && resize_edge && button == BTN_LEFT && |
865 | !is_floating) { | 865 | state == WLR_BUTTON_PRESSED && !is_floating) { |
866 | seat_set_focus_container(seat, cont); | 866 | seat_set_focus_container(seat, cont); |
867 | seat_begin_resize_tiling(seat, cont, button, edge); | 867 | seat_begin_resize_tiling(seat, cont, button, edge); |
868 | return; | 868 | return; |
@@ -871,7 +871,8 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
871 | // Handle tiling resize via mod | 871 | // Handle tiling resize via mod |
872 | bool mod_pressed = keyboard && | 872 | bool mod_pressed = keyboard && |
873 | (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod); | 873 | (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod); |
874 | if (!is_floating_or_child && mod_pressed && state == WLR_BUTTON_PRESSED) { | 874 | if (cont && !is_floating_or_child && mod_pressed && |
875 | state == WLR_BUTTON_PRESSED) { | ||
875 | uint32_t btn_resize = config->floating_mod_inverse ? | 876 | uint32_t btn_resize = config->floating_mod_inverse ? |
876 | BTN_LEFT : BTN_RIGHT; | 877 | BTN_LEFT : BTN_RIGHT; |
877 | if (button == btn_resize) { | 878 | if (button == btn_resize) { |
@@ -899,7 +900,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
899 | } | 900 | } |
900 | 901 | ||
901 | // Handle beginning floating move | 902 | // Handle beginning floating move |
902 | if (is_floating_or_child && !is_fullscreen_or_child && | 903 | if (cont && is_floating_or_child && !is_fullscreen_or_child && |
903 | state == WLR_BUTTON_PRESSED) { | 904 | state == WLR_BUTTON_PRESSED) { |
904 | uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; | 905 | uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; |
905 | if (button == btn_move && state == WLR_BUTTON_PRESSED && | 906 | if (button == btn_move && state == WLR_BUTTON_PRESSED && |
@@ -914,7 +915,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
914 | } | 915 | } |
915 | 916 | ||
916 | // Handle beginning floating resize | 917 | // Handle beginning floating resize |
917 | if (is_floating_or_child && !is_fullscreen_or_child && | 918 | if (cont && is_floating_or_child && !is_fullscreen_or_child && |
918 | state == WLR_BUTTON_PRESSED) { | 919 | state == WLR_BUTTON_PRESSED) { |
919 | // Via border | 920 | // Via border |
920 | if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) { | 921 | if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) { |
@@ -979,6 +980,8 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
979 | static void dispatch_cursor_axis(struct sway_cursor *cursor, | 980 | static void dispatch_cursor_axis(struct sway_cursor *cursor, |
980 | struct wlr_event_pointer_axis *event) { | 981 | struct wlr_event_pointer_axis *event) { |
981 | struct sway_seat *seat = cursor->seat; | 982 | struct sway_seat *seat = cursor->seat; |
983 | struct sway_input_device *input_device = event->device->data; | ||
984 | struct input_config *ic = input_device_get_config(input_device); | ||
982 | 985 | ||
983 | // Determine what's under the cursor | 986 | // Determine what's under the cursor |
984 | struct wlr_surface *surface = NULL; | 987 | struct wlr_surface *surface = NULL; |
@@ -990,6 +993,8 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor, | |||
990 | enum wlr_edges edge = cont ? find_edge(cont, cursor) : WLR_EDGE_NONE; | 993 | enum wlr_edges edge = cont ? find_edge(cont, cursor) : WLR_EDGE_NONE; |
991 | bool on_border = edge != WLR_EDGE_NONE; | 994 | bool on_border = edge != WLR_EDGE_NONE; |
992 | bool on_titlebar = cont && !on_border && !surface; | 995 | bool on_titlebar = cont && !on_border && !surface; |
996 | float scroll_factor = | ||
997 | (ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor; | ||
993 | 998 | ||
994 | // Scrolling on a tabbed or stacked title bar | 999 | // Scrolling on a tabbed or stacked title bar |
995 | if (on_titlebar) { | 1000 | if (on_titlebar) { |
@@ -1000,7 +1005,7 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor, | |||
1000 | seat_get_active_tiling_child(seat, tabcontainer); | 1005 | seat_get_active_tiling_child(seat, tabcontainer); |
1001 | list_t *siblings = container_get_siblings(cont); | 1006 | list_t *siblings = container_get_siblings(cont); |
1002 | int desired = list_find(siblings, active->sway_container) + | 1007 | int desired = list_find(siblings, active->sway_container) + |
1003 | event->delta_discrete; | 1008 | round(scroll_factor * event->delta_discrete); |
1004 | if (desired < 0) { | 1009 | if (desired < 0) { |
1005 | desired = 0; | 1010 | desired = 0; |
1006 | } else if (desired >= siblings->length) { | 1011 | } else if (desired >= siblings->length) { |
@@ -1024,7 +1029,8 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor, | |||
1024 | } | 1029 | } |
1025 | 1030 | ||
1026 | wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, | 1031 | wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, |
1027 | event->orientation, event->delta, event->delta_discrete, event->source); | 1032 | event->orientation, scroll_factor * event->delta, |
1033 | round(scroll_factor * event->delta_discrete), event->source); | ||
1028 | } | 1034 | } |
1029 | 1035 | ||
1030 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { | 1036 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { |