config: add debounce_drag option for window drag/resize

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.
This commit is contained in:
BenHodgsonR2R 2025-11-25 16:30:50 +11:00
parent fe6a855bbb
commit 7df4e3a2e8
2 changed files with 7 additions and 2 deletions

View file

@ -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});

View file

@ -589,7 +589,8 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
static auto PANIMATEMOUSE = CConfigValue<Hyprlang::INT>("misc:animate_mouse_windowdragging");
static auto PANIMATE = CConfigValue<Hyprlang::INT>("misc:animate_manual_resizes");
static auto SNAPENABLED = CConfigValue<Hyprlang::INT>("general:snap:enabled");
static auto SNAPENABLED = CConfigValue<Hyprlang::INT>("general:snap:enabled");
static auto PDEBOUNCEDRAG = CConfigValue<Hyprlang::INT>("misc:debounce_drag");
const auto TIMERDELTA = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - TIMER).count();
const auto MSDELTA = std::chrono::duration_cast<std::chrono::milliseconds>(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;