Can't input uppercase letters with virtual keyboard protocol in wayland

15 views
Skip to first unread message

Fan Zeming

unread,
Mar 4, 2025, 3:50:48 AMMar 4
to fcit...@googlegroups.com
Hi,

I'm using kwin 6 with wayland enabled, and I'm writing a virtual
keyboard using the `org.fcitx.Fcitx5.VirtualKeyboardBackend1` interface.
Since kwin can only handle a limited set of keysyms, I use the following
method to emulate inputting a uppercase letter:

keycode(50) 'Shift' pressed -> keycode(30) 'u' pressed -> keycode(30)
'u' released -> keycode(50) 'Shift' released

But, in `WaylandIMInputContextV1::forwardKeyDelegate`, it will send a
released event automatically. Events received in kwin will became:

keycode(50) 'Shift' pressed -> keycode(50) 'Shift' released ->
keycode(30) 'u' pressed -> keycode(30) 'u' released -> keycode(30) 'u'
released -> keycode(50) 'Shift' released

Is there any method to input a uppercase letter through the
`org.fcitx.Fcitx5.VirtualKeyboardBackend1` interface with a input method
like `keyboard-us`? I know the auto release is a trick to implement key
repetition in wayland. Can we disable this if the forward key event is
from a virtual keyboard event?

--
Best regards,
Fan Zeming

CS Slayer

unread,
Mar 4, 2025, 4:04:39 AMMar 4
to fcitx-dev
Put what keyboard engine currently does aside, just simply imagine what should be done.

So basically two way I would imagine:
1. send key sym to client. This is what I hope it can be done, but not currently possible for all client on wayland
2. use commit_string, reliable, but not simulate key sequence.
3. Or, make forwardKeyDelegate key to generate key sequence that should produce the given xkb state. instead of generate just press, if modifier is not empty.

You may want to add a check to only apply such logic if key is from virtual keyboard (isVirtual()).

fortime fan

unread,
Mar 4, 2025, 5:11:52 AMMar 4
to fcit...@googlegroups.com
After some tests, I found it is not related to the auto release trick. It looks `wl_keyboard::modifiers` should be used instead of `wl_keyboard::key`. It won't matter whether `sendKeyVK` is called or not for `Shift`.

--
Best regards,
Fan Zeming
--
You received this message because you are subscribed to the Google Groups "fcitx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fcitx-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fcitx-dev/1ff3bb38-95ce-40c0-ab1d-87d49b26c9e3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages