Ensure style class is removed from all IdleInhibitor instances by moving it to update().

pull/906/head
Jordan Leppert 2020-11-01 18:17:51 +00:00
parent a9dae931c7
commit b015836e7b
1 changed files with 2 additions and 4 deletions

View File

@ -37,13 +37,14 @@ waybar::modules::IdleInhibitor::~IdleInhibitor() {
auto waybar::modules::IdleInhibitor::update() -> void { auto waybar::modules::IdleInhibitor::update() -> void {
// Check status // Check status
std::string status = waybar::modules::IdleInhibitor::status;
if (status == "activated") { if (status == "activated") {
label_.get_style_context()->remove_class("deactivated");
if (idle_inhibitor_ == nullptr) { if (idle_inhibitor_ == nullptr) {
idle_inhibitor_ = zwp_idle_inhibit_manager_v1_create_inhibitor( idle_inhibitor_ = zwp_idle_inhibit_manager_v1_create_inhibitor(
waybar::Client::inst()->idle_inhibit_manager, bar_.surface); waybar::Client::inst()->idle_inhibit_manager, bar_.surface);
} }
} else { } else {
label_.get_style_context()->remove_class("activated");
if (idle_inhibitor_ != nullptr) { if (idle_inhibitor_ != nullptr) {
zwp_idle_inhibitor_v1_destroy(idle_inhibitor_); zwp_idle_inhibitor_v1_destroy(idle_inhibitor_);
idle_inhibitor_ = nullptr; idle_inhibitor_ = nullptr;
@ -62,14 +63,11 @@ auto waybar::modules::IdleInhibitor::update() -> void {
bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) { bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
if (e->button == 1) { if (e->button == 1) {
std::string status = waybar::modules::IdleInhibitor::status;
label_.get_style_context()->remove_class(status);
if (status == "activated") { if (status == "activated") {
status = "deactivated"; status = "deactivated";
} else { } else {
status = "activated"; status = "activated";
} }
waybar::modules::IdleInhibitor::status = status;
} }
// Make all other idle inhibitor modules update // Make all other idle inhibitor modules update