fix(wlr/taskbar): protocol error when reconnecting outputs

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
```
pull/969/head
Aleksei Bavshin 2021-01-08 15:07:04 -08:00
parent ef9c3ef1cb
commit b79301a5bd
No known key found for this signature in database
GPG Key ID: 4F071603387A382A
1 changed files with 14 additions and 2 deletions

View File

@ -637,10 +637,22 @@ Taskbar::Taskbar(const std::string &id, const waybar::Bar &bar, const Json::Valu
Taskbar::~Taskbar()
{
if (manager_) {
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;
}
}
}
void Taskbar::update()
{