From a2c1392c120f325f442c295592d49706a5486402 Mon Sep 17 00:00:00 2001 From: Farseen Date: Sun, 3 Apr 2022 03:15:54 +0530 Subject: [PATCH] feat(pulseaudio): define reverse-scroll option (#2664) * pulseaudio: define reverse-scroll option When we enable natural scrolling option in libinput, it sends scroll down event when we swipe up on the touchpad. This makes the pulseaudio module feel weird. This option fixes that. * Update CHANGELOG.md Co-authored-by: Patrick Ziegler --- CHANGELOG.md | 3 +++ include/modules/pulseaudio.hpp | 1 + src/modules/pulseaudio.cpp | 10 ++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db96e56e..9f8793e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking - `custom/script` now doesn't hide failing script if it's output is not changing ([`#2636`](https://github.com/polybar/polybar/issues/2636)). Somewhat similar behaviour can be imitated with `format-fail`, if necessary. +### Added +- `internal/pulseaudio`: `reverse-scroll` option ([`#2664`](https://github.com/polybar/polybar/pull/2664)) + ## [3.6.1] - 2022-03-05 ### Build - Fixed compiler warning in Clang 13 ([`#2613`](https://github.com/polybar/polybar/pull/2613)) diff --git a/include/modules/pulseaudio.hpp b/include/modules/pulseaudio.hpp index 85a90b58..37868f39 100644 --- a/include/modules/pulseaudio.hpp +++ b/include/modules/pulseaudio.hpp @@ -53,6 +53,7 @@ namespace modules { atomic m_muted{false}; atomic m_volume{0}; atomic m_decibels{0}; + atomic m_reverse_scroll{false}; }; } // namespace modules diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index 1eebb4b2..e2d9d79a 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -26,6 +26,7 @@ namespace modules { auto sink_name = m_conf.get(name(), "sink", ""s); bool m_max_volume = m_conf.get(name(), "use-ui-max", true); + m_reverse_scroll = m_conf.get(name(), "reverse-scroll", false); try { m_pulseaudio = std::make_unique(m_log, move(sink_name), m_max_volume); @@ -124,8 +125,13 @@ namespace modules { } m_builder->action(mousebtn::LEFT, *this, EVENT_TOGGLE, ""); - m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_INC, ""); - m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_DEC, ""); + if (!m_reverse_scroll) { + m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_INC, ""); + m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_DEC, ""); + } else { + m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_DEC, ""); + m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_INC, ""); + } } m_builder->append(output);