Skip to content

Commit 7b23d58

Browse files
committed
fix(bar): force commit for occluded surfaces
All the mode or visibility changes require `wl_surface_commit` to be applied. gtk-layer-shell will attempt to force GTK to commit, but may fail if the surface has stopped receiving frame callbacks[^1]. Thus, we could get stuck in a state where the bar is hidden and unable to regain visibility. To address this, a new API has been added to gtk-layer-shell, `gtk_layer_try_force_commit`, which does `wl_surface_commit` with the necessary safety checks to avoid corrupting GTK internal state. Note: this change bumps gtk-layer-shell requirement to 0.9.0. [^1]: wmww/gtk-layer-shell#185
1 parent 4a6af0d commit 7b23d58

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ if libsndio.found()
106106
endif
107107
endif
108108

109-
gtk_layer_shell = dependency('gtk-layer-shell-0', version: ['>=0.6.0'],
109+
gtk_layer_shell = dependency('gtk-layer-shell-0', version: ['>=0.9.0'],
110110
default_options: ['introspection=false', 'vapi=false'],
111111
fallback: ['gtk-layer-shell', 'gtk_layer_shell'])
112112
systemd = dependency('systemd', required: get_option('systemd'))

src/bar.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ void from_json(const Json::Value& j, std::map<Key, Value>& m) {
132132
waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
133133
: output(w_output),
134134
config(w_config),
135+
surface(nullptr),
135136
window{Gtk::WindowType::WINDOW_TOPLEVEL},
136137
x_global(0),
137138
y_global(0),
@@ -339,6 +340,13 @@ void waybar::Bar::setMode(const struct bar_mode& mode) {
339340
window.get_style_context()->add_class("hidden");
340341
window.set_opacity(0);
341342
}
343+
/*
344+
* All the changes above require `wl_surface_commit`.
345+
* gtk-layer-shell schedules a commit on the next frame event in GTK, but this could fail in
346+
* certain scenarios, such as fully occluded bar.
347+
*/
348+
gtk_layer_try_force_commit(gtk_window);
349+
wl_display_flush(Client::inst()->wl_display);
342350
}
343351

344352
void waybar::Bar::setPassThrough(bool passthrough) {

0 commit comments

Comments
 (0)