summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorKhalid <khalid.y96@outlook.com>2024-03-23 23:31:03 +0300
committerGitHub <noreply@github.com>2024-03-23 20:31:03 +0000
commit059e85ae69e5d50bb6734532da4abdcf66167ab3 (patch)
treed2bc278511f778203f9c55af9b8ec6a97c789139 /src/managers
parent0dfdb6678f5362fda449694639e8fee806ca1ae4 (diff)
input: Add options to set tablet's active area (#5199)
* Add options to set tablet's active area * Set tablet's active area in `setTabletConfigs` * Fix formatting for new variables in ConfigManager * Report tablet's physical size with hyprctl
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/input/InputManager.cpp7
-rw-r--r--src/managers/input/Tablets.cpp8
2 files changed, 14 insertions, 1 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 7d820c8f..94e6abec 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1438,6 +1438,13 @@ void CInputManager::setTabletConfigs() {
auto regionBox = CBox{REGION_POS.x, REGION_POS.y, REGION_SIZE.x, REGION_SIZE.y};
if (!regionBox.empty())
wlr_cursor_map_input_to_region(g_pCompositor->m_sWLRCursor, t.wlrDevice, regionBox.pWlr());
+
+ const auto ACTIVE_AREA_SIZE = g_pConfigManager->getDeviceVec(t.name, "active_area_size", "input:tablet:active_area_size");
+ const auto ACTIVE_AREA_POS = g_pConfigManager->getDeviceVec(t.name, "active_area_position", "input:tablet:active_area_position");
+ if (ACTIVE_AREA_SIZE.x != 0 || ACTIVE_AREA_SIZE.y != 0) {
+ t.activeArea = CBox{ACTIVE_AREA_POS.x / t.wlrTablet->width_mm, ACTIVE_AREA_POS.y / t.wlrTablet->height_mm,
+ (ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t.wlrTablet->width_mm, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t.wlrTablet->height_mm};
+ }
}
}
}
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index 387212c7..9252fca4 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -51,8 +51,14 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
if (PTAB->relativeInput)
wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, dx, dy);
- else
+ else {
+ // Calculate transformations if active area is set
+ if (!PTAB->activeArea.empty()) {
+ x = (x - PTAB->activeArea.x) / (PTAB->activeArea.w - PTAB->activeArea.x);
+ y = (y - PTAB->activeArea.y) / (PTAB->activeArea.h - PTAB->activeArea.y);
+ }
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
+ }
g_pInputManager->simulateMouseMovement();
g_pInputManager->focusTablet(PTAB, EVENT->tool, true);