From 65389700878640fa0e90419b9cf34f48e4186fca Mon Sep 17 00:00:00 2001 From: alaricljs Date: Sat, 12 Apr 2025 10:43:13 -0400 Subject: binds: add drag_threshold for click/drag isolation (#9839) --------- Co-authored-by: Leeman --- src/config/ConfigManager.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 56ff3f30..70f6701e 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -651,6 +651,7 @@ CConfigManager::CConfigManager() { registerConfigVar("binds:disable_keybind_grabbing", Hyprlang::INT{0}); registerConfigVar("binds:window_direction_monitor_fallback", Hyprlang::INT{1}); registerConfigVar("binds:allow_pin_fullscreen", Hyprlang::INT{0}); + registerConfigVar("binds:drag_threshold", Hyprlang::INT{0}); registerConfigVar("gestures:workspace_swipe", Hyprlang::INT{0}); registerConfigVar("gestures:workspace_swipe_fingers", Hyprlang::INT{3}); @@ -2255,6 +2256,8 @@ std::optional CConfigManager::handleBind(const std::string& command bool longPress = false; bool hasDescription = false; bool dontInhibit = false; + bool click = false; + bool drag = false; const auto BINDARGS = command.substr(4); for (auto const& arg : BINDARGS) { @@ -2280,6 +2283,12 @@ std::optional CConfigManager::handleBind(const std::string& command hasDescription = true; } else if (arg == 'p') { dontInhibit = true; + } else if (arg == 'c') { + click = true; + release = true; + } else if (arg == 'g') { + drag = true; + release = true; } else { return "bind: invalid flag"; } @@ -2291,6 +2300,9 @@ std::optional CConfigManager::handleBind(const std::string& command if (mouse && (repeat || release || locked)) return "flag m is exclusive"; + if (click && drag) + return "flags c and g are mutually exclusive"; + const int numbArgs = hasDescription ? 5 : 4; const auto ARGS = CVarList(value, numbArgs); @@ -2350,7 +2362,8 @@ std::optional CConfigManager::handleBind(const std::string& command g_pKeybindManager->addKeybind(SKeybind{parsedKey.key, KEYSYMS, parsedKey.keycode, parsedKey.catchAll, MOD, MODS, HANDLER, COMMAND, locked, m_szCurrentSubmap, DESCRIPTION, release, repeat, longPress, - mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit}); + mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit, + click, drag}); } return {}; -- cgit v1.2.3