aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-10-14 12:38:44 +0100
committervaxerski <[email protected]>2022-10-14 12:38:44 +0100
commit724fa4a7d44fe594109213b8a6f438e3539aa332 (patch)
tree840651e65089da97f581896821ed41fc24d778f1
parentcee0645fd1e8f84438635483fd17007c077812fe (diff)
downloadHyprland-724fa4a7d44fe594109213b8a6f438e3539aa332.tar.gz
Hyprland-724fa4a7d44fe594109213b8a6f438e3539aa332.zip
add touch binding to output
-rw-r--r--src/config/ConfigManager.cpp2
-rw-r--r--src/helpers/WLClasses.hpp2
-rw-r--r--src/managers/input/InputManager.cpp6
-rw-r--r--src/managers/input/Touch.cpp6
4 files changed, 16 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 10840a65..93d684f5 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -148,6 +148,7 @@ void CConfigManager::setDefaultVars() {
configValues["input:touchpad:drag_lock"].intValue = 0;
configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
configValues["input:touchdevice:transform"].intValue = 0;
+ configValues["input:touchdevice:output"].strValue = STRVAL_EMPTY;
configValues["binds:pass_mouse_when_bound"].intValue = 0;
configValues["binds:scroll_event_delay"].intValue = 300;
@@ -189,6 +190,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
cfgValues["left_handed"].intValue = 0;
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
cfgValues["touch_transform"].intValue = 0;
+ cfgValues["touch_output"].strValue = STRVAL_EMPTY;
}
void CConfigManager::setDefaultAnimationVars() {
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index a6751cd9..515ef946 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -328,6 +328,8 @@ struct STouchDevice {
std::string name = "";
+ std::string boundOutput = "";
+
DYNLISTENER(destroy);
bool operator==(const STouchDevice& other) {
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index dc85735b..5ef257e3 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1092,6 +1092,12 @@ void CInputManager::setTouchDeviceConfigs() {
const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
+
+ const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "touch_output") : g_pConfigManager->getString("input:touchdevice:output");
+ if (!OUTPUT.empty() && OUTPUT != STRVAL_EMPTY)
+ PTOUCHDEV->boundOutput = OUTPUT;
+ else
+ PTOUCHDEV->boundOutput = "";
}
}
}
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index d7b52171..e140d8a1 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -3,6 +3,12 @@
void CInputManager::onTouchDown(wlr_touch_down_event* e) {
auto PMONITOR = g_pCompositor->getMonitorFromName(e->touch->output_name ? e->touch->output_name : "");
+
+ const auto PDEVIT = std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&](const STouchDevice& other) { return other.pWlrDevice == &e->touch->base; });
+
+ if (PDEVIT != m_lTouchDevices.end() && !PDEVIT->boundOutput.empty())
+ PMONITOR = g_pCompositor->getMonitorFromName(PDEVIT->boundOutput);
+
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_pLastMonitor;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);