Skip to content

Commit abd7ca2

Browse files
committed
Fix clock on-scroll value not being used for calendar, which was broken by 86a3898
1 parent cc084f5 commit abd7ca2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/modules/clock.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Clock final : public ALabel {
4141
const int cldMonColLen_{20}; // calendar month column length
4242
WS cldWPos_{WS::HIDDEN}; // calendar week side to print
4343
months cldCurrShift_{0}; // calendar months shift
44+
int cldShift_{1}; // calendar months shift factor
4445
year_month_day cldYearShift_; // calendar Year mode. Cached ymd
4546
std::string cldYearCached_; // calendar Year mode. Cached calendar
4647
year_month cldMonShift_; // calendar Month mode. Cached ym

src/modules/clock.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config)
115115
} else
116116
cldMonCols_ = 1;
117117
if (config_[kCldPlaceholder]["on-scroll"].isInt()) {
118+
cldShift_ = config_[kCldPlaceholder]["on-scroll"].asInt();
118119
event_box_.add_events(Gdk::LEAVE_NOTIFY_MASK);
119120
event_box_.signal_leave_notify_event().connect([this](GdkEventCrossing*) {
120121
cldCurrShift_ = months{0};
@@ -405,10 +406,10 @@ void waybar::modules::Clock::cldModeSwitch() {
405406
cldMode_ = (cldMode_ == CldMode::YEAR) ? CldMode::MONTH : CldMode::YEAR;
406407
}
407408
void waybar::modules::Clock::cldShift_up() {
408-
cldCurrShift_ += (months)((cldMode_ == CldMode::YEAR) ? 12 : 1);
409+
cldCurrShift_ += (months)((cldMode_ == CldMode::YEAR) ? 12 : 1) * cldShift_;
409410
}
410411
void waybar::modules::Clock::cldShift_down() {
411-
cldCurrShift_ -= (months)((cldMode_ == CldMode::YEAR) ? 12 : 1);
412+
cldCurrShift_ -= (months)((cldMode_ == CldMode::YEAR) ? 12 : 1) * cldShift_;
412413
}
413414
void waybar::modules::Clock::tz_up() {
414415
const auto tzSize{tzList_.size()};
@@ -468,4 +469,4 @@ auto waybar::modules::Clock::get_ordinal_date(const year_month_day& today) -> st
468469
res << "th";
469470
}
470471
return res.str();
471-
}
472+
}

0 commit comments

Comments
 (0)