Merge pull request #3067 from encbar5/restore_intertible_month_scroll

Fix clock on-scroll value not being used for calendar
master
Alexis Rouillard 2024-03-24 17:19:27 +01:00 committed by GitHub
commit c6cbf57a38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -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_{1}; // 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

View File

@ -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();
}
}