Idle inhibitor toggle no longer update all modules - a list of idle inhibitors is maintained on the Client.

pull/906/head
Jordan Leppert 2020-10-31 17:30:25 +00:00
parent 188611a767
commit aa4fc3dd29
4 changed files with 9 additions and 16 deletions

View File

@ -31,7 +31,6 @@ class Bar {
auto toggle() -> void; auto toggle() -> void;
void handleSignal(int); void handleSignal(int);
void updateAll();
struct waybar_output *output; struct waybar_output *output;
Json::Value config; Json::Value config;

View File

@ -21,8 +21,11 @@ class Client {
struct wl_registry * registry = nullptr; struct wl_registry * registry = nullptr;
struct zwlr_layer_shell_v1 * layer_shell = nullptr; struct zwlr_layer_shell_v1 * layer_shell = nullptr;
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr; struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr; struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
struct zwp_idle_inhibitor_v1* idle_inhibitor; struct zwp_idle_inhibitor_v1* idle_inhibitor;
std::vector<waybar::AModule*> idle_inhibitor_modules;
std::vector<std::unique_ptr<Bar>> bars; std::vector<std::unique_ptr<Bar>> bars;
private: private:

View File

@ -461,15 +461,3 @@ auto waybar::Bar::setupWidgets() -> void {
right_.pack_end(*module, false, false); 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();
}
}

View File

@ -10,6 +10,7 @@ waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar&
event_box_.add_events(Gdk::BUTTON_PRESS_MASK); event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
event_box_.signal_button_press_event().connect( event_box_.signal_button_press_event().connect(
sigc::mem_fun(*this, &IdleInhibitor::handleToggle)); sigc::mem_fun(*this, &IdleInhibitor::handleToggle));
waybar::Client::inst()->idle_inhibitor_modules.push_back(this);
dp.emit(); dp.emit();
} }
@ -57,9 +58,11 @@ bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
click_param = status_; click_param = status_;
} }
// Make all modules update // Make all other idle inhibitor modules update
for (auto const& bar : waybar::Client::inst()->bars) { for (auto const& module : waybar::Client::inst()->idle_inhibitor_modules) {
bar->updateAll(); if (module != this) {
module->update();
}
} }
ALabel::handleToggle(e); ALabel::handleToggle(e);