From 4dc07c4378e0fad735fb0efc96d6200739d5cae1 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 21 Apr 2024 12:50:31 +0100 Subject: [PATCH] keybinds: clear repeat source on mouse inputs fixes #5671 --- src/managers/KeybindManager.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 39ede5d4..34e2f85b 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -335,14 +335,14 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard .submapAtPress = m_szCurrentSelectedSubmap, }; + if (m_pActiveKeybindEventSource) { + wl_event_source_remove(m_pActiveKeybindEventSource); + m_pActiveKeybindEventSource = nullptr; + m_pActiveKeybind = nullptr; + } + bool suppressEvent = false; if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) { - // clean repeat - if (m_pActiveKeybindEventSource) { - wl_event_source_remove(m_pActiveKeybindEventSource); - m_pActiveKeybindEventSource = nullptr; - m_pActiveKeybind = nullptr; - } m_dPressedKeys.push_back(KEY); @@ -353,12 +353,6 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard m_dPressedKeys.back().sent = !suppressEvent; } else { // key release - // clean repeat - if (m_pActiveKeybindEventSource) { - wl_event_source_remove(m_pActiveKeybindEventSource); - m_pActiveKeybindEventSource = nullptr; - m_pActiveKeybind = nullptr; - } bool foundInPressedKeys = false; for (auto it = m_dPressedKeys.begin(); it != m_dPressedKeys.end();) { @@ -396,6 +390,12 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) { m_tScrollTimer.reset(); + if (m_pActiveKeybindEventSource) { + wl_event_source_remove(m_pActiveKeybindEventSource); + m_pActiveKeybindEventSource = nullptr; + m_pActiveKeybind = nullptr; + } + bool found = false; if (e->source == WL_POINTER_AXIS_SOURCE_WHEEL && e->orientation == WL_POINTER_AXIS_VERTICAL_SCROLL) { if (e->delta < 0) @@ -433,6 +433,12 @@ bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) { .modmaskAtPressTime = MODS, }; + if (m_pActiveKeybindEventSource) { + wl_event_source_remove(m_pActiveKeybindEventSource); + m_pActiveKeybindEventSource = nullptr; + m_pActiveKeybind = nullptr; + } + if (e->state == WL_POINTER_BUTTON_STATE_PRESSED) { m_dPressedKeys.push_back(KEY);