fix(bar): make disable-on-sleep DPMS suspend actually reach modules
toggleSuspend dynamic_cast<AModule*>-ed the children of the left/center/right Gtk::Box. But modules are packed via AModule::operator Gtk::Widget&(), which returns the member event_box_, so every box child is a Gtk::EventBox and the cast is always null -- suspend()/resume() never ran, making disable-on-sleep a silent no-op. Iterate modules_all_ (the real module pointers) instead. Fixes disable-on-sleep DPMS suspend/resume never firing.
This commit is contained in:
+10
-10
@@ -331,12 +331,14 @@ waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
|
||||
* returned to the main loop, when any late initial configure has been dispatched and widgets have
|
||||
* had a chance to allocate/draw.
|
||||
*/
|
||||
Glib::signal_idle().connect(sigc::track_obj([this] {
|
||||
Glib::signal_idle().connect(sigc::track_obj(
|
||||
[this] {
|
||||
window.queue_resize();
|
||||
window.queue_draw();
|
||||
forceLayerCommit();
|
||||
return false;
|
||||
}, *this));
|
||||
},
|
||||
*this));
|
||||
|
||||
if (spdlog::should_log(spdlog::level::debug)) {
|
||||
// Unfortunately, this function isn't in the C++ bindings, so we have to call the C version.
|
||||
@@ -750,9 +752,12 @@ void waybar::Bar::onOutputGeometryChanged() {
|
||||
}
|
||||
|
||||
void waybar::Bar::toggleSuspend(bool suspend) {
|
||||
auto process_modules = [suspend](Gtk::Box& module_box) {
|
||||
for (auto* widget : module_box.get_children()) {
|
||||
auto* module = dynamic_cast<waybar::AModule*>(widget);
|
||||
// Iterate the actual module objects. Modules are packed into the Gtk::Box via
|
||||
// AModule::operator Gtk::Widget&(), which returns the member event_box_, so the
|
||||
// box children are Gtk::EventBox, never AModule -- a dynamic_cast over them is
|
||||
// always null and suspend()/resume() would never fire. modules_all_ holds the
|
||||
// real module pointers (including group children), so use it instead.
|
||||
for (auto const& module : modules_all_) {
|
||||
if (module && module->shouldSuspend()) {
|
||||
if (suspend) {
|
||||
module->suspend();
|
||||
@@ -761,9 +766,4 @@ void waybar::Bar::toggleSuspend(bool suspend) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
process_modules(left_);
|
||||
process_modules(center_);
|
||||
process_modules(right_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user