summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-10 11:17:06 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-10 11:17:06 +0200
commit5046c02cceea9bccf1b39fbc84ad062f59ce6e22 (patch)
treebe50ba824424e58cb03b9145e4d81d0b337ac73a /src
parentc76c372c752c41ab82f67734bc0304ccae1b49e6 (diff)
minor fixes for closing windows and focus
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp26
-rw-r--r--src/Window.hpp1
-rw-r--r--src/events/Windows.cpp18
3 files changed, 26 insertions, 19 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index ecefbaba..d5e98a1e 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -406,8 +406,8 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
};
wlr_signal_emit_safe(&m_sSeat.seat->keyboard_state.events.focus_change, &event);
- if (const auto PWINDOW = getWindowFromSurface(pSurface); PWINDOW)
- Debug::log(LOG, "Set keyboard focus to surface %x, with window name: %s", pSurface, PWINDOW->m_szTitle.c_str());
+ if (pWindowOwner)
+ Debug::log(LOG, "Set keyboard focus to surface %x, with window name: %s", pSurface, pWindowOwner->m_szTitle.c_str());
else
Debug::log(LOG, "Set keyboard focus to surface %x", pSurface);
}
@@ -560,11 +560,27 @@ void CCompositor::moveWindowToTop(CWindow* pWindow) {
void CCompositor::cleanupWindows() {
for (auto& w : m_lWindowsFadingOut) {
if (!w->m_bFadingOut || w->m_fAlpha == 0.f) {
- m_lWindows.remove(*w);
- m_lWindowsFadingOut.remove(w);
+ 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);
- Debug::log(LOG, "Cleanup: cleaned up a window");
+ m_lWindows.remove(*w);
+ m_lWindowsFadingOut.remove(w);
+
+ Debug::log(LOG, "Cleanup: destroyed a window");
return;
}
}
diff --git a/src/Window.hpp b/src/Window.hpp
index af0e8d84..d34a5d06 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -71,6 +71,7 @@ public:
// Fade in-out
float m_fAlpha = 0.f;
bool m_bFadingOut = false;
+ bool m_bReadyToDelete = false;
// For the list lookup
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 193bf840..628a388b 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -30,6 +30,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_bMappedX11 = true;
PWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace;
PWINDOW->m_bIsMapped = true;
+ PWINDOW->m_bReadyToDelete = false;
+ PWINDOW->m_bFadingOut = false;
// checks if the window wants borders and sets the appriopriate flag
g_pXWaylandManager->checkBorders(PWINDOW);
@@ -212,26 +214,14 @@ void Events::listener_commitWindow(void* owner, void* data) {
void Events::listener_destroyWindow(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner;
- Debug::log(LOG, "Window %x destroyed", PWINDOW);
+ Debug::log(LOG, "Window %x destroyed, queueing.", PWINDOW);
if (PWINDOW == g_pCompositor->m_pLastWindow) {
g_pCompositor->m_pLastWindow = nullptr;
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;
- }
-
- g_pCompositor->removeWindowFromVectorSafe(PWINDOW);
+ PWINDOW->m_bReadyToDelete = true;
}
void Events::listener_setTitleWindow(void* owner, void* data) {