From f08167c877227b2c9e0b59e7d38d072bdcd944a5 Mon Sep 17 00:00:00 2001 From: may <63159454+m4rch3n1ng@users.noreply.github.com> Date: Sun, 15 Jun 2025 11:45:06 +0200 Subject: [PATCH] input: add sticky option for drag_lock (#10702) * allow configuring the sticky option for `drag_lock` * enable sticky drag_lock by default as recommended by libinput recommended here: https://lists.freedesktop.org/archives/wayland-devel/2024-November/043860.html --- CMakeLists.txt | 2 +- src/config/ConfigDescriptions.hpp | 7 ++++--- src/config/ConfigManager.cpp | 4 ++-- src/managers/input/InputManager.cpp | 8 ++++---- src/meson.build | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 618938031..8d8feb607 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,7 +136,7 @@ pkg_check_modules( pixman-1 xcursor libdrm - libinput + libinput>=1.28 gbm gio-2.0 re2) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 7d62c8338..a4bcf4409 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -623,9 +623,10 @@ inline static const std::vector CONFIG_OPTIONS = { }, SConfigOptionDescription{ .value = "input:touchpad:drag_lock", - .description = "When enabled, lifting the finger off for a short time while dragging will not drop the dragged item.", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{false}, + .description = "When enabled, lifting the finger off while dragging will not drop the dragged item. 0 -> disabled, 1 -> enabled with timeout, 2 -> enabled sticky." + "dragging will not drop the dragged item.", + .type = CONFIG_OPTION_INT, + .data = SConfigOptionDescription::SRangeData{2, 0, 2}, }, SConfigOptionDescription{ .value = "input:touchpad:tap-and-drag", diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 6759771c6..8fc6e3265 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -652,7 +652,7 @@ CConfigManager::CConfigManager() { registerConfigVar("input:touchpad:middle_button_emulation", Hyprlang::INT{0}); registerConfigVar("input:touchpad:tap-to-click", Hyprlang::INT{1}); registerConfigVar("input:touchpad:tap-and-drag", Hyprlang::INT{1}); - registerConfigVar("input:touchpad:drag_lock", Hyprlang::INT{0}); + registerConfigVar("input:touchpad:drag_lock", Hyprlang::INT{2}); registerConfigVar("input:touchpad:scroll_factor", {1.f}); registerConfigVar("input:touchpad:flip_x", Hyprlang::INT{0}); registerConfigVar("input:touchpad:flip_y", Hyprlang::INT{0}); @@ -775,7 +775,7 @@ CConfigManager::CConfigManager() { m_config->addSpecialConfigValue("device", "middle_button_emulation", Hyprlang::INT{0}); m_config->addSpecialConfigValue("device", "tap-to-click", Hyprlang::INT{1}); m_config->addSpecialConfigValue("device", "tap-and-drag", Hyprlang::INT{1}); - m_config->addSpecialConfigValue("device", "drag_lock", Hyprlang::INT{0}); + m_config->addSpecialConfigValue("device", "drag_lock", Hyprlang::INT{2}); m_config->addSpecialConfigValue("device", "left_handed", Hyprlang::INT{0}); m_config->addSpecialConfigValue("device", "scroll_method", {STRVAL_EMPTY}); m_config->addSpecialConfigValue("device", "scroll_button", Hyprlang::INT{0}); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 8d9d40b25..e0957abfb 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1233,10 +1233,10 @@ void CInputManager::setPointerConfigs() { else libinput_device_config_tap_set_drag_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_ENABLED); - if (g_pConfigManager->getDeviceInt(devname, "drag_lock", "input:touchpad:drag_lock") == 0) - libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); - else - libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED); + const auto TAP_DRAG_LOCK = g_pConfigManager->getDeviceInt(devname, "drag_lock", "input:touchpad:drag_lock"); + if (TAP_DRAG_LOCK >= 0 && TAP_DRAG_LOCK <= 2) { + libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, static_cast(TAP_DRAG_LOCK)); + } if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) libinput_device_config_tap_set_enabled(LIBINPUTDEV, diff --git a/src/meson.build b/src/meson.build index 3973dc4cc..d0a1590e8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -21,7 +21,7 @@ executable( dependency('libdrm'), dependency('egl'), dependency('xkbcommon'), - dependency('libinput'), + dependency('libinput', version: '>=1.28'), dependency('re2'), xcb_dep, xcb_composite_dep,