When code_mod is used, allow for resetting modifiers or not (default is not to reset them)

This commit is contained in:
Maarten van Gompel 2021-08-23 18:58:29 +02:00 committed by John Sullivan
parent 9eee270dfd
commit 00f288b609
2 changed files with 8 additions and 3 deletions

View File

@ -48,6 +48,7 @@ struct key {
* XKB keycodes are +8 */
struct layout *layout; //pointer back to the parent layout that holds this key
const uint32_t code_mod; /* modifier to force when this key is pressed */
bool reset_mod; /* reset modifiers when clicked */
//actual coordinates on the surface (pixels), will be computed automatically for all keys
uint32_t x, y, w, h;
@ -170,7 +171,11 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
switch (k->type) {
case Code:
if (k->code_mod) {
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, k->code_mod, 0, 0, 0);
if (k->reset_mod) {
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, k->code_mod, 0, 0, 0);
} else {
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods ^ k->code_mod, 0, 0, 0);
}
} else {
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
}

View File

@ -274,8 +274,8 @@ static struct key keys_special[] = {
{"", "", 2.0, Mod, Shift},
{";", ":", 1.0, Code, KEY_SEMICOLON},
{"/", "?", 1.0, Code, KEY_SLASH},
{"<", "«", 1.0, CodeMod, KEY_COMMA, 0, AltGr},
{">", "»", 1.0, CodeMod, KEY_DOT, 0, AltGr},
{"<", "«", 1.0, Code, KEY_COMMA, 0, AltGr},
{">", "»", 1.0, Code, KEY_DOT, 0, AltGr},
{"¡", "¿", 1.0, Code, KEY_MENU},
{"", "", 1.0, Pad},
{"AGr", "AGr", 1.0, Mod, AltGr},