aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorTobias Zimmermann <[email protected]>2024-02-28 00:21:22 +0100
committerGitHub <[email protected]>2024-02-27 23:21:22 +0000
commit489ac40abd7b3ae037e1681ee92bbef9d981a29c (patch)
treefba3d5bd1c2ca60837153ddac22d2312021bad56 /src/managers/input/InputManager.cpp
parente3373669e5544c3f18cf1edcd8fcfff9c6222f5c (diff)
downloadHyprland-489ac40abd7b3ae037e1681ee92bbef9d981a29c.tar.gz
Hyprland-489ac40abd7b3ae037e1681ee92bbef9d981a29c.zip
config: Add option to resolve keybinds by sym instead of code (#4851)
This commit adds the new configuration option 'resolve_binds_by_sym' which can be set globally or per-device. It is off by default, which preserves the current behavior. This setting only affects the behavior of keybinds that are defined via key symbols, not those defined via keycode. Binds defined by symbols currently activate if the keycode pressed would generate the specified symbol on the first layout specified in the input section. If enabled, keys pressed on the relevant device will instead match keybinds by the symbols they produce with their current layout. Closes #1881.
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index bda23378..2c8c2d7c 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -823,7 +823,8 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
const auto REPEATRATE = g_pConfigManager->getDeviceInt(devname, "repeat_rate", "input:repeat_rate");
const auto REPEATDELAY = g_pConfigManager->getDeviceInt(devname, "repeat_delay", "input:repeat_delay");
- const auto NUMLOCKON = g_pConfigManager->getDeviceInt(devname, "numlock_by_default", "input:numlock_by_default");
+ const auto NUMLOCKON = g_pConfigManager->getDeviceInt(devname, "numlock_by_default", "input:numlock_by_default");
+ const auto RESOLVEBINDSBYSYM = g_pConfigManager->getDeviceInt(devname, "resolve_binds_by_sym", "input:resolve_binds_by_sym");
const auto FILEPATH = g_pConfigManager->getDeviceString(devname, "kb_file", "input:kb_file");
const auto RULES = g_pConfigManager->getDeviceString(devname, "kb_rules", "input:kb_rules");
@@ -834,7 +835,8 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true;
- pKeyboard->enabled = ENABLED;
+ pKeyboard->enabled = ENABLED;
+ pKeyboard->resolveBindsBySym = RESOLVEBINDSBYSYM;
try {
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
@@ -906,6 +908,9 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
+ xkb_state_unref(pKeyboard->xkbTranslationState);
+ pKeyboard->xkbTranslationState = xkb_state_new(KEYMAP);
+
wlr_keyboard_set_keymap(wlr_keyboard_from_input_device(pKeyboard->keyboard), KEYMAP);
wlr_keyboard_modifiers wlrMods = {0};
@@ -1127,6 +1132,8 @@ void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
pKeyboard->hyprListener_keyboardMod.removeCallback();
pKeyboard->hyprListener_keyboardKey.removeCallback();
+ xkb_state_unref(pKeyboard->xkbTranslationState);
+
if (pKeyboard->active) {
m_lKeyboards.remove(*pKeyboard);