Relationship between the input method server and applications under Fcitx5+KWin/Wayland
With the latest release of Plasma 5.24, the native wayland input method support in KWin is improved to support non-virtual keyboard input method like Fcitx 5. (There are lots of issues if you try to use zwp_input_method_v1 in 5.23).
This leads to a outcome that non-Gtk/Qt application using text-input-v3 can be used flawlessly under KWin Wayland. Though, there is some small step that you’ll need to follow.
First of all, I suggest you have most up-to-date Plasma 5.24 and Fcitx 5.0.14. I believe the distribution that picks up Plasma 5.24 should also have up-to-date Fcitx 5.
Next, you’ll need to make KWin Wayland to launch Fcitx 5. This is required because only the privileged client is allowed to talk to KWin on input method protocol. KWin will send a socket file descriptor to the input method and input method service need to use this socket to connect to KWin.
Thanks to a simple KCM, which is accessible from systemettings -> Virtual keyboard (Naming of the KCM is not so good, because it was designed for mobile phone to launch maliit initially.)
From there, just select Fcitx 5. This requires you to have up-to-date Fcitx 5 to make it show up in this KCM, because it requires a special new field in the Fcitx 5 desktop file.
Although kwin will launch input method in a pretty early stage, but there might still be some race condition if there is another mechanism (Like XDG autostart) to launch Fcitx 5. You can try to re-login to see if if works, if not, you may want to disable Fcitx 5’s own XDG autostart or what ever mechanism you’re using to launch Fcitx 5.
Theoretically you don’t need to re-login, KWin can reload it immediately after you apply the setting in systemsettings. I would just re-login to make sure everything it properly launched, then you should be good to go.
Hello world from Chinese Pinyin!
Should I keep setting GTK_IM_MODULE / QT_IM_MODULE / XMODIFIERS?
Qt has text-input-v2 support which can be used if QT_IM_MODULE is empty, but it has some small issue regarding the preedit. Also, with current version of wayland input method protocol, there can be only one global input context for wayland. So right now it can be a problem if you want to use the “per-application” input state supported by Fcitx 5. But using Qt’s text-input protocol has one benefit, is that visually there won’t be blinking for input window.
Gtk has text-input-v3 support, but it’s preedit is poorly styled with bold font for highlight. Also, its surrounding text support is poorly implemented. So for now, using GTK_IM_MODULE=fcitx might still be good option if you want to have all Fcitx features.
It’s required to support XWayland.