Skip to content

Commit

Permalink
fix(wlr/taskbar): protocol error when reconnecting outputs
Browse files Browse the repository at this point in the history
Destroy request is not specified for foreign toplevel manager and it
does not prevent the compositor from sending more events.
Libwayland would ignore events to a destroyed objects, but that could
indirectly cause a gap in the sequence of new object ids and trigger
error condition in the library.

With this commit waybar sends a `stop` request to notify the compositor
about the destruction of a toplevel manager. That fixes abnormal
termination of the bar with following errors:
```
(waybar:11791): Gdk-DEBUG: 20:04:19.778: not a valid new object id (4278190088), message toplevel(n)

Gdk-Message: 20:04:19.778: Error reading events from display: Invalid argument
```
  • Loading branch information
alebastr committed Jan 8, 2021
1 parent ef9c3ef commit b79301a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/modules/wlr/taskbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,20 @@ Taskbar::Taskbar(const std::string &id, const waybar::Bar &bar, const Json::Valu
Taskbar::~Taskbar()
{
if (manager_) {
zwlr_foreign_toplevel_manager_v1_destroy(manager_);
manager_ = nullptr;
struct wl_display *display = Client::inst()->wl_display;
/*
* Send `stop` request and wait for one roundtrip.
* This is not quite correct as the protocol encourages us to wait for the .finished event,
* but it should work with wlroots foreign toplevel manager implementation.
*/
zwlr_foreign_toplevel_manager_v1_stop(manager_);
wl_display_roundtrip(display);

if (manager_) {
spdlog::warn("Foreign toplevel manager destroyed before .finished event");
zwlr_foreign_toplevel_manager_v1_destroy(manager_);
manager_ = nullptr;
}
}
}

Expand Down

0 comments on commit b79301a

Please sign in to comment.