From 726d69782124ffb5b609c0377cd21cfd4d6f6f88 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 9 Nov 2024 02:26:24 +0000 Subject: [PATCH] popup: minor cleanups don't iterate over unmapped popups in breadthfirst, don't refocus if it wasnt in focus ref #8293 --- src/desktop/Popup.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 58995f00..ea6e877b 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -4,6 +4,8 @@ #include "../protocols/LayerShell.hpp" #include "../protocols/XDGShell.hpp" #include "../protocols/core/Compositor.hpp" +#include "../managers/SeatManager.hpp" +#include "../managers/eventLoop/EventLoopManager.hpp" #include CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) { @@ -106,6 +108,8 @@ void CPopup::onUnmap() { return; } + m_bMapped = false; + m_vLastSize = m_pResource->surface->surface->current.size; const auto COORDS = coordsGlobal(); @@ -116,8 +120,6 @@ void CPopup::onUnmap() { m_pSubsurfaceHead.reset(); - g_pInputManager->simulateMouseMovement(); - if (!m_pLayerOwner.expired() && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP) g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer)); @@ -131,6 +133,11 @@ void CPopup::onUnmap() { g_pHyprRenderer->damageBox(&box); }, nullptr); + + const bool WASLASTFOCUS = g_pSeatManager->state.keyboardFocus == m_pWLSurface->resource() || g_pSeatManager->state.pointerFocus == m_pWLSurface->resource(); + + if (WASLASTFOCUS) + g_pInputManager->simulateMouseMovement(); } void CPopup::onCommit(bool ignoreSiblings) { @@ -317,7 +324,7 @@ CPopup* CPopup::at(const Vector2D& globalCoords, bool allowsInput) { breadthfirst([](CPopup* popup, void* data) { ((std::vector*)data)->push_back(popup); }, &popups); for (auto const& p : popups | std::views::reverse) { - if (!p->m_pResource) + if (!p->m_pResource || !p->m_bMapped) continue; if (!allowsInput) {