aboutsummaryrefslogtreecommitdiff
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorSpencer Michaels <spencer@smichaels.net>2018-11-17 14:31:33 -0500
committerSpencer Michaels <spencer@smichaels.net>2018-11-18 13:49:30 -0500
commit70bc4c3ab6c408850543d827f788ef310fdb269c (patch)
tree265d4ea923f1329d1e7661c0f92a242337318d58 /sway/input/cursor.c
parentb87250425fe13149e41b346f15c5cf808f376438 (diff)
Add scroll factor config option.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c10
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 @@
#elif __FreeBSD__
#include <dev/evdev/input-event-codes.h>
#endif
+#include <float.h>
#include <limits.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_xcursor_manager.h>
@@ -979,6 +980,8 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
static void dispatch_cursor_axis(struct sway_cursor *cursor,
struct wlr_event_pointer_axis *event) {
struct sway_seat *seat = cursor->seat;
+ struct sway_input_device *input_device = event->device->data;
+ struct input_config *ic = input_device_get_config(input_device);
// Determine what's under the cursor
struct wlr_surface *surface = NULL;
@@ -990,6 +993,8 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor,
enum wlr_edges edge = cont ? find_edge(cont, cursor) : WLR_EDGE_NONE;
bool on_border = edge != WLR_EDGE_NONE;
bool on_titlebar = cont && !on_border && !surface;
+ float scroll_factor =
+ (ic == NULL || ic->scroll_factor == FLT_MIN) ? 1.0f : ic->scroll_factor;
// Scrolling on a tabbed or stacked title bar
if (on_titlebar) {
@@ -1000,7 +1005,7 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor,
seat_get_active_tiling_child(seat, tabcontainer);
list_t *siblings = container_get_siblings(cont);
int desired = list_find(siblings, active->sway_container) +
- event->delta_discrete;
+ round(scroll_factor * event->delta_discrete);
if (desired < 0) {
desired = 0;
} else if (desired >= siblings->length) {
@@ -1024,7 +1029,8 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor,
}
wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec,
- event->orientation, event->delta, event->delta_discrete, event->source);
+ event->orientation, scroll_factor * event->delta,
+ round(scroll_factor * event->delta_discrete), event->source);
}
static void handle_cursor_axis(struct wl_listener *listener, void *data) {