Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clock on-scroll value not being used for calendar #3067

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/modules/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/modules/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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()};
Expand Down Expand Up @@ -468,4 +469,4 @@ auto waybar::modules::Clock::get_ordinal_date(const year_month_day& today) -> st
res << "th";
}
return res.str();
}
}
Loading