diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 1297bb83..0772b676 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -240,10 +240,6 @@ CBox CWindow::getWindowBoxUnified(uint64_t properties) { return box; } -CBox CWindow::getWindowMainSurfaceBox() { - return {m_vRealPosition.value().x, m_vRealPosition.value().y, m_vRealSize.value().x, m_vRealSize.value().y}; -} - SBoxExtents CWindow::getFullWindowReservedArea() { return g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock()); } diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 9867a8c9..64f39558 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -396,10 +396,12 @@ class CWindow { } // methods - CBox getFullWindowBoundingBox(); - SBoxExtents getFullWindowExtents(); - CBox getWindowBoxUnified(uint64_t props); - CBox getWindowMainSurfaceBox(); + CBox getFullWindowBoundingBox(); + SBoxExtents getFullWindowExtents(); + CBox getWindowBoxUnified(uint64_t props); + inline CBox getWindowMainSurfaceBox() const { + return {m_vRealPosition.value().x, m_vRealPosition.value().y, m_vRealSize.value().x, m_vRealSize.value().y}; + } CBox getWindowIdealBoundingBoxIgnoreReserved(); void addWindowDeco(std::unique_ptr deco); void updateWindowDecos(); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 6f7d8017..028286bf 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -139,6 +139,15 @@ void CInputManager::sendMotionEventsToFocused() { } void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { + if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState) + return; + + Vector2D const mouseCoords = getMouseCoordsInternal(); + auto const MOUSECOORDSFLOORED = mouseCoords.floor(); + + if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus) + return; + static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); static auto PMOUSEREFOCUS = CConfigValue("input:mouse_refocus"); static auto PFOLLOWONDND = CConfigValue("misc:always_follow_on_dnd"); @@ -159,15 +168,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { PHLWINDOW pFoundWindow; PHLLS pFoundLayerSurface; - if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState) - return; - - Vector2D mouseCoords = getMouseCoordsInternal(); - const auto MOUSECOORDSFLOORED = mouseCoords.floor(); - - if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus) - return; - EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED); m_vLastCursorPosFloored = MOUSECOORDSFLOORED; @@ -1418,19 +1418,10 @@ void CInputManager::unconstrainMouse() { } bool CInputManager::isConstrained() { - for (auto const& c : m_vConstraints) { - const auto C = c.lock(); - - if (!C) - continue; - - if (!C->isActive() || C->owner()->resource() != g_pCompositor->m_pLastFocus) - continue; - - return true; - } - - return false; + return std::any_of(m_vConstraints.begin(), m_vConstraints.end(), [](auto const& c) { + const auto constraint = c.lock(); + return constraint && constraint->isActive() && constraint->owner()->resource() == g_pCompositor->m_pLastFocus; + }); } bool CInputManager::isLocked() { diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp index 4666a59e..3eb45546 100644 --- a/src/render/decorations/DecorationPositioner.cpp +++ b/src/render/decorations/DecorationPositioner.cpp @@ -297,15 +297,16 @@ SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, CBox accum = pWindow->getWindowMainSurfaceBox(); for (auto const& data : m_vWindowPositioningDatas) { - if (data->pWindow.lock() != pWindow) - continue; - - if (!data->pWindow.lock() || !data->pDecoration) + if (!data->pDecoration) continue; if (!(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT) && inputOnly) continue; + auto const window = data->pWindow.lock(); + if (!window || window != pWindow) + continue; + CBox decoBox; if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) { @@ -373,9 +374,10 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) { } CBox CDecorationPositioner::getWindowDecorationBox(IHyprWindowDecoration* deco) { - const auto DATA = getDataFor(deco, deco->m_pWindow.lock()); + auto const window = deco->m_pWindow.lock(); + const auto DATA = getDataFor(deco, window); CBox box = DATA->lastReply.assignedGeometry; - box.translate(getEdgeDefinedPoint(DATA->positioningInfo.edges, deco->m_pWindow.lock())); + box.translate(getEdgeDefinedPoint(DATA->positioningInfo.edges, window)); return box; }