commit aa65896fbfde70c020fabd00c789544fa1c07d61
parent bddf05e0fc6451011854199a60a5d1910295f36c
Author: John Sullivan <jsullivan@csumb.edu>
Date: Sun, 9 Jan 2022 21:02:46 -0800
keyboard.c: fix update/draw logic in kbd_unpress_key
thanks @0x4261756D @earboxer for pointing out this issue
Diffstat:
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/keyboard.c b/keyboard.c
@@ -166,26 +166,34 @@ kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
void
kbd_unpress_key(struct kbd *kb, uint32_t time) {
+ bool unlatch_shift = false;
+
if (kb->last_press) {
- kbd_draw_key(kb, kb->last_press, Unpress);
- if (kb->last_press->type == Copy) {
+ unlatch_shift = (kb->mods & Shift) == Shift;
+
+ if (unlatch_shift) {
+ kb->mods ^= Shift;
+ zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
+ }
+
+ if (kb->last_press->type == Copy) {
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
WL_KEYBOARD_KEY_STATE_RELEASED);
} else {
zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
WL_KEYBOARD_KEY_STATE_RELEASED);
}
- kb->last_press = NULL;
if (kb->compose >= 2) {
kb->compose = 0;
kbd_switch_layout(kb, kb->prevlayout);
- if ((kb->mods & Shift) == Shift)
- kb->mods ^= Shift;
- } else if ((kb->mods & Shift) == Shift) {
- kb->mods ^= Shift;
+ } else if (unlatch_shift) {
kbd_draw_layout(kb);
- }
+ } else {
+ kbd_draw_key(kb, kb->last_press, Unpress);
+ }
+
+ kb->last_press = NULL;
}
}