Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tablet] Allow mapping to entire monitor layout #7586

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading