From c9ea600baa186acd3825dde306a6b3f89de09131 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 9 Mar 2024 15:32:36 +0000 Subject: [PATCH] layer-shell: allow for popup creation before map ref https://github.com/jjsullivan5196/wvkbd/issues/65 --- src/events/Layers.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp index ad65f8fb..db237690 100644 --- a/src/events/Layers.cpp +++ b/src/events/Layers.cpp @@ -51,6 +51,7 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) { layerSurface->layer = WLRLAYERSURFACE->current.layer; WLRLAYERSURFACE->data = layerSurface; layerSurface->monitorID = PMONITOR->ID; + layerSurface->popupHead = std::make_unique(layerSurface); layerSurface->forceBlur = g_pConfigManager->shouldBlurLS(layerSurface->szNamespace); @@ -65,6 +66,8 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) { const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID); + layersurface->popupHead.reset(); + if (!g_pCompositor->getMonitorFromID(layersurface->monitorID)) Debug::log(WARN, "Layersurface destroyed on an invalid monitor (removed?)"); @@ -111,8 +114,6 @@ void Events::listener_mapLayerSurface(void* owner, void* data) { layersurface->keyboardExclusive = layersurface->layerSurface->current.keyboard_interactive; layersurface->surface = layersurface->layerSurface->surface; - layersurface->popupHead = std::make_unique(layersurface); - // fix if it changed its mon const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output); @@ -184,8 +185,6 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) { std::erase(g_pInputManager->m_dExclusiveLSes, layersurface); - layersurface->popupHead.reset(); - if (!g_pInputManager->m_dExclusiveLSes.empty()) g_pCompositor->focusSurface(g_pInputManager->m_dExclusiveLSes[0]->layerSurface->surface);