From 09c0960801c1380e1e81ad99074bdbff30ac2c79 Mon Sep 17 00:00:00 2001 From: encbar5 <8845322+encbar5@users.noreply.github.com> Date: Sat, 23 Mar 2024 08:22:19 -0500 Subject: [PATCH] Fix clock on-scroll value not being used for calendar, which was broken by 86a3898 --- include/modules/clock.hpp | 1 + src/modules/clock.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/modules/clock.hpp b/include/modules/clock.hpp index 8b597c4e..e0c2b4fe 100644 --- a/include/modules/clock.hpp +++ b/include/modules/clock.hpp @@ -41,6 +41,7 @@ class Clock final : public ALabel { const int cldMonColLen_{20}; // calendar month column length WS cldWPos_{WS::HIDDEN}; // calendar week side to print months cldCurrShift_{0}; // calendar months shift + int cldShift_{0}; // calendar months shift factor year_month_day cldYearShift_; // calendar Year mode. Cached ymd std::string cldYearCached_; // calendar Year mode. Cached calendar year_month cldMonShift_; // calendar Month mode. Cached ym diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index b54a360f..e2cdf9fc 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -115,6 +115,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) } else cldMonCols_ = 1; if (config_[kCldPlaceholder]["on-scroll"].isInt()) { + cldShift_ = config_[kCldPlaceholder]["on-scroll"].asInt(); event_box_.add_events(Gdk::LEAVE_NOTIFY_MASK); event_box_.signal_leave_notify_event().connect([this](GdkEventCrossing*) { cldCurrShift_ = months{0}; @@ -405,10 +406,10 @@ void waybar::modules::Clock::cldModeSwitch() { cldMode_ = (cldMode_ == CldMode::YEAR) ? CldMode::MONTH : CldMode::YEAR; } void waybar::modules::Clock::cldShift_up() { - cldCurrShift_ += (months)((cldMode_ == CldMode::YEAR) ? 12 : 1); + cldCurrShift_ += (months)((cldMode_ == CldMode::YEAR) ? 12 : 1) * cldShift_; } void waybar::modules::Clock::cldShift_down() { - cldCurrShift_ -= (months)((cldMode_ == CldMode::YEAR) ? 12 : 1); + cldCurrShift_ -= (months)((cldMode_ == CldMode::YEAR) ? 12 : 1) * cldShift_; } void waybar::modules::Clock::tz_up() { const auto tzSize{tzList_.size()}; @@ -468,4 +469,4 @@ auto waybar::modules::Clock::get_ordinal_date(const year_month_day& today) -> st res << "th"; } return res.str(); -} \ No newline at end of file +}