Implement wl_text_input and zwp_text_input_v2 interfaces
ClosedPublic

Authored by graesslin on May 18 2016, 3:36 PM.

Details

Summary

This change introduces support for text input. Text input allows to
compose text on the server (e.g. through a virtual keyboard) and sent
the composed text to the client.

There are multiple interfaces for text input. QtWayland 5.6 uses
wl_text_input, QtWayland 5.7 uses zwp_text_input_v2.

wl_text_input is from pre Wayland-Protocols times and considered as
UnstableV0 in this implementation. The other interface is UnstableV2.
Unfortunately the V2 variant is not yet part of Wayland-Protocols, but
used in Qt.

The implementation hides the different interfaces as good as possible.
The general idea is the same, the differences are rather minor.

This means changes to how interfaces are wrapped normally. On client
side in the Registry a manager is factored which represent either of
the two interfaces. Similar on the server side Display's factory method
takes an argument to decide which interface should be factored. This
way a user of the library can expose both interfaces and thus be
compatible with Qt 5.6 and Qt 5.7 onwards.

Diff Detail

Repository
R127 KWayland
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 3860.May 18 2016, 3:36 PM
graesslin retitled this revision from to Implement wl_text_input and zwp_text_input_v2 interfaces.
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 18 2016, 3:36 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript

Sorry for the large review. The fact that it supports two interfaces made it rather complex.

When reviewing please check whether the exposed methods sound good, are well documented, etc. Please also verify whether the implementation actually matches what is described in the two xml protocols.

graesslin updated this revision to Diff 3872.May 19 2016, 6:06 AM

More documentation

graesslin updated this revision to Diff 3873.May 19 2016, 6:19 AM

Some method renaming:

  • on client: activate -> enable, deactivate -> disable
  • on server: made setters not sound like getters
broulik added inline comments.
src/server/textinput_interface.h
159

MultiLine? Makes it consistent with Qt API

graesslin marked an inline comment as done.May 20 2016, 5:42 AM
graesslin updated this revision to Diff 3899.May 20 2016, 5:42 AM

Multiline -> MultiLine

graesslin updated this revision to Diff 3903.May 20 2016, 8:45 AM

The SeatInterface now exposes TextInputInterface in similar ways to the other
input devices. That is there is a setFocusedTextInputSurface and the focused
TextInputInterface is exposed through focusedTextInput().

This means that text input is no longer strictly bound to keyboard focus, it
can be set indipendently. Though setFocusedKeyboardSurface updates the
focusedTextInputSurface if the SeatInterface has keyboard support. This is
a requirement in the v2 xml description.

In addition TextInputInterface has a new method isEnabled() -> bool to check
whether it's currently enabled and emits a signal if this changes. This can
be used by the compositor to decide whether it should send text input through
the interface.

graesslin updated this revision to Diff 3990.May 25 2016, 11:19 AM

include QVector in one header to make it compile with Qt 5.6

sebas accepted this revision.May 25 2016, 12:20 PM
sebas added a reviewer: sebas.
sebas added a subscriber: sebas.

a few niggles, but generally, look good to me.

src/client/outputmanagement.cpp
94 ↗(On Diff #3990)

Seems unrelated (not a problem, unless I'm missing something)

src/client/plasmawindowmanagement.cpp
128 ↗(On Diff #3990)

Seems unrelated (not a problem, unless I'm missing something)

357 ↗(On Diff #3990)

Seems unrelated (not a problem, unless I'm missing something)

src/client/plasmawindowmodel.cpp
60 ↗(On Diff #3990)

the changes in this file are unrelated, but do make sense (I don't care much if you push them together)

src/client/protocols/plasma-window-management.xml
20 ↗(On Diff #3990)

changes here are also unrelated?

src/client/protocols/text-input-unstable-v2.xml
154

"a URL"

src/client/registry.h
451

A small note about the protocol (i.e. which version of the interface should be used) probably wouldn't hurt (as the two creators may end up being confusing). This is a bit high-level though, for APIDOCs, but still raises this question.

src/client/textinput.h
50

move this above the previous paragraph, more logical order (general purpose, then implementation caveats)

82

Does this actually show the panel then? (Could be more clear what's expected here, what's the relationship between enable/disable and show*/hide*)

158

I think LowerCase, UpperCase and TitleCase feel more in line with the other fields here?

src/server/textinput_interface.h
135

LowerCase, UpperCase, etc. as well?

217

DateTime?

This revision is now accepted and ready to land.May 25 2016, 12:20 PM
graesslin updated this revision to Diff 3995.May 25 2016, 12:27 PM
graesslin edited edge metadata.

Upload new version against master

graesslin marked an inline comment as done.May 25 2016, 12:33 PM
graesslin added inline comments.
src/client/protocols/text-input-unstable-v2.xml
154

this is an XML file I imported from 3rd party (QtWayland). Not going to touch it.

src/client/registry.h
451

Isn't the explanation in createTextInputManager sufficient? After all it says one should prefer createTextInputManager

src/client/textinput.h
82

honest answer: I don't know.

graesslin marked 3 inline comments as done.May 25 2016, 12:37 PM
graesslin updated this revision to Diff 3997.May 25 2016, 12:38 PM

Addresses sebas review comments:

  • fixed documentation in Registry
  • Reordered documentation in TextInput
  • Changed enum values to CamelCase
This revision was automatically updated to reflect the committed changes.