From 221acebf2cff1125d3183d5bb0ace17a8f4da9de Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 19 Mar 2022 22:03:40 +0100 Subject: [PATCH] input tweaks --- src/events/Events.cpp | 2 +- src/managers/InputManager.cpp | 11 ++++++----- src/managers/KeybindManager.cpp | 7 ++++++- src/managers/KeybindManager.hpp | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/events/Events.cpp b/src/events/Events.cpp index 03882ccd..4e31a065 100644 --- a/src/events/Events.cpp +++ b/src/events/Events.cpp @@ -191,7 +191,7 @@ void Events::listener_unmapLayerSurface(wl_listener* listener, void* data) { void Events::listener_commitLayerSurface(wl_listener* listener, void* data) { SLayerSurface* layersurface = wl_container_of(listener, layersurface, listen_commitLayerSurface); - if (!layersurface->layerSurface->output) + if (!layersurface->layerSurface || !layersurface->layerSurface->output) return; const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output); diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index 64e9bca9..ecf63bf2 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -131,17 +131,18 @@ void CInputManager::onKeyboardKey(wlr_event_keyboard_key* e, SKeyboard* pKeyboar wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat); + bool found = false; if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) { for (int i = 0; i < syms; ++i) - g_pKeybindManager->handleKeybinds(MODS, keysyms[i]); + found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i]) || found; } else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) { // hee hee } - wlr_seat_set_keyboard(g_pCompositor->m_sWLRSeat, pKeyboard->keyboard); - wlr_seat_keyboard_notify_key(g_pCompositor->m_sWLRSeat, e->time_msec, e->keycode, e->state); - - g_pCompositor->focusWindow(g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal())); + if (!found) { + wlr_seat_set_keyboard(g_pCompositor->m_sWLRSeat, pKeyboard->keyboard); + wlr_seat_keyboard_notify_key(g_pCompositor->m_sWLRSeat, e->time_msec, e->keycode, e->state); + } } void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index e1e77973..a4206340 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -26,7 +26,8 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) { return modMask; } -void CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key) { +bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key) { + bool found = false; for (auto& k : m_dKeybinds) { if (modmask != k.modmask) continue; @@ -41,7 +42,11 @@ void CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t // yes. if (k.handler == "exec") { spawn(k.arg); } else if (k.handler == "killactive") { killActive(k.arg); } + + found = true; } + + return found; } // Dispatchers diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 067a84bf..6400b193 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -13,7 +13,7 @@ struct SKeybind { class CKeybindManager { public: - void handleKeybinds(const uint32_t&, const xkb_keysym_t&); + bool handleKeybinds(const uint32_t&, const xkb_keysym_t&); void addKeybind(SKeybind); uint32_t stringToModMask(std::string); void clearKeybinds();