diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-07-08 09:27:17 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-07-08 09:27:17 +0200 |
| commit | cd0a01f4de6e1489caa35bece331c81dbaab2587 (patch) | |
| tree | 17905972a6749532b6688b27590063f92d9911ec /src/managers/KeybindManager.cpp | |
| parent | 75c2a378e3c9368feb57a31710de26decc3da3bc (diff) | |
Added binding by keycodes
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ce99030e..bb66e83d 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -69,7 +69,7 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) { return modMask; } -bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key) { +bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode) { bool found = false; if (handleInternalKeybinds(key)) @@ -82,15 +82,24 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap) continue; - // oMg such performance hit!!11! - // this little maneouver is gonna cost us 4µs - const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE); - const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY); - // small TODO: fix 0-9 keys and other modified ones with shift - - if (key != KBKEY && key != KBKEYUPPER) - continue; + if (k.keycode != -1) { + if (keycode != k.keycode) + continue; + + } else { + if (key == 0) + continue; // this is a keycode check run + + // oMg such performance hit!!11! + // this little maneouver is gonna cost us 4µs + const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE); + const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY); + // small TODO: fix 0-9 keys and other modified ones with shift + + if (key != KBKEY && key != KBKEYUPPER) + continue; + } const auto DISPATCHER = m_mDispatchers.find(k.handler); @@ -99,7 +108,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str()); } else { // call the dispatcher - Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, KBKEYUPPER); + Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, key); DISPATCHER->second(k.arg); } |
