Virtual keyboard support in KWin/Wayland 5.7

Over the last weeks I worked on improved input device support in KWin/Wayland and support for virtual keyboard. KWin 5.7 will integrate the new QtVirtualKeyboard module which is now available under GPLv3. For us this means that we have access to a high quality QML based keyboard. For Qt it means that the virtual keyboard is exposed to more users and thanks to the open source nature it means that we can upstream fixes.

The virtual keyboard is integrated into KWin/Wayland making it part of our platform. To support it we implemented the text input interface in KWayland. If an application supports it, then the virtual keyboard can input text from the compositor side.

Video on youtube:

As you can see in the video the virtual keyboard is only enabled by default if no hardware keyboard is available. If a hardware keyboard gets plugged in the virtual keyboard gets disabled automatically. In addition there is a Status Notifier Item registered which allows to enable/disable the virtual keyboard independently of the hardware keyboard state. So on a notebook with a touch screen it’s possible to get the virtual keyboard even if there is (of course) a hardware keyboard.

Implementing support for the virtual keyboard was an interesting journey which required many unexpected changes and improvements all over the place. First of all wl_text_input interface needed to be implemented as that’s what is used in QtWayland 5.6. At one point I hit a wall and saw that the implementation in QtWayland is incomplete. So I checked how it looks like in QtWayland 5.7 and alas the complete implementation changed, it’s using zwp_text_input_unstable_v2, which is not even in wayland-protocols. I’m not happy about QtWayland using not standardized interfaces as I think that’s very bad for compatibility. Nevertheless I also added support for it in KWayland as otherwise we would not be able to communicate with applications using Qt 5.7. As the QtVirtualKeyboard will only be available with Qt 5.7, we need to support Qt 5.7’s interface as well. In KWayland this is implemented in a transparent way and KWin announces support for both interfaces.

Another area which needed lots of work is the support for input devices in KWin. We need to properly detect whether a real keyboard is available. We needed to add further support for touch events in KWin. So thanks to the integration of virtual keyboard KWin now supports touch much better on Wayland.

The improvements for input devices are also useful in other areas. E.g. today I landed a change to not show the cursor image if no pointer device (mouse or touchpad) is connected.

21 Replies to “Virtual keyboard support in KWin/Wayland 5.7”

      1. My girlfriend has a Yoga and we were quite surprised how bad the support for transitioning between table and laptop mode is currently supported. So kudos for this!

        Does this mean it will be supported on Wayland in the next big KDE release or am I a bit too optimistic?

        Also, will this be supported on Xorg as well or is that a future thing? (And I hope I haven’t missed the addition of this feature to Kwin ages ago… )

        1. X11 is something I would also like to support, but I fear 5.7 is an unrealistic target

          1. Hi Martin,

            Just to let you know, I have an Asus Vivobook Flip (the likes with touchscreen and 360° rotating screen), newly acquired and very motivated to see KDE software using this hardware up to its potential.

            I’ve seen often that you lack testing on touchscreen, so if ever you need me to start a Krypton/Neon live image on this and report, please just let me know. The “GPU” is a mere Intel HD Graphics, which I understand is the most compatible with Wayland, so good for testing I guess.

            I’m no dev, but probably tech savvy enough to do this kind of testing (tough I would most likely require some guidance in debugging).

              1. I don’t seem to receive e-mails though I checked the “follow up” e-mail notice, so please tell me if you need my e-mail address and where I can send it to you.

    1. KDE is huge – I cannot give a generic answer to that. Best check out the getting started guides

  1. Could this be easily back ported to 5.6? I have a Acer Switch 10 that needs this today! Can’t wait for July to come either way. Nice work!

  2. Quite a few mice do expose both a keyboard and a mouse interface. Will that work with the detection mode and if not can the virtual keyboard be enforced?

    1. we are able to detect whether it’s a “real” keyboard. Otherwise every power button would already break it.

  3. Wait, I thought the zwp_* protocols were just drafts of what will eventually be standartized? Bad things happen when a protocol becomes a standard without anybody having tried to implement it first…

    1. Yes, but this protocol is not yet even part of wayland-protocol’s unstable folder.

  4. Hi, I just wanted to say that I’m thrilled about this new feature. I run KDE on a Lenovo Yoga 2 and really look forward to using it as a tablet sometimes.
    Thank you, keep up the great work!

  5. This all looks great! I think I’m ready to switch my laptop over to KDE. I particularly like the virtual keyboard, and I’m looking forward to more touch-friendliness in the future.

    I have a Thinkpad Yoga 12. Is there currently a way to manually switch on the virtual keyboard or disable the actual keyboard? Do I just need to be patient and wait for someone to develop a widget?

    1. Is there currently a way to manually switch on the virtual keyboard or disable the actual keyboard?

      Yes, KWin adds a status notifier item. So through the systemtray it can be enabled manually.

Comments are closed.