Integrate QtVirtualKeyboard into KWin/Wayland
ClosedPublic

Authored by graesslin on May 19 2016, 10:35 AM.

Details

Summary

The idea is to have KWin provide a virtual keyboard. To support this
KWin uses the QT_IM_MODULE qtvirtualkeyboard and makes sure that the
QPA plugin loads it.

KWin has a new class VirtualKeyboard which acts as the focus object and
the "proxy" for input methods. The QPA plugin ensures that this is the
focusObject, so that all input method related events are sent to this
class. From there it will be possible to delegate to other applications
through the Wayland interfaces.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin updated this revision to Diff 3879.May 19 2016, 10:35 AM
graesslin retitled this revision from to Integrate QtVirtualKeyboard into KWin/Wayland.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
graesslin added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptMay 19 2016, 10:35 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript

Virtual keyboard with some test input in the various supported layouts

broulik added inline comments.
qml/virtualkeyboard/main.qml
26

Instead of making a transparent Rectangle, just use Item instead

virtualkeyboard.cpp
292

Perhaps set ImhSensitiveData | ImhHiddenText ?

graesslin added inline comments.May 19 2016, 1:07 PM
virtualkeyboard.cpp
292

No those are already part of the contentHints() and already mapped.

graesslin marked an inline comment as done.May 19 2016, 1:11 PM
graesslin updated this revision to Diff 3904.May 20 2016, 9:19 AM

Adjust to API changes

graesslin updated this revision to Diff 3964.May 24 2016, 12:10 PM
  • Only enable virtual keyboard if no alpha numeric keyboard
  • add a SNI to enable/disable virtual keyboard nevertheless
  • add a Qt 5.6 (enterprise) variant, for easy testing with Qt 5.6
  • show OSD on enable/disable
graesslin updated this revision to Diff 3988.May 25 2016, 10:23 AM

Bind enabled to SeatInterface::hasKeyboard instead of going through libinput

sebas accepted this revision.May 25 2016, 1:13 PM
sebas added a reviewer: sebas.
sebas added a subscriber: sebas.

looks good to me

plugins/qpa/integration.cpp
46

cross fingers?

tests/inputmethodstest.qml
83

DateTime and Terminal missing?

virtualkeyboard.cpp
56

too late

This revision is now accepted and ready to land.May 25 2016, 1:13 PM
graesslin marked an inline comment as done.May 25 2016, 1:44 PM
graesslin added inline comments.
plugins/qpa/integration.cpp
46

sorry, but I don't get this comment

tests/inputmethodstest.qml
83

Good catch, but no. Those two are not available in Qt's API.

xuetianweng added inline comments.
main_wayland.cpp
449

Don't do this. Otherwise qtvirtualkeyboard will be the only usable input method for Qt.

IMHO for wayland there should be a wayland specific im module that talk to input method via wl_text.

And X11 app should use a different QT_IM_MODULE.

FYI: https://fcitx-im.org/wiki/Input_method_related_environment_variables

graesslin added inline comments.May 30 2016, 5:58 AM
main_wayland.cpp
449

Don't do this. Otherwise qtvirtualkeyboard will be the only usable input method for Qt.

That's totally fine in this case. It only affects KWin and KWin doesn't have any text input fields.

IMHO for wayland there should be a wayland specific im module that talk to input method via wl_text.

QtWayland uses wl_text by default if QT_IM_MODULE is not specified. I think that's exactly what you want.

And X11 app should use a different QT_IM_MODULE.

Look at the file name, it's main_wayland.cpp ;-) Doesn't affect X11 at all.

xuetianweng added inline comments.May 30 2016, 10:57 PM
main_wayland.cpp
449

Specifically, I mean X11 app under Wayland. Since kwin_wayland will start the session I wonder if it will be inherit by the whole desktop session.

graesslin added inline comments.May 31 2016, 6:36 AM
main_wayland.cpp
449

I don't understand the concern. The QT_IM_MODULE env variable set here in the code only affects KWin. It is not passed to any other process.

Setting QT_IM_MODULE env variables will still overwrite everything - except in KWin where the variable is pointless. So nothing changes except by default KWin can now offer a virtual keyboard.

xuetianweng added inline comments.May 31 2016, 7:17 PM
main_wayland.cpp
449

Ah, ok, I misunderstood that this will inherit by session since I thought kwin start the script exit-with-session.

But then I still have one minor concern, for any window that actually inside kwin (e.g. right click on title bar -> window specific settings), the input method will be forced to qtvirtualkeyboard. Though I know input method is not commonly being used there, but I don't think that's expected behavior for input method user.

broulik added inline comments.May 31 2016, 7:36 PM
main_wayland.cpp
449

That dialog is a separate binary kwin_rules_dialog. Except for the virtual keyboard and wayland debug console I don't think there are any user-facing kwin-internal windows (that are real windows, not counting stuff like close buttons on present windows and so on)

graesslin added inline comments.Jun 1 2016, 7:35 AM
main_wayland.cpp
449

It's as Kai-Uwe says: KWin has no own windows. Everything are external programs launched by KWin with a cleaned up environment.

The only input field where KWin accepts input is the dialog for setting a shortcut for a window. As KGlobalAccel doesn't support input methods it's not a problem either.

This revision was automatically updated to reflect the committed changes.