Commit 7c26d5a21795acd7c8a6d573aa043e8a818712a0 Parent: 35f1062e42ee5ba57b2e91bf932cb422581379ab Author: mcol <mcol@posteo.net> Date: 2021-01-20 21:39:13 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-01-20 21:39:13 +0000 Only bind the 6 vt switching keys that will work with the configured mod
src/config.c Modified
@@ -242,8 +242,9 @@ if (!server->vt_switching) return; - /* Depending on what the user sets the mod key to, either func keys or - * direct VT key combo "keys" will be matched, so configure both. */ + /* If the configured mod key is alt then we have to bind the VT key combos + * otherwise they interfere with the alt. With other mods we don't get this + * key combo so we have to bind the function keys manually. */ uint32_t func_keys[] = { XKB_KEY_F1, XKB_KEY_F2, @@ -251,6 +252,8 @@ XKB_KEY_F4, XKB_KEY_F5, XKB_KEY_F6, + }; + uint32_t switch_keys[] = { XKB_KEY_XF86Switch_VT_1, XKB_KEY_XF86Switch_VT_2, XKB_KEY_XF86Switch_VT_3, @@ -258,15 +261,23 @@ XKB_KEY_XF86Switch_VT_5, XKB_KEY_XF86Switch_VT_6 }; + uint32_t *keys; + if (server->mod == WLR_MODIFIER_ALT) { + keys = switch_keys; + } else { + keys = func_keys; + } + struct binding *kb; - for (unsigned i = 0; i < 12; i++) { + for (unsigned i = 0; i < 6; i++) { kb = calloc(1, sizeof(struct binding)); kb->mods = WLR_MODIFIER_CTRL; - kb->key = func_keys[i]; + kb->key = *keys; + keys++; kb->action = &change_vt; kb->data = calloc(1, sizeof(unsigned)); - *(unsigned *)(kb->data) = (i + 1) % 6; + *(unsigned *)(kb->data) = i + 1; wl_list_insert(server->key_bindings.prev, &kb->link); } }