From aa4fc3dd29544586482525e20f55c8c5becb82f0 Mon Sep 17 00:00:00 2001 From: Jordan Leppert Date: Sat, 31 Oct 2020 17:30:25 +0000 Subject: [PATCH] Idle inhibitor toggle no longer update all modules - a list of idle inhibitors is maintained on the Client. --- include/bar.hpp | 1 - include/client.hpp | 3 +++ src/bar.cpp | 12 ------------ src/modules/idle_inhibitor.cpp | 9 ++++++--- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/bar.hpp b/include/bar.hpp index d1077842..fdc5a739 100644 --- a/include/bar.hpp +++ b/include/bar.hpp @@ -31,7 +31,6 @@ class Bar { auto toggle() -> void; void handleSignal(int); - void updateAll(); struct waybar_output *output; Json::Value config; diff --git a/include/client.hpp b/include/client.hpp index b7631ccf..b6762f63 100644 --- a/include/client.hpp +++ b/include/client.hpp @@ -21,8 +21,11 @@ class Client { struct wl_registry * registry = nullptr; struct zwlr_layer_shell_v1 * layer_shell = nullptr; struct zxdg_output_manager_v1 * xdg_output_manager = nullptr; + struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr; struct zwp_idle_inhibitor_v1* idle_inhibitor; + std::vector idle_inhibitor_modules; + std::vector> bars; private: diff --git a/src/bar.cpp b/src/bar.cpp index 747f0bf8..8af6b971 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -461,15 +461,3 @@ auto waybar::Bar::setupWidgets() -> void { right_.pack_end(*module, false, false); } } - -void waybar::Bar::updateAll() { - for (auto const& module : modules_left_) { - module->update(); - } - for (auto const& module : modules_center_) { - module->update(); - } - for (auto const& module : modules_right_) { - module->update(); - } -} diff --git a/src/modules/idle_inhibitor.cpp b/src/modules/idle_inhibitor.cpp index c6a4c78b..7a0dd505 100644 --- a/src/modules/idle_inhibitor.cpp +++ b/src/modules/idle_inhibitor.cpp @@ -10,6 +10,7 @@ waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar& event_box_.add_events(Gdk::BUTTON_PRESS_MASK); event_box_.signal_button_press_event().connect( sigc::mem_fun(*this, &IdleInhibitor::handleToggle)); + waybar::Client::inst()->idle_inhibitor_modules.push_back(this); dp.emit(); } @@ -57,9 +58,11 @@ bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) { click_param = status_; } - // Make all modules update - for (auto const& bar : waybar::Client::inst()->bars) { - bar->updateAll(); + // Make all other idle inhibitor modules update + for (auto const& module : waybar::Client::inst()->idle_inhibitor_modules) { + if (module != this) { + module->update(); + } } ALabel::handleToggle(e);