popup: minor cleanups

don't iterate over unmapped popups in breadthfirst, don't refocus if it wasnt in focus

ref #8293
This commit is contained in:
Vaxry 2024-11-09 02:26:24 +00:00
parent 0ccc0ace88
commit 726d697821

View file

@ -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 <ranges>
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<CPopup*>*)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) {