Skip to content

Commit

Permalink
Move entire area search to a function. Enable tablet to map 'entire'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Agent_00Ming committed Nov 5, 2024
1 parent 88e9e03 commit 7ea4bd2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
42 changes: 24 additions & 18 deletions src/managers/PointerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -685,7 +703,9 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
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) {
if (TAB->boundOutput == "entire")
mappedArea = getEntireMappableArea();
else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(TAB->boundOutput); PMONITOR) {
currentMonitor = PMONITOR->self.lock();
mappedArea = currentMonitor->logicalBox();
}
Expand All @@ -711,23 +731,9 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
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) {
if (POINTER->boundOutput == "entire")
mappedArea = getEntireMappableArea();
else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(POINTER->boundOutput); PMONITOR) {
currentMonitor = PMONITOR->self.lock();
mappedArea = currentMonitor->logicalBox();
}
Expand Down
4 changes: 3 additions & 1 deletion src/managers/PointerManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7ea4bd2

Please sign in to comment.