From 7df4e3a2e80b925a6b31c1630176736a5a705ad1 Mon Sep 17 00:00:00 2001 From: BenHodgsonR2R Date: Tue, 25 Nov 2025 16:30:50 +1100 Subject: [PATCH] config: add debounce_drag option for window drag/resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds misc:debounce_drag config option to control mouse event debouncing during window dragging and resizing operations. Values: - 0: Force off (always disabled, maximum smoothness) - 1: Force on (always enabled, helpful for low-polling mice) - 2: Auto (default, enabled on ≤60Hz monitors, disabled on >60Hz) The original debounce logic (from #4553) was always enabled and helped prevent stuttering on 60Hz monitors with low-polling mice (~125Hz), but caused slightly reduced responsiveness on high-refresh setups. This change makes the behavior adaptive by default while allowing manual override. --- src/config/ConfigManager.cpp | 1 + src/layout/IHyprLayout.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index fc020d7ac..b1812828b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -480,6 +480,7 @@ CConfigManager::CConfigManager() { registerConfigVar("misc:layers_hog_keyboard_focus", Hyprlang::INT{1}); registerConfigVar("misc:animate_manual_resizes", Hyprlang::INT{0}); registerConfigVar("misc:animate_mouse_windowdragging", Hyprlang::INT{0}); + registerConfigVar("misc:debounce_drag", Hyprlang::INT{2}); registerConfigVar("misc:disable_autoreload", Hyprlang::INT{0}); registerConfigVar("misc:enable_swallow", Hyprlang::INT{0}); registerConfigVar("misc:swallow_regex", {STRVAL_EMPTY}); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 18c100b72..d4383ca4c 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -589,7 +589,8 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { static auto PANIMATEMOUSE = CConfigValue("misc:animate_mouse_windowdragging"); static auto PANIMATE = CConfigValue("misc:animate_manual_resizes"); - static auto SNAPENABLED = CConfigValue("general:snap:enabled"); + static auto SNAPENABLED = CConfigValue("general:snap:enabled"); + static auto PDEBOUNCEDRAG = CConfigValue("misc:debounce_drag"); const auto TIMERDELTA = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - TIMER).count(); const auto MSDELTA = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - MSTIMER).count(); @@ -602,7 +603,10 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { if (m_mouseMoveEventCount == 1) totalMs = 0; - if (MSMONITOR > 16.0) { + // Apply debounce automatically for 60Hz monitors (MSMONITOR > 16.0), + // or manually if user explicitly enables it. High-refresh users get max smoothness by default. + // 0 = off, 1 = on, 2 = auto (default) + if ((MSMONITOR > 16.0 && *PDEBOUNCEDRAG == 2) || *PDEBOUNCEDRAG == 1) { totalMs += MSDELTA < MSMONITOR ? MSDELTA : std::round(totalMs * 1.0 / m_mouseMoveEventCount); m_mouseMoveEventCount += 1;