From 7ea4bd2a7ca35428e69c62a6e725783c241cb84e Mon Sep 17 00:00:00 2001 From: Agent_00Ming Date: Fri, 30 Aug 2024 10:34:05 -0400 Subject: [PATCH] Move entire area search to a function. Enable tablet to map 'entire'. --- src/managers/PointerManager.cpp | 42 +++++++++++++++++++-------------- src/managers/PointerManager.hpp | 4 +++- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index b309ba82120..1fefdb4186b 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -633,6 +633,24 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) { return hotBox.middle(); } +CBox CPointerManager::getEntireMappableArea() { + // find x and y size of the entire space + Vector2D bottomRight = {-9999999, -9999999}, topLeft = {9999999, 9999999}; + for (auto const& m : g_pCompositor->m_vMonitors) { + const auto EXTENT = m->logicalBox().extent(); + const auto POS = m->logicalBox().pos(); + if (EXTENT.x > bottomRight.x) + bottomRight.x = EXTENT.x; + if (EXTENT.y > bottomRight.y) + bottomRight.y = EXTENT.y; + if (POS.x < topLeft.x) + topLeft.x = POS.x; + if (POS.y < topLeft.y) + topLeft.y = POS.y; + } + return {topLeft, bottomRight - topLeft}; +} + void CPointerManager::damageIfSoftware() { auto b = getCursorBoxGlobal().expand(4); @@ -685,7 +703,9 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP dev) { case HID_TYPE_TABLET: { CTablet* TAB = reinterpret_cast(dev.get()); if (!TAB->boundOutput.empty()) { - if (const auto PMONITOR = g_pCompositor->getMonitorFromString(TAB->boundOutput); PMONITOR) { + if (TAB->boundOutput == "entire") + mappedArea = getEntireMappableArea(); + else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(TAB->boundOutput); PMONITOR) { currentMonitor = PMONITOR->self.lock(); mappedArea = currentMonitor->logicalBox(); } @@ -711,23 +731,9 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP dev) { case HID_TYPE_POINTER: { IPointer* POINTER = reinterpret_cast(dev.get()); if (!POINTER->boundOutput.empty()) { - if (POINTER->boundOutput == "entire") { - // find x and y size of the entire space - Vector2D bottomRight = {-9999999, -9999999}, topLeft = {9999999, 9999999}; - for (auto const& m : g_pCompositor->m_vMonitors) { - const auto EXTENT = m->logicalBox().extent(); - const auto POS = m->logicalBox().pos(); - if (EXTENT.x > bottomRight.x) - bottomRight.x = EXTENT.x; - if (EXTENT.y > bottomRight.y) - bottomRight.y = EXTENT.y; - if (POS.x < topLeft.x) - topLeft.x = POS.x; - if (POS.y < topLeft.y) - topLeft.y = POS.y; - } - mappedArea = {topLeft, bottomRight - topLeft}; - } else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(POINTER->boundOutput); PMONITOR) { + if (POINTER->boundOutput == "entire") + mappedArea = getEntireMappableArea(); + else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(POINTER->boundOutput); PMONITOR) { currentMonitor = PMONITOR->self.lock(); mappedArea = currentMonitor->logicalBox(); } diff --git a/src/managers/PointerManager.hpp b/src/managers/PointerManager.hpp index a0cd0fff095..5af99c08ff4 100644 --- a/src/managers/PointerManager.hpp +++ b/src/managers/PointerManager.hpp @@ -82,7 +82,9 @@ class CPointerManager { // returns the thing in logical coordinates of the monitor CBox getCursorBoxLogicalForMonitor(PHLMONITOR pMonitor); // returns the thing in global coords - CBox getCursorBoxGlobal(); + CBox getCursorBoxGlobal(); + // returns the area covered by all monitors + CBox getEntireMappableArea(); Vector2D transformedHotspot(PHLMONITOR pMonitor);