From ae4ac6d3b709ee974dcad70114630b1bce928806 Mon Sep 17 00:00:00 2001 From: hiqqup Date: Fri, 8 Dec 2023 17:18:42 +0100 Subject: [PATCH] implement scroll factor --- config.def.h | 1 + dwl.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/config.def.h b/config.def.h index 5375eb5..047168a 100644 --- a/config.def.h +++ b/config.def.h @@ -66,6 +66,7 @@ static const int natural_scrolling = 0; static const int disable_while_typing = 1; static const int left_handed = 0; static const int middle_button_emulation = 0; +static const double scroll_factor = 1; /* You can choose between: LIBINPUT_CONFIG_SCROLL_NO_SCROLL LIBINPUT_CONFIG_SCROLL_2FG diff --git a/dwl.c b/dwl.c index 6aa2cf3..4d805c9 100644 --- a/dwl.c +++ b/dwl.c @@ -1,6 +1,7 @@ /* * See LICENSE file for copyright and license details. */ +#include #include #include #include @@ -226,6 +227,8 @@ typedef struct { struct wl_listener destroy; } SessionLock; +typedef double (*hooked_axis_t)(struct libinput_event_pointer*, enum libinput_pointer_axis); + /* function declarations */ static void applybounds(Client *c, struct wlr_box *bbox); static void applyrules(Client *c); @@ -978,6 +981,18 @@ createnotify(struct wl_listener *listener, void *data) LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle); } +double +libinput_event_pointer_get_scroll_value(struct libinput_event_pointer* event, enum libinput_pointer_axis axis) +{ + void* sym = dlsym(RTLD_NEXT, "libinput_event_pointer_get_scroll_value"); + hooked_axis_t hooked = *(hooked_axis_t*)(&sym); + if (axis == LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) { + return hooked(event, axis) * scroll_factor; + } else { + return hooked(event, axis) * scroll_factor; + } +} + void createpointer(struct wlr_pointer *pointer) {