diff --git a/src/Compositor.cpp b/src/Compositor.cpp index d5e98a1e1..319a5eb16 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -563,18 +563,6 @@ void CCompositor::cleanupWindows() { if (!w->m_bReadyToDelete) continue; - w->hyprListener_mapWindow.removeCallback(); - w->hyprListener_unmapWindow.removeCallback(); - w->hyprListener_destroyWindow.removeCallback(); - - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(w); - - if (w->m_pSurfaceTree) { - Debug::log(LOG, "Destroying Subsurface tree of %x in destroyWindow", w); - SubsurfaceTree::destroySurfaceTree(w->m_pSurfaceTree); - w->m_pSurfaceTree = nullptr; - } - g_pHyprOpenGL->m_mWindowFramebuffers[w].release(); g_pHyprOpenGL->m_mWindowFramebuffers.erase(w); m_lWindows.remove(*w); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ad36a15df..70267f108 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -345,8 +345,9 @@ void CConfigManager::loadConfigLoadVars() { for (auto& m : g_pCompositor->m_lMonitors) g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); - // Update the keyboard layout to the cfg'd one - g_pInputManager->setKeyboardLayout(); + // Update the keyboard layout to the cfg'd one if this is not the first launch + if (!isFirstLaunch) + g_pInputManager->setKeyboardLayout(); // Calculate the mod mask for main_mod configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask(configValues["general:main_mod"].strValue); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 628a388b6..722d3ed65 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -221,6 +221,18 @@ void Events::listener_destroyWindow(void* owner, void* data) { g_pCompositor->m_pLastFocus = nullptr; } + PWINDOW->hyprListener_mapWindow.removeCallback(); + PWINDOW->hyprListener_unmapWindow.removeCallback(); + PWINDOW->hyprListener_destroyWindow.removeCallback(); + + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW); + + if (PWINDOW->m_pSurfaceTree) { + Debug::log(LOG, "Destroying Subsurface tree of %x in destroyWindow", PWINDOW); + SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree); + PWINDOW->m_pSurfaceTree = nullptr; + } + PWINDOW->m_bReadyToDelete = true; } diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index d918979a9..d13251027 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -73,7 +73,6 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) { return; } - for (auto& c : pNode->childSubsurfaces) destroySubsurface(&c); @@ -83,6 +82,8 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) { pNode->hyprListener_destroy.removeCallback(); pNode->hyprListener_newSubsurface.removeCallback(); + surfaceTreeNodes.remove(*pNode); + Debug::log(LOG, "SurfaceTree Node removed"); }