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:
+20
-20
@@ -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
|
* returned to the main loop, when any late initial configure has been dispatched and widgets have
|
||||||
* had a chance to allocate/draw.
|
* had a chance to allocate/draw.
|
||||||
*/
|
*/
|
||||||
Glib::signal_idle().connect(sigc::track_obj([this] {
|
Glib::signal_idle().connect(sigc::track_obj(
|
||||||
window.queue_resize();
|
[this] {
|
||||||
window.queue_draw();
|
window.queue_resize();
|
||||||
forceLayerCommit();
|
window.queue_draw();
|
||||||
return false;
|
forceLayerCommit();
|
||||||
}, *this));
|
return false;
|
||||||
|
},
|
||||||
|
*this));
|
||||||
|
|
||||||
if (spdlog::should_log(spdlog::level::debug)) {
|
if (spdlog::should_log(spdlog::level::debug)) {
|
||||||
// Unfortunately, this function isn't in the C++ bindings, so we have to call the C version.
|
// Unfortunately, this function isn't in the C++ bindings, so we have to call the C version.
|
||||||
@@ -750,20 +752,18 @@ void waybar::Bar::onOutputGeometryChanged() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void waybar::Bar::toggleSuspend(bool suspend) {
|
void waybar::Bar::toggleSuspend(bool suspend) {
|
||||||
auto process_modules = [suspend](Gtk::Box& module_box) {
|
// Iterate the actual module objects. Modules are packed into the Gtk::Box via
|
||||||
for (auto* widget : module_box.get_children()) {
|
// AModule::operator Gtk::Widget&(), which returns the member event_box_, so the
|
||||||
auto* module = dynamic_cast<waybar::AModule*>(widget);
|
// box children are Gtk::EventBox, never AModule -- a dynamic_cast over them is
|
||||||
if (module && module->shouldSuspend()) {
|
// always null and suspend()/resume() would never fire. modules_all_ holds the
|
||||||
if (suspend) {
|
// real module pointers (including group children), so use it instead.
|
||||||
module->suspend();
|
for (auto const& module : modules_all_) {
|
||||||
} else {
|
if (module && module->shouldSuspend()) {
|
||||||
module->resume();
|
if (suspend) {
|
||||||
}
|
module->suspend();
|
||||||
|
} else {
|
||||||
|
module->resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
process_modules(left_);
|
|
||||||
process_modules(center_);
|
|
||||||
process_modules(right_);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user