diff options
author | vaxerski <[email protected]> | 2023-03-28 20:17:47 +0100 |
---|---|---|
committer | vaxerski <[email protected]> | 2023-03-28 20:17:47 +0100 |
commit | d6241a3086c4abfd21e91e23c83c97c3f80123d4 (patch) | |
tree | 81e739849af94411fd2f161639698746878ec58d | |
parent | df54ab40ceb6e7f74844e83d3f55739accd349cc (diff) | |
download | Hyprland-d6241a3086c4abfd21e91e23c83c97c3f80123d4.tar.gz Hyprland-d6241a3086c4abfd21e91e23c83c97c3f80123d4.zip |
windows: only connect unmap when mapped
-rw-r--r-- | src/Window.cpp | 4 | ||||
-rw-r--r-- | src/events/Windows.cpp | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/Window.cpp b/src/Window.cpp index b8c7ab36..681de391 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -338,6 +338,8 @@ void CWindow::onUnmap() { std::erase_if(g_pCompositor->m_vWindowFocusHistory, [&](const auto& other) { return other == this; }); m_pWLSurface.unassign(); + + hyprListener_unmapWindow.removeCallback(); } void CWindow::onMap() { @@ -369,6 +371,8 @@ void CWindow::onMap() { m_fBorderAngleAnimationProgress = 1.f; g_pCompositor->m_vWindowFocusHistory.push_back(this); + + hyprListener_unmapWindow.initCallback(m_bIsX11 ? &m_uSurface.xwayland->events.unmap : &m_uSurface.xdg->events.unmap, &Events::listener_unmapWindow, this, "CWindow"); } void CWindow::onBorderAngleAnimEnd(void* ptr) { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index adbd2118..8b292a0b 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -583,6 +583,12 @@ void Events::listener_unmapWindow(void* owner, void* data) { Debug::log(LOG, "Window %x unmapped (class %s)", PWINDOW, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str()); + if (!PWINDOW->m_pWLSurface.exists() || !PWINDOW->m_bIsMapped) { + Debug::log(WARN, "Window %x unmapped without being mapped??", PWINDOW); + PWINDOW->m_bFadingOut = false; + return; + } + g_pEventManager->postEvent(SHyprIPCEvent{"closewindow", getFormat("%x", PWINDOW)}); EMIT_HOOK_EVENT("closeWindow", PWINDOW); @@ -1007,7 +1013,6 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) { PNEWWINDOW->m_pX11Parent = g_pCompositor->getX11Parent(PNEWWINDOW); PNEWWINDOW->hyprListener_mapWindow.initCallback(&XWSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XWayland Window"); - PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XWSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XWSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_setOverrideRedirect.initCallback(&XWSURFACE->events.set_override_redirect, &Events::listener_setOverrideRedirect, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_configureX11.initCallback(&XWSURFACE->events.request_configure, &Events::listener_configureX11, PNEWWINDOW, "XWayland Window"); @@ -1026,7 +1031,6 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) { PNEWWINDOW->m_uSurface.xdg = XDGSURFACE; PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window"); - PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XDGSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XDG Window"); PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XDGSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XDG Window"); } |