diff options
author | Spencer Michaels <spencer@smichaels.net> | 2018-11-17 14:31:33 -0500 |
---|---|---|
committer | Spencer Michaels <spencer@smichaels.net> | 2018-11-18 13:49:30 -0500 |
commit | 70bc4c3ab6c408850543d827f788ef310fdb269c (patch) | |
tree | 265d4ea923f1329d1e7661c0f92a242337318d58 /sway/input/cursor.c | |
parent | Merge pull request #3147 from emersion/set10 (diff) | |
download | sway-70bc4c3ab6c408850543d827f788ef310fdb269c.tar.gz sway-70bc4c3ab6c408850543d827f788ef310fdb269c.tar.zst sway-70bc4c3ab6c408850543d827f788ef310fdb269c.zip |
Add scroll factor config option.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index c6b7414c..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> |
@@ -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) { |