Fix crash upon reconnecting monitor

This commit is contained in:
Julian Schuler 2023-01-08 18:49:24 +01:00
parent 1d6cfe7ce6
commit 2045aac5b0
1 changed files with 15 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include <stdexcept> #include <stdexcept>
#include <vector> #include <vector>
#include "client.hpp"
#include "gtkmm/widget.h" #include "gtkmm/widget.h"
#include "modules/wlr/workspace_manager_binding.hpp" #include "modules/wlr/workspace_manager_binding.hpp"
@ -166,9 +167,21 @@ WorkspaceManager::~WorkspaceManager() {
return; return;
} }
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 workspace manager implementation.
zext_workspace_manager_v1_stop(workspace_manager_);
wl_display_roundtrip(display);
// If the .finished handler is still not executed, destroy the workspace manager here.
if (workspace_manager_) {
spdlog::warn("Foreign toplevel manager destroyed before .finished event");
zext_workspace_manager_v1_destroy(workspace_manager_); zext_workspace_manager_v1_destroy(workspace_manager_);
workspace_manager_ = nullptr; workspace_manager_ = nullptr;
} }
}
auto WorkspaceManager::remove_workspace_group(uint32_t id) -> void { auto WorkspaceManager::remove_workspace_group(uint32_t id) -> void {
auto it = std::find_if(groups_.begin(), groups_.end(), auto it = std::find_if(groups_.begin(), groups_.end(),