From 812250582584f6ab1555fff98591f03ce0f2e5b3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 27 Aug 2022 19:29:28 +0200 Subject: [PATCH] pass press and release events separately --- src/managers/KeybindManager.cpp | 19 ++++++++++++++++--- src/managers/KeybindManager.hpp | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7b4eb211..318d7407 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -265,7 +265,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& } for (auto& k : m_lKeybinds) { - if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap || (!pressed && !k.release) || k.shadowed) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap || (!pressed && !k.release && k.handler != "pass") || k.shadowed) continue; if (!key.empty()) { @@ -302,8 +302,13 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& } else { // call the dispatcher Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %s, %d)", modmask, key.c_str(), keysym); + + m_iPassPressed = (int)pressed; + DISPATCHER->second(k.arg); + m_iPassPressed = -1; + if (k.handler == "submap") { found = true; // don't process keybinds on submap change. break; @@ -1379,8 +1384,16 @@ void CKeybindManager::pass(std::string regexp) { wlr_keyboard_modifiers kbmods = {g_pInputManager->accumulateModsFromAllKBs(), 0, 0, 0}; wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &kbmods); - wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_PRESSED); - wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_RELEASED); + if (g_pKeybindManager->m_iPassPressed == 1) + wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_PRESSED); + else if (g_pKeybindManager->m_iPassPressed == 0) + wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_RELEASED); + else { + // dynamic call of the dispatcher + + wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_PRESSED); + wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_RELEASED); + } wlr_seat_keyboard_notify_enter(g_pCompositor->m_sSeat.seat, PLASTSRF, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers); } diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 7f9faa4b..bb6666c8 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -62,6 +62,8 @@ private: uint32_t m_uTimeLastMs = 0; uint32_t m_uLastCode = 0; + int m_iPassPressed = -1; // used for pass + CTimer m_tScrollTimer; bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&, bool, uint32_t);