svkbd

simple virtual keyboard
git clone git://git.suckless.org/svkbd
Log | Files | Refs | README | LICENSE

commit 92795b2a0ac2f9c2a26bcdf8752e8f0ab7c11675
parent ff704d5d1e801f9783a9453972978d7db26d44a2
Author: norayr chilingarian <norayr@arnet.am>
Date:   Sun,  3 Dec 2023 20:22:04 +0400

fix uppercase in armenian (and perhaps some other) layouts

"This patch fixes uppercase in armenian (and perhaps some other) layouts. svkbd
was previously registering a key in one modification (xorg accepts up to 4
modifications). with this patch svkbd registers 2 modifications - upper and
lower case. function tmp_remap changed in a way that if the key is not found in
a current layout, it is temporary added to it. for cyrillic layout uppercase
(when shift is pressed) letters were showing anyway, because those are somehow
found (modified) by xorg. but for armenian layout that did not work. now works."

Patch by նորայր <norayr@arnet.am>

Diffstat:
Msvkbd.c | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/svkbd.c b/svkbd.c @@ -481,9 +481,18 @@ press(Key *k, KeySym buttonmod) int tmp_remap(KeySym keysym) { - XChangeKeyboardMapping(dpy, tmp_keycode, 1, &keysym, 1); + /* map lower and upper case of keysym to the temporary keycode */ + KeySym syms[2]; + XConvertCase(keysym, &syms[0], &syms[1]); + + /* if keysym is capital letter then swap upper and lower case */ + if (keysym == syms[1]) + syms[1] = syms[0], syms[0] = keysym; + + XChangeKeyboardMapping(dpy, tmp_keycode, syms[0] == syms[1] ? 1 : 2, syms, 1); XSync(dpy, False); + printdbg("Temporary map keysym %ld (%ld, %ld) to keycode %d\n", keysym, syms[0], syms[1], tmp_keycode); return tmp_keycode; }