From 0f8c156f243c0765dfc24f725357a1bbbce2628e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20G=C3=BCnzler?= Date: Mon, 12 Jun 2023 13:55:28 +0900 Subject: [PATCH 1/2] Lift reverse-scrolling option into AModule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The option is generally useful when scrolling is used, when configuring input devices to use "natural scroll direction". Both backlight and pulseaudio were using different implementations, this unifies and documents them. Signed-off-by: Robert Günzler --- src/AModule.cpp | 7 +++++-- src/modules/backlight.cpp | 8 -------- src/modules/pulseaudio.cpp | 7 ------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/AModule.cpp b/src/AModule.cpp index 459e5620..1bfb2def 100644 --- a/src/AModule.cpp +++ b/src/AModule.cpp @@ -97,11 +97,14 @@ bool AModule::handleToggle(GdkEventButton* const& e) { } AModule::SCROLL_DIR AModule::getScrollDir(GdkEventScroll* e) { + // only affects up/down + bool reverse = config_["reverse-scrolling"].asBool(); + switch (e->direction) { case GDK_SCROLL_UP: - return SCROLL_DIR::UP; + return reverse ? SCROLL_DIR::DOWN : SCROLL_DIR::UP; case GDK_SCROLL_DOWN: - return SCROLL_DIR::DOWN; + return reverse ? SCROLL_DIR::UP : SCROLL_DIR::DOWN; case GDK_SCROLL_LEFT: return SCROLL_DIR::LEFT; case GDK_SCROLL_RIGHT: diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index eb7a7e9a..58d14dde 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -305,14 +305,6 @@ bool waybar::modules::Backlight::handleScroll(GdkEventScroll *e) { return true; } - if (config_["reverse-scrolling"].asBool()) { - if (dir == SCROLL_DIR::UP) { - dir = SCROLL_DIR::DOWN; - } else if (dir == SCROLL_DIR::DOWN) { - dir = SCROLL_DIR::UP; - } - } - // Get scroll step double step = 1; diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index 586b6cc1..d35e2983 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -81,13 +81,6 @@ bool waybar::modules::Pulseaudio::handleScroll(GdkEventScroll *e) { if (dir == SCROLL_DIR::NONE) { return true; } - if (config_["reverse-scrolling"].asInt() == 1) { - if (dir == SCROLL_DIR::UP) { - dir = SCROLL_DIR::DOWN; - } else if (dir == SCROLL_DIR::DOWN) { - dir = SCROLL_DIR::UP; - } - } double volume_tick = static_cast(PA_VOLUME_NORM) / 100; pa_volume_t change = volume_tick; pa_cvolume pa_volume = pa_volume_; From 73c7e5453540e5883bf83297a765e8fcc5d92801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20G=C3=BCnzler?= Date: Mon, 12 Jun 2023 14:08:22 +0900 Subject: [PATCH 2/2] pulseaudio: document reverse-scrolling option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- man/waybar-pulseaudio.5.scd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/man/waybar-pulseaudio.5.scd b/man/waybar-pulseaudio.5.scd index b941c22c..b0722654 100644 --- a/man/waybar-pulseaudio.5.scd +++ b/man/waybar-pulseaudio.5.scd @@ -91,6 +91,10 @@ Additionally you can control the volume by scrolling *up* or *down* while the cu typeof: double ++ Threshold to be used when scrolling. +*reverse-scrolling*: ++ + typeof: bool ++ + Option to reverse the scroll direction. + *tooltip*: ++ typeof: bool ++ default: true ++