Complex text input in Plasma
mgraesslin at kde.org
Thu Apr 6 19:21:16 UTC 2017
Am 2017-04-06 19:16, schrieb Eike Hein:
> In the aftermath of D5301, Martin asked to compile a document on the
> requirements for complex text input in Plasma, especially with the
> opportunities provided by the Wayland transition. It makes sense to
> share this document with all of you, to
Thanks for the nice write down.
> * KWin is smart enough to do cool things like switch keyboard
> layouts automatically per virtual desktop or even window
that's actually also a feature of the keyboard daemon we have on X11.
Only on wayland KWin takes care of it.
> = The situation on Wayland =
> Currently, only ibus works on Wayland. Input method popups are not
> positioned correctly, but otherwise things work. The situation is
> just as good or bad as on X11.
Sharing a bit more about state of Wayland:
There is the text-input protocol which KWin supports and uses for
virtual keyboard. This means we already have the possibility to do
things like text input, text prediction, cursor moving, styling hints
(not yet implemented as virt keyboard doesn't support it), etc. etc. out
of the box with Qt applications. We know whether the application
supports it. We know the position of the text field and much more. For
those interested: relevant code is in KWin/virtualkeyboard.cpp
Ideally we would build up on this. We must not (!) specify an input
plugin for Qt apps as that would break the virtual keyboard. And even if
others give up on convergence I still think it's important to support it
and have it as a target.
So for input methods KWin would have to provide the UI interaction. Of
course I do not want to rebuild such a stack but would prefer to be able
to hook into an existing - I hope that's possible. Maybe a similar
approach as to how virtual keyboard works: kwin just emulates to the
qtvirtualkeyboard like if it were in application. So maybe KWin could
load one of the plugins and interact with them as a proxy for the
application and just forward the result through the text input
What I could imagine is that we start with emoji support. Might sound
weird but is a simplified use case to just "play" with it and
experiment. We could setup a global shortcut (like the one in GNOME),
pop up a UI with the emoji selection and go through the text input
protocol to send the emoji into the application.
Unfortunately text input in Wayland is weird as there are two competing
protocol versions and Qt has one of them. There is the zwp_text_input_v1
which is part of Wayland-protocols and zwp_text_input_v2 which is part
of Qt. It is not upstreamed, but uses upstream naming conventions. Which
will result in a horrible mess once upstream introduces a
zwp_text_input_v2. KWin supports both versions at the same time, but it
makes everything more complex and we currently can only assume that it
works correctly with Qt apps. The GTK version we support on Wayland
neither supports v1 nor v2. For the newer GTK versions which we do not
support yet I do not know. Also it leaves out Xwayland application but
there a bridge to one of the existing X11 solutions is thinkable.
More information about the Plasma-devel