Skip to content

Commit

Permalink
pointer: map devices across all outputs by default
Browse files Browse the repository at this point in the history
  • Loading branch information
JManch committed Nov 5, 2024
1 parent 88e9e03 commit 6f230cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/devices/VirtualPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CVirtualPointer::CVirtualPointer(SP<CVirtualPointerV1Resource> resource) : point
listeners.holdBegin = pointer->events.holdBegin.registerListener([this](std::any d) { pointerEvents.holdBegin.emit(d); });
listeners.holdEnd = pointer->events.holdEnd.registerListener([this](std::any d) { pointerEvents.holdEnd.emit(d); });

boundOutput = resource->boundOutput ? resource->boundOutput->szName : "entire";
boundOutput = resource->boundOutput ? resource->boundOutput->szName : "";

deviceName = pointer->name;
}
Expand Down
52 changes: 24 additions & 28 deletions src/managers/PointerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,26 +668,37 @@ 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))
abs.x = std::clamp(abs.x, 0.0, 1.0);
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
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;
}
CBox mappedArea = {topLeft, bottomRight - topLeft};

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();
if (const auto boundMonitor = PMONITOR->self.lock(); boundMonitor)
mappedArea = boundMonitor->logicalBox();
}
}

Expand All @@ -696,40 +707,25 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
mappedArea.w = TAB->boundBox.w;
mappedArea.h = TAB->boundBox.h;
}

break;
}
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 (const auto boundMonitor = PMONITOR->self.lock(); boundMonitor)
mappedArea = boundMonitor->logicalBox();
}
}
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 (const auto PMONITOR = g_pCompositor->getMonitorFromString(POINTER->boundOutput); PMONITOR) {
if (const auto boundMonitor = PMONITOR->self.lock(); boundMonitor)
mappedArea = boundMonitor->logicalBox();
}
}
break;
Expand Down

0 comments on commit 6f230cd

Please sign in to comment.