summaryrefslogtreecommitdiff
path: root/src/managers/PointerManager.cpp
diff options
context:
space:
mode:
authorJManch <61563764+JManch@users.noreply.github.com>2024-11-11 13:45:33 +0000
committerGitHub <noreply@github.com>2024-11-11 13:45:33 +0000
commit07052a515bea46e8b01d3ca5b2c284c272c5ed34 (patch)
treeec2bb8d9bd352c4b8f2d7024aa16b1013a0fec4c /src/managers/PointerManager.cpp
parent1fa0cd7a7574c8e93c567bf0453c155285dd3960 (diff)
pointer: map devices across all outputs by default (#8352)
Diffstat (limited to 'src/managers/PointerManager.cpp')
-rw-r--r--src/managers/PointerManager.cpp76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index b309ba82..75be235f 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -668,9 +668,7 @@ void CPointerManager::move(const Vector2D& deltaLogical) {
}
void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
-
- PHLMONITOR currentMonitor = g_pCompositor->m_pLastMonitor.lock();
- if (!currentMonitor || !dev)
+ if (!dev)
return;
if (!std::isnan(abs.x))
@@ -678,20 +676,44 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
if (!std::isnan(abs.y))
abs.y = std::clamp(abs.y, 0.0, 1.0);
- // in logical global
- CBox mappedArea = currentMonitor->logicalBox();
+ // find x and y size of the entire space
+ const auto& MONITORS = g_pCompositor->m_vMonitors;
+ Vector2D topLeft = MONITORS.at(0)->vecPosition, bottomRight = MONITORS.at(0)->vecPosition + MONITORS.at(0)->vecSize;
+ for (size_t i = 1; i < MONITORS.size(); ++i) {
+ const auto EXTENT = MONITORS[i]->logicalBox().extent();
+ const auto POS = MONITORS[i]->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;
+ }
+ CBox mappedArea = {topLeft, bottomRight - topLeft};
+
+ auto outputMappedArea = [&mappedArea](const std::string& output) {
+ if (output == "current") {
+ if (const auto PLASTMONITOR = g_pCompositor->m_pLastMonitor.lock(); PLASTMONITOR)
+ return PLASTMONITOR->logicalBox();
+ } else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(output); PMONITOR)
+ return PMONITOR->logicalBox();
+ return mappedArea;
+ };
switch (dev->getType()) {
case HID_TYPE_TABLET: {
CTablet* TAB = reinterpret_cast<CTablet*>(dev.get());
if (!TAB->boundOutput.empty()) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromString(TAB->boundOutput); PMONITOR) {
- currentMonitor = PMONITOR->self.lock();
- mappedArea = currentMonitor->logicalBox();
- }
- }
+ mappedArea = outputMappedArea(TAB->boundOutput);
+ mappedArea.translate(TAB->boundBox.pos());
+ } else if (TAB->absolutePos) {
+ mappedArea.x = TAB->boundBox.x;
+ mappedArea.y = TAB->boundBox.y;
+ } else
+ mappedArea.translate(TAB->boundBox.pos());
- mappedArea.translate(TAB->boundBox.pos());
if (!TAB->boundBox.empty()) {
mappedArea.w = TAB->boundBox.w;
mappedArea.h = TAB->boundBox.h;
@@ -700,38 +722,14 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
}
case HID_TYPE_TOUCH: {
ITouch* TOUCH = reinterpret_cast<ITouch*>(dev.get());
- if (!TOUCH->boundOutput.empty()) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromString(TOUCH->boundOutput); PMONITOR) {
- currentMonitor = PMONITOR->self.lock();
- mappedArea = currentMonitor->logicalBox();
- }
- }
+ if (!TOUCH->boundOutput.empty())
+ mappedArea = outputMappedArea(TOUCH->boundOutput);
break;
}
case HID_TYPE_POINTER: {
IPointer* POINTER = reinterpret_cast<IPointer*>(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) {
- currentMonitor = PMONITOR->self.lock();
- mappedArea = currentMonitor->logicalBox();
- }
- }
+ if (!POINTER->boundOutput.empty())
+ mappedArea = outputMappedArea(POINTER->boundOutput);
break;
}
default: break;