From f9cfec8abb9033e14f558fc2dc24dfa1c2a51e5a Mon Sep 17 00:00:00 2001 From: github-usr-name Date: Sun, 25 Feb 2024 14:03:00 +0000 Subject: [PATCH] compositor: allow source monitor to be provided to `getMonitorInDirection` (#4837) Co-authored-by: github-user-name --- src/Compositor.cpp | 10 ++++++++-- src/Compositor.hpp | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 5eeabf8a..3ac2d9b8 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1802,8 +1802,14 @@ CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) { } CMonitor* CCompositor::getMonitorInDirection(const char& dir) { - const auto POSA = m_pLastMonitor->vecPosition; - const auto SIZEA = m_pLastMonitor->vecSize; + return this->getMonitorInDirection(m_pLastMonitor, dir); +} + +CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const char& dir) { + if(!pSourceMonitor) return nullptr; + + const auto POSA = pSourceMonitor->vecPosition; + const auto SIZEA = pSourceMonitor->vecSize; auto longestIntersect = -1; CMonitor* longestIntersectMonitor = nullptr; diff --git a/src/Compositor.hpp b/src/Compositor.hpp index de5677c9..c08a5931 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -171,6 +171,7 @@ class CCompositor { bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr); CWindow* getConstraintWindow(SMouse*); CMonitor* getMonitorInDirection(const char&); + CMonitor* getMonitorInDirection(CMonitor*, const char&); void updateAllWindowsAnimatedDecorationValues(); void updateWorkspaceWindows(const int64_t& id); void updateWindowAnimatedDecorationValues(CWindow*);