From 35496f461f6afa4b0ae0d07f429817543e98105c Mon Sep 17 00:00:00 2001 From: Kory Prince Date: Sat, 1 Jul 2023 03:09:47 -0500 Subject: [PATCH 1/3] fix regression from #2232: reverse-scrolling was not applied to GTK_SCROLL_SMOOTH events --- src/AModule.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AModule.cpp b/src/AModule.cpp index 1bfb2def..dc866d44 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -121,9 +121,9 @@ AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) { } if (distance_scrolled_y_ < -threshold) { - dir = SCROLL_DIR::UP; + dir = reverse ? SCROLL_DIR::DOWN : SCROLL_DIR::UP; } else if (distance_scrolled_y_ > threshold) { - dir = SCROLL_DIR::DOWN; + dir = reverse ? SCROLL_DIR::UP : SCROLL_DIR::DOWN; } else if (distance_scrolled_x_ > threshold) { dir = SCROLL_DIR::RIGHT; } else if (distance_scrolled_x_ < -threshold) { From 7a01143359228a3bda8874b12b9fb420d7e76f3b Mon Sep 17 00:00:00 2001 From: Kory Prince Date: Sat, 1 Jul 2023 01:53:20 -0500 Subject: [PATCH 2/3] ignore reverse-scrolling from mouse wheel --- src/AModule.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/AModule.cpp b/src/AModule.cpp index dc866d44..76999e1d 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -100,6 +100,12 @@ AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) { // only affects up/down bool reverse = config_["reverse-scrolling"].asBool(); + // ignore reverse-scrolling if event comes from a mouse wheel + GdkDevice* device = gdk_event_get_source_device((GdkEvent *)e); + if (device != NULL && gdk_device_get_source(device) == GDK_SOURCE_MOUSE) { + reverse = false; + } + switch (e->direction) { case GDK_SCROLL_UP: return reverse ? SCROLL_DIR::DOWN : SCROLL_DIR::UP; From 1ba05d1ffa00014497fafbf84617ed135b4f6cdc Mon Sep 17 00:00:00 2001 From: Kory Prince Date: Sat, 1 Jul 2023 10:35:37 -0500 Subject: [PATCH 3/3] add reverse-mouse-scrolling to configure mouse wheel reverse scrolling --- src/AModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AModule.cpp b/src/AModule.cpp index 76999e1d..b84f551a 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -99,11 +99,12 @@ bool AModule::handleToggle(GdkEventButton* const& e) { AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) { // only affects up/down bool reverse = config_["reverse-scrolling"].asBool(); + bool reverse_mouse = config_["reverse-mouse-scrolling"].asBool(); // ignore reverse-scrolling if event comes from a mouse wheel GdkDevice* device = gdk_event_get_source_device((GdkEvent *)e); if (device != NULL && gdk_device_get_source(device) == GDK_SOURCE_MOUSE) { - reverse = false; + reverse = reverse_mouse; } switch (e->direction) {