diff options
| author | Vaxry <vaxry@vaxry.net> | 2026-04-07 14:24:51 +0100 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-04-07 12:07:36 -0400 |
| commit | 75dc67e63f1873f1e97f73daf0ce284f75afa97c (patch) | |
| tree | 8afb58435f57b8795778edb735e89297aeedde68 /src/managers/input/InputManager.cpp | |
| parent | ec8c336e1446de8a2b32dc7767bc88a9b99c6daa (diff) | |
input: lazy cache getWindowIdeal()
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 875fd0b6..8672d28c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -410,8 +410,19 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_layerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface); // then, we check if the workspace doesn't have a fullscreen window - const auto PWORKSPACE = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace; - const auto PWINDOWIDEAL = g_pCompositor->vectorToWindowUnified(mouseCoords, Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING); + const auto PWORKSPACE = PMONITOR->m_activeSpecialWorkspace ? PMONITOR->m_activeSpecialWorkspace : PMONITOR->m_activeWorkspace; + + bool windowIdealQueried = false; + PHLWINDOW pWindowIdeal; + const auto getWindowIdeal = [&]() -> const PHLWINDOW& { + if (!windowIdealQueried) { + pWindowIdeal = g_pCompositor->vectorToWindowUnified(mouseCoords, Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING); + windowIdealQueried = true; + } + + return pWindowIdeal; + }; + if (PWORKSPACE->m_hasFullscreenWindow && PWORKSPACE->m_fullscreenMode == FSMODE_FULLSCREEN) { const auto IS_LS_UNFOCUSABLE = pFoundLayerSurface && (pFoundLayerSurface->m_layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP || @@ -429,6 +440,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st return; } + const auto& PWINDOWIDEAL = getWindowIdeal(); if (PWINDOWIDEAL && ((PWINDOWIDEAL->m_isFloating && (PWINDOWIDEAL->m_createdOverFullscreen || PWINDOWIDEAL->m_pinned)) /* floating over fullscreen or pinned */ || (PMONITOR->m_activeSpecialWorkspace == PWINDOWIDEAL->m_workspace) /* on an open special workspace */)) @@ -449,9 +461,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st if (PWORKSPACE->m_hasFullscreenWindow && PWORKSPACE->m_fullscreenMode == FSMODE_MAXIMIZED) { if (!foundSurface) { if (PMONITOR->m_activeSpecialWorkspace) { + const auto& PWINDOWIDEAL = getWindowIdeal(); if (pFoundWindow != PWINDOWIDEAL) - pFoundWindow = - g_pCompositor->vectorToWindowUnified(mouseCoords, Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING); + pFoundWindow = PWINDOWIDEAL; if (pFoundWindow && !pFoundWindow->onSpecialWorkspace()) { pFoundWindow = PWORKSPACE->getFullscreenWindow(); @@ -464,9 +476,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st } if (!foundSurface) { + const auto& PWINDOWIDEAL = getWindowIdeal(); if (pFoundWindow != PWINDOWIDEAL) - pFoundWindow = - g_pCompositor->vectorToWindowUnified(mouseCoords, Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING); + pFoundWindow = PWINDOWIDEAL; if (!(pFoundWindow && (pFoundWindow->m_isFloating && (pFoundWindow->m_createdOverFullscreen || pFoundWindow->m_pinned)))) pFoundWindow = PWORKSPACE->getFullscreenWindow(); @@ -475,8 +487,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st } } else { + const auto& PWINDOWIDEAL = getWindowIdeal(); if (pFoundWindow != PWINDOWIDEAL) - pFoundWindow = g_pCompositor->vectorToWindowUnified(mouseCoords, Desktop::View::RESERVED_EXTENTS | Desktop::View::INPUT_EXTENTS | Desktop::View::ALLOW_FLOATING); + pFoundWindow = PWINDOWIDEAL; } if (pFoundWindow) { |
