<div dir="ltr">There is a reference implementation of this version of the protocol in QtWayland <span style="line-height:1.5"><a href="https://codereview.qt-project.org/#/c/153711/">https://codereview.qt-project.org/#/c/153711/</a> where the text-input protocol is used to proxy the Qt input method of Qt Wayland clients to the </span>Qt input method on <span style="line-height:1.5">compositor side.</span><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">One can then use for example the qtvirtualkeyboard (which plugs in the Qt input method system) in the Qt compositor and use that to input text in all clients.</span></div><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">Jan Arne Petersen</span></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 14, 2016 at 12:58 PM Jan Arne Petersen <<a href="mailto:janarne@gmail.com">janarne@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There were some shortcomings in the first version of the protocol which<br>
makes it not really useful in real world applications. It is not really<br>
possible to fix them in a compatible way so introduce a new v2 of the<br>
protocol.<br>
<br>
Fixes some shortcomings of the first version:<br>
<br>
* Use only one wp_text_input per wl_seat (client side should be<br>
handled by client toolkit)<br>
* Allow focus tracking without wl_keyboard present<br>
* Improve update state handling and better define state handling<br>
<br>
Signed-off-by: Jan Arne Petersen <<a href="mailto:janarne@gmail.com" target="_blank">janarne@gmail.com</a>><br>
---<br>
Chnages to v4:<br>
* Improved descriptions<br>
* Remove invoke_action request<br>
<br>
unstable/text-input/text-input-unstable-v2.xml | 484 +++++++++++++++++++++++++<br>
1 file changed, 484 insertions(+)<br>
create mode 100644 unstable/text-input/text-input-unstable-v2.xml<br>
<br>
diff --git a/unstable/text-input/text-input-unstable-v2.xml b/unstable/text-input/text-input-unstable-v2.xml<br>
new file mode 100644<br>
index 0000000..1e64c4b<br>
--- /dev/null<br>
+++ b/unstable/text-input/text-input-unstable-v2.xml<br>
@@ -0,0 +1,484 @@<br>
+<?xml version="1.0" encoding="UTF-8"?><br>
+<br>
+<protocol name="text_input_unstable_v2"><br>
+ <copyright><br>
+ Copyright © 2012, 2013 Intel Corporation<br>
+ Copyright © 2015, 2016 Jan Arne Petersen<br>
+<br>
+ Permission to use, copy, modify, distribute, and sell this<br>
+ software and its documentation for any purpose is hereby granted<br>
+ without fee, provided that the above copyright notice appear in<br>
+ all copies and that both that copyright notice and this permission<br>
+ notice appear in supporting documentation, and that the name of<br>
+ the copyright holders not be used in advertising or publicity<br>
+ pertaining to distribution of the software without specific,<br>
+ written prior permission. The copyright holders make no<br>
+ representations about the suitability of this software for any<br>
+ purpose. It is provided "as is" without express or implied<br>
+ warranty.<br>
+<br>
+ THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS<br>
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND<br>
+ FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY<br>
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES<br>
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN<br>
+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,<br>
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF<br>
+ THIS SOFTWARE.<br>
+ </copyright><br>
+<br>
+ <interface name="zwp_text_input_v2" version="1"><br>
+ <description summary="text input"><br>
+ The zwp_text_input_v2 interface represents text input and input methods<br>
+ associated with a seat. It provides enter/leave events to follow the<br>
+ text input focus for a seat.<br>
+<br>
+ Requests are used to enable/disable the text-input object and set<br>
+ state information like surrounding and selected text or the content type.<br>
+ The information about the entered text is sent to the text-input object<br>
+ via the pre-edit and commit events. Using this interface removes the need<br>
+ for applications to directly process hardware key events and compose text<br>
+ out of them.<br>
+<br>
+ Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices<br>
+ have to always point to the first byte of an UTF-8 encoded code point.<br>
+ Lengths are not allowed to contain just a part of an UTF-8 encoded code<br>
+ point.<br>
+<br>
+ State is sent by the state requests (set_surrounding_text,<br>
+ set_content_type, set_cursor_rectangle and set_preferred_language) and<br>
+ an update_state request. After an enter or an input_method_change event<br>
+ all state information is invalidated and needs to be resent from the<br>
+ client. A reset or entering a new widget on client side also<br>
+ invalidates all current state information.<br>
+<br>
+ Serials are used to synchronize the state between the client and<br>
+ an input method. New serials are sent by the text input in the<br>
+ update_state request and are used by the input method to indicate<br>
+ the known text input state in events like preedit_string, commit_string,<br>
+ and keysym. The text input can then ignore events from the input method<br>
+ which are based on an outdated state (for example after a reset).<br>
+ </description><br>
+<br>
+ <request name="destroy" type="destructor"><br>
+ <description summary="Destroy the wp_text_input"><br>
+ Destroy the wp_text_input object. Also disables all surfaces enabled<br>
+ through this wp_text_input object<br>
+ </description><br>
+ </request><br>
+<br>
+ <request name="enable"><br>
+ <description summary="enable text input for surface"><br>
+ Enable text input in a surface (usually when a text entry inside of it<br>
+ has focus).<br>
+<br>
+ This can be called before or after a surface gets text (or keyboard)<br>
+ focus via the enter event. Text input to a surface is only active<br>
+ when it has the current text (or keyboard) focus and is enabled.<br>
+ </description><br>
+ <arg name="surface" type="object" interface="wl_surface"/><br>
+ </request><br>
+<br>
+ <request name="disable"><br>
+ <description summary="disable text input for surface"><br>
+ Disable text input in a surface (typically when there is no focus on any<br>
+ text entry inside the surface).<br>
+ </description><br>
+ <arg name="surface" type="object" interface="wl_surface"/><br>
+ </request><br>
+<br>
+ <request name="show_input_panel"><br>
+ <description summary="show input panels"><br>
+ Requests input panels (virtual keyboard) to show.<br>
+<br>
+ This should be used for example to show a virtual keyboard again<br>
+ (with a tap) after it was closed by pressing on a close button on the<br>
+ keyboard.<br>
+ </description><br>
+ </request><br>
+<br>
+ <request name="hide_input_panel"><br>
+ <description summary="hide input panels"><br>
+ Requests input panels (virtual keyboard) to hide.<br>
+ </description><br>
+ </request><br>
+<br>
+ <request name="set_surrounding_text"><br>
+ <description summary="sets the surrounding text"><br>
+ Sets the plain surrounding text around the input position. Text is<br>
+ UTF-8 encoded. Cursor is the byte offset within the surrounding text.<br>
+ Anchor is the byte offset of the selection anchor within the<br>
+ surrounding text. If there is no selected text, anchor is the same as<br>
+ cursor.<br>
+<br>
+ Make sure to always send some text before and after the cursor<br>
+ except when the cursor is at the beginning or end of text.<br>
+<br>
+ When there was a configure_surrounding_text event take the<br>
+ before_cursor and after_cursor arguments into account for picking how<br>
+ much surrounding text to send.<br>
+<br>
+ There is a maximum length of wayland messages so text can not be<br>
+ longer than 4000 bytes.<br>
+ </description><br>
+ <arg name="text" type="string"/><br>
+ <arg name="cursor" type="int"/><br>
+ <arg name="anchor" type="int"/><br>
+ </request><br>
+<br>
+ <enum name="content_hint" bitfield="true"><br>
+ <description summary="content hint"><br>
+ Content hint is a bitmask to allow to modify the behavior of the text<br>
+ input.<br>
+ </description><br>
+ <entry name="none" value="0x0" summary="no special behaviour"/><br>
+ <entry name="auto_completion" value="0x1" summary="suggest word completions"/><br>
+ <entry name="auto_correction" value="0x2" summary="suggest word corrections"/><br>
+ <entry name="auto_capitalization" value="0x4" summary="switch to uppercase letters at the start of a sentence"/><br>
+ <entry name="lowercase" value="0x8" summary="prefer lowercase letters"/><br>
+ <entry name="uppercase" value="0x10" summary="prefer uppercase letters"/><br>
+ <entry name="titlecase" value="0x20" summary="prefer casing for titles and headings (can be language dependent)"/><br>
+ <entry name="hidden_text" value="0x40" summary="characters should be hidden"/><br>
+ <entry name="sensitive_data" value="0x80" summary="typed text should not be stored"/><br>
+ <entry name="latin" value="0x100" summary="just latin characters should be entered"/><br>
+ <entry name="multiline" value="0x200" summary="the text input is multiline"/><br>
+ </enum><br>
+<br>
+ <enum name="content_purpose"><br>
+ <description summary="content purpose"><br>
+ The content purpose allows to specify the primary purpose of a text<br>
+ input.<br>
+<br>
+ This allows an input method to show special purpose input panels with<br>
+ extra characters or to disallow some characters.<br>
+ </description><br>
+ <entry name="normal" value="0" summary="default input, allowing all characters"/><br>
+ <entry name="alpha" value="1" summary="allow only alphabetic characters"/><br>
+ <entry name="digits" value="2" summary="allow only digits"/><br>
+ <entry name="number" value="3" summary="input a number (including decimal separator and sign)"/><br>
+ <entry name="phone" value="4" summary="input a phone number"/><br>
+ <entry name="url" value="5" summary="input an URL"/><br>
+ <entry name="email" value="6" summary="input an email address"/><br>
+ <entry name="name" value="7" summary="input a name of a person"/><br>
+ <entry name="password" value="8" summary="input a password (combine with password or sensitive_data hint)"/><br>
+ <entry name="date" value="9" summary="input a date"/><br>
+ <entry name="time" value="10" summary="input a time"/><br>
+ <entry name="datetime" value="11" summary="input a date and time"/><br>
+ <entry name="terminal" value="12" summary="input for a terminal"/><br>
+ </enum><br>
+<br>
+ <request name="set_content_type"><br>
+ <description summary="set content purpose and hint"><br>
+ Sets the content purpose and content hint. While the purpose is the<br>
+ basic purpose of an input field, the hint flags allow to modify some<br>
+ of the behavior.<br>
+<br>
+ When no content type is explicitly set, a normal content purpose with<br>
+ none hint should be assumed.<br>
+ </description><br>
+ <arg name="hint" type="uint" enum="content_hint"/><br>
+ <arg name="purpose" type="uint" enum="content_purpose"/><br>
+ </request><br>
+<br>
+ <request name="set_cursor_rectangle"><br>
+ <description summary="set cursor position"><br>
+ Sets the cursor outline as a x, y, width, height rectangle in surface<br>
+ local coordinates.<br>
+<br>
+ Allows the compositor to put a window with word suggestions near the<br>
+ cursor.<br>
+ </description><br>
+ <arg name="x" type="int"/><br>
+ <arg name="y" type="int"/><br>
+ <arg name="width" type="int"/><br>
+ <arg name="height" type="int"/><br>
+ </request><br>
+<br>
+ <request name="set_preferred_language"><br>
+ <description summary="sets preferred language"><br>
+ Sets a specific language. This allows for example a virtual keyboard to<br>
+ show a language specific layout. The "language" argument is a RFC-3066<br>
+ format language tag.<br>
+<br>
+ It could be used for example in a word processor to indicate language of<br>
+ currently edited document or in an instant message application which<br>
+ tracks languages of contacts.<br>
+ </description><br>
+ <arg name="language" type="string"/><br>
+ </request><br>
+<br>
+ <enum name="update_state"><br>
+ <description summary="update_state flags"><br>
+ Defines the reason for sending an updated state.<br>
+ </description><br>
+ <entry name="change" value="0" summary="updated state because it changed"/><br>
+ <entry name="full" value="1" summary="full state after enter or input_method_changed event"/><br>
+ <entry name="reset" value="2" summary="full state after reset"/><br>
+ <entry name="enter" value="3" summary="full state after switching focus to a different widget on client side"/><br>
+ </enum><br>
+<br>
+ <request name="update_state"><br>
+ <description summary="update state"><br>
+ Allows to atomically send state updates from client.<br>
+<br>
+ This request should follow after a batch of state updating requests<br>
+ like set_surrounding_text, set_content_type, set_cursor_rectangle and<br>
+ set_preferred_language.<br>
+<br>
+ The flags field indicates why an updated state is sent to the input<br>
+ method.<br>
+<br>
+ Reset should be used by an editor widget after the text was changed<br>
+ outside of the normal input method flow.<br>
+<br>
+ For "change" it is enough to send the changed state, else the full<br>
+ state should be send.<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="used to identify the known state"/><br>
+ <arg name="flags" type="uint" enum="update_state"/><br>
+ </request><br>
+<br>
+ <event name="enter"><br>
+ <description summary="enter event"><br>
+ Notification that this seat's text-input focus is on a certain surface.<br>
+<br>
+ When the seat has the keyboard capability the text-input focus follows<br>
+ the keyboard focus.<br>
+ </description><br>
+ <arg name="serial" type="uint"/><br>
+ <arg name="surface" type="object" interface="wl_surface"/><br>
+ </event><br>
+<br>
+ <event name="leave"><br>
+ <description summary="leave event"><br>
+ Notification that this seat's text-input focus is no longer on<br>
+ a certain surface.<br>
+<br>
+ The leave notification is sent before the enter notification<br>
+ for the new focus.<br>
+<br>
+ When the seat has the keyboard capabillity the text-input focus follows<br>
+ the keyboard focus.<br>
+ </description><br>
+ <arg name="serial" type="uint"/><br>
+ <arg name="surface" type="object" interface="wl_surface"/><br>
+ </event><br>
+<br>
+ <enum name="input_panel_visibility"><br>
+ <entry name="hidden" value="0"<br>
+ summary="the input panel (virtual keyboard) is hidden"/><br>
+ <entry name="visible" value="1"<br>
+ summary="the input panel (virtual keyboard) is visible"/><br>
+ </enum><br>
+<br>
+ <event name="input_panel_state"><br>
+ <description summary="state of the input panel"><br>
+ Notification that the visibility of the input panel (virtual keyboard)<br>
+ changed.<br>
+<br>
+ The rectangle x, y, width, height defines the area overlapped by the<br>
+ input panel (virtual keyboard) on the surface having the text<br>
+ focus in surface local coordinates.<br>
+<br>
+ That can be used to make sure widgets are visible and not covered by<br>
+ a virtual keyboard.<br>
+ </description><br>
+ <arg name="state" type="uint" enum="input_panel_visibility"/><br>
+ <arg name="x" type="int"/><br>
+ <arg name="y" type="int"/><br>
+ <arg name="width" type="int"/><br>
+ <arg name="height" type="int"/><br>
+ </event><br>
+<br>
+ <event name="preedit_string"><br>
+ <description summary="pre-edit"><br>
+ Notify when a new composing text (pre-edit) should be set around the<br>
+ current cursor position. Any previously set composing text should<br>
+ be removed.<br>
+<br>
+ The commit text can be used to replace the composing text in some cases<br>
+ (for example when losing focus).<br>
+<br>
+ The text input should also handle all preedit_style and preedit_cursor<br>
+ events occurring directly before preedit_string.<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="serial of the latest known text input state"/><br>
+ <arg name="text" type="string"/><br>
+ <arg name="commit" type="string"/><br>
+ </event><br>
+<br>
+ <enum name="preedit_style"><br>
+ <entry name="default" value="0" summary="default style for composing text"/><br>
+ <entry name="none" value="1" summary="composing text should be shown the same as non-composing text"/><br>
+ <entry name="active" value="2" summary="composing text might be bold"/><br>
+ <entry name="inactive" value="3" summary="composing text might be cursive"/><br>
+ <entry name="highlight" value="4" summary="composing text might have a different background color"/><br>
+ <entry name="underline" value="5" summary="composing text might be underlined"/><br>
+ <entry name="selection" value="6" summary="composing text should be shown the same as selected text"/><br>
+ <entry name="incorrect" value="7" summary="composing text might be underlined with a red wavy line"/><br>
+ </enum><br>
+<br>
+ <event name="preedit_styling"><br>
+ <description summary="pre-edit styling"><br>
+ Sets styling information on composing text. The style is applied for<br>
+ length bytes from index relative to the beginning of the composing<br>
+ text (as byte offset). Multiple styles can be applied to a composing<br>
+ text by sending multiple preedit_styling events.<br>
+<br>
+ This event is handled as part of a following preedit_string event.<br>
+ </description><br>
+ <arg name="index" type="uint"/><br>
+ <arg name="length" type="uint"/><br>
+ <arg name="style" type="uint" enum="preedit_style"/><br>
+ </event><br>
+<br>
+ <event name="preedit_cursor"><br>
+ <description summary="pre-edit cursor"><br>
+ Sets the cursor position inside the composing text (as byte<br>
+ offset) relative to the start of the composing text. When index is a<br>
+ negative number no cursor is shown.<br>
+<br>
+ When no preedit_cursor event is sent the cursor will be at the end of<br>
+ the composing text by default.<br>
+<br>
+ This event is handled as part of a following preedit_string event.<br>
+ </description><br>
+ <arg name="index" type="int"/><br>
+ </event><br>
+<br>
+ <event name="commit_string"><br>
+ <description summary="commit"><br>
+ Notify when text should be inserted into the editor widget. The text to<br>
+ commit could be either just a single character after a key press or the<br>
+ result of some composing (pre-edit). It could be also an empty text<br>
+ when some text should be removed (see delete_surrounding_text) or when<br>
+ the input cursor should be moved (see cursor_position).<br>
+<br>
+ Any previously set composing text should be removed.<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="serial of the latest known text input state"/><br>
+ <arg name="text" type="string"/><br>
+ </event><br>
+<br>
+ <event name="cursor_position"><br>
+ <description summary="set cursor to new position"><br>
+ Notify when the cursor or anchor position should be modified.<br>
+<br>
+ This event should be handled as part of a following commit_string<br>
+ event.<br>
+<br>
+ The text between anchor and index should be selected.<br>
+ </description><br>
+ <arg name="index" type="int" summary="position of cursor"/><br>
+ <arg name="anchor" type="int" summary="position of selection anchor"/><br>
+ </event><br>
+<br>
+ <event name="delete_surrounding_text"><br>
+ <description summary="delete surrounding text"><br>
+ Notify when the text around the current cursor position should be<br>
+ deleted.<br>
+<br>
+ Index is relative to the current cursor (in bytes).<br>
+ Length is the length of deleted text (in bytes).<br>
+<br>
+ This event should be handled as part of a following commit_string<br>
+ or preedit_string event.<br>
+ </description><br>
+ <arg name="index" type="int"/><br>
+ <arg name="length" type="uint"/><br>
+ </event><br>
+<br>
+ <event name="modifiers_map"><br>
+ <description summary="modifiers map"><br>
+ Transfer an array of 0-terminated modifiers names. The position in<br>
+ the array is the index of the modifier as used in the modifiers<br>
+ bitmask in the keysym event.<br>
+ </description><br>
+ <arg name="map" type="array"/><br>
+ </event><br>
+<br>
+ <event name="keysym"><br>
+ <description summary="keysym"><br>
+ Notify when a key event was sent. Key events should not be used<br>
+ for normal text input operations, which should be done with<br>
+ commit_string, delete_surrounding_text, etc. The key event follows<br>
+ the wl_keyboard key event convention. Sym is a XKB keysym, state a<br>
+ wl_keyboard key_state. Modifiers are a mask for effective modifiers<br>
+ (where the modifier indices are set by the modifiers_map event)<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="serial of the latest known text input state"/><br>
+ <arg name="time" type="uint"/><br>
+ <arg name="sym" type="uint"/><br>
+ <arg name="state" type="uint"/><br>
+ <arg name="modifiers" type="uint"/><br>
+ </event><br>
+<br>
+ <event name="language"><br>
+ <description summary="language"><br>
+ Sets the language of the input text. The "language" argument is a RFC-3066<br>
+ format language tag.<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="serial of the latest known text input state"/><br>
+ <arg name="language" type="string"/><br>
+ </event><br>
+<br>
+ <enum name="text_direction"><br>
+ <entry name="auto" value="0" summary="automatic text direction based on text and language"/><br>
+ <entry name="ltr" value="1" summary="left-to-right"/><br>
+ <entry name="rtl" value="2" summary="right-to-left"/><br>
+ </enum><br>
+<br>
+ <event name="text_direction"><br>
+ <description summary="text direction"><br>
+ Sets the text direction of input text.<br>
+<br>
+ It is mainly needed for showing input cursor on correct side of the<br>
+ editor when there is no input yet done and making sure neutral<br>
+ direction text is laid out properly.<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="serial of the latest known text input state"/><br>
+ <arg name="direction" type="uint" enum="text_direction"/><br>
+ </event><br>
+<br>
+ <event name="configure_surrounding_text"><br>
+ <description summary="configure amount of surrounding text to be sent"><br>
+ Configure what amount of surrounding text is expected by the<br>
+ input method. The surrounding text will be sent in the<br>
+ set_surrounding_text request on the following state information updates.<br>
+ </description><br>
+ <arg name="before_cursor" type="int"/><br>
+ <arg name="after_cursor" type="int"/><br>
+ </event><br>
+<br>
+ <event name="input_method_changed"><br>
+ <description summary="Notifies about a changed input method"><br>
+ The input method changed on compositor side, which invalidates all<br>
+ current state information. New state information should be sent from<br>
+ the client via state requests (set_surrounding_text,<br>
+ set_content_hint, ...) and update_state.<br>
+ </description><br>
+ <arg name="serial" type="uint" summary="serial to synchronize state information"/><br>
+ <arg name="flags" type="uint" summary="currently unused"/><br>
+ </event><br>
+ </interface><br>
+<br>
+ <interface name="zwp_text_input_manager_v2" version="1"><br>
+ <description summary="text input manager"><br>
+ A factory for text-input objects. This object is a global singleton.<br>
+ </description><br>
+<br>
+ <request name="destroy" type="destructor"><br>
+ <description summary="Destroy the wp_text_input_manager"><br>
+ Destroy the wp_text_input_manager object.<br>
+ </description><br>
+ </request><br>
+<br>
+ <request name="get_text_input"><br>
+ <description summary="create a new text input object"><br>
+ Creates a new text-input object for a given seat.<br>
+ </description><br>
+ <arg name="id" type="new_id" interface="zwp_text_input_v2"/><br>
+ <arg name="seat" type="object" interface="wl_seat"/><br>
+ </request><br>
+ </interface><br>
+</protocol><br>
--<br>
2.5.0<br>
<br>
</blockquote></div>