| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | |
| 3 | <protocol name="text_input_unstable_v3"> |
| 4 | <copyright> |
| 5 | Copyright © 2012, 2013 Intel Corporation |
| 6 | Copyright © 2015, 2016 Jan Arne Petersen |
| 7 | Copyright © 2017, 2018 Red Hat, Inc. |
| 8 | Copyright © 2018 Purism SPC |
| 9 | |
| 10 | Permission to use, copy, modify, distribute, and sell this |
| 11 | software and its documentation for any purpose is hereby granted |
| 12 | without fee, provided that the above copyright notice appear in |
| 13 | all copies and that both that copyright notice and this permission |
| 14 | notice appear in supporting documentation, and that the name of |
| 15 | the copyright holders not be used in advertising or publicity |
| 16 | pertaining to distribution of the software without specific, |
| 17 | written prior permission. The copyright holders make no |
| 18 | representations about the suitability of this software for any |
| 19 | purpose. It is provided "as is" without express or implied |
| 20 | warranty. |
| 21 | |
| 22 | THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 23 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 24 | FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 25 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 26 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
| 27 | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
| 28 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
| 29 | THIS SOFTWARE. |
| 30 | </copyright> |
| 31 | |
| 32 | <description summary="Protocol for composing text"> |
| 33 | This protocol allows compositors to act as input methods and to send text |
| 34 | to applications. A text input object is used to manage state of what are |
| 35 | typically text entry fields in the application. |
| 36 | |
| 37 | This document adheres to the RFC 2119 when using words like "must", |
| 38 | "should", "may", etc. |
| 39 | |
| 40 | Warning! The protocol described in this file is experimental and |
| 41 | backward incompatible changes may be made. Backward compatible changes |
| 42 | may be added together with the corresponding interface version bump. |
| 43 | Backward incompatible changes are done by bumping the version number in |
| 44 | the protocol and interface names and resetting the interface version. |
| 45 | Once the protocol is to be declared stable, the 'z' prefix and the |
| 46 | version number in the protocol and interface names are removed and the |
| 47 | interface version number is reset. |
| 48 | </description> |
| 49 | |
| 50 | <interface name="zwp_text_input_v3" version="1"> |
| 51 | <description summary="text input"> |
| 52 | The zwp_text_input_v3 interface represents text input and input methods |
| 53 | associated with a seat. It provides enter/leave events to follow the |
| 54 | text input focus for a seat. |
| 55 | |
| 56 | Requests are used to enable/disable the text-input object and set |
| 57 | state information like surrounding and selected text or the content type. |
| 58 | The information about the entered text is sent to the text-input object |
| 59 | via the preedit_string and commit_string events. |
| 60 | |
| 61 | Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices |
| 62 | must not point to middle bytes inside a code point: they must either |
| 63 | point to the first byte of a code point or to the end of the buffer. |
| 64 | Lengths must be measured between two valid indices. |
| 65 | |
| 66 | Focus moving throughout surfaces will result in the emission of |
| 67 | zwp_text_input_v3.enter and zwp_text_input_v3.leave events. The focused |
| 68 | surface must commit zwp_text_input_v3.enable and |
| 69 | zwp_text_input_v3.disable requests as the keyboard focus moves across |
| 70 | editable and non-editable elements of the UI. Those two requests are not |
| 71 | expected to be paired with each other, the compositor must be able to |
| 72 | handle consecutive series of the same request. |
| 73 | |
| 74 | State is sent by the state requests (set_surrounding_text, |
| 75 | set_content_type and set_cursor_rectangle) and a commit request. After an |
| 76 | enter event or disable request all state information is invalidated and |
| 77 | needs to be resent by the client. |
| 78 | </description> |
| 79 | |
| 80 | <request name="destroy" type="destructor"> |
| 81 | <description summary="Destroy the wp_text_input"> |
| 82 | Destroy the wp_text_input object. Also disables all surfaces enabled |
| 83 | through this wp_text_input object. |
| 84 | </description> |
| 85 | </request> |
| 86 | |
| 87 | <request name="enable"> |
| 88 | <description summary="Request text input to be enabled"> |
| 89 | Requests text input on the surface previously obtained from the enter |
| 90 | event. |
| 91 | |
| 92 | This request must be issued every time the focused text input changes |
| 93 | to a new one, including within the current surface. Use |
| 94 | zwp_text_input_v3.disable when there is no longer any input focus on |
| 95 | the current surface. |
| 96 | |
| 97 | Clients must not enable more than one text input on the single seat |
| 98 | and should disable the current text input before enabling the new one. |
| 99 | Requests to enable a text input when another text input is enabled |
| 100 | on the same seat must be ignored by compositor. |
| 101 | |
| 102 | This request resets all state associated with previous enable, disable, |
| 103 | set_surrounding_text, set_text_change_cause, set_content_type, and |
| 104 | set_cursor_rectangle requests, as well as the state associated with |
| 105 | preedit_string, commit_string, and delete_surrounding_text events. |
| 106 | |
| 107 | The set_surrounding_text, set_content_type and set_cursor_rectangle |
| 108 | requests must follow if the text input supports the necessary |
| 109 | functionality. |
| 110 | |
| 111 | State set with this request is double-buffered. It will get applied on |
| 112 | the next zwp_text_input_v3.commit request, and stay valid until the |
| 113 | next committed enable or disable request. |
| 114 | |
| 115 | The changes must be applied by the compositor after issuing a |
| 116 | zwp_text_input_v3.commit request. |
| 117 | </description> |
| 118 | </request> |
| 119 | |
| 120 | <request name="disable"> |
| 121 | <description summary="Disable text input on a surface"> |
| 122 | Explicitly disable text input on the current surface (typically when |
| 123 | there is no focus on any text entry inside the surface). |
| 124 | |
| 125 | State set with this request is double-buffered. It will get applied on |
| 126 | the next zwp_text_input_v3.commit request. |
| 127 | </description> |
| 128 | </request> |
| 129 | |
| 130 | <request name="set_surrounding_text"> |
| 131 | <description summary="sets the surrounding text"> |
| 132 | Sets the surrounding plain text around the input, excluding the preedit |
| 133 | text. |
| 134 | |
| 135 | The client should notify the compositor of any changes in any of the |
| 136 | values carried with this request, including changes caused by handling |
| 137 | incoming text-input events as well as changes caused by other |
| 138 | mechanisms like keyboard typing. |
| 139 | |
| 140 | If the client is unaware of the text around the cursor, it should not |
| 141 | issue this request, to signify lack of support to the compositor. |
| 142 | |
| 143 | Text is UTF-8 encoded, and should include the cursor position, the |
| 144 | complete selection and additional characters before and after them. |
| 145 | There is a maximum length of wayland messages, so text can not be |
| 146 | longer than 4000 bytes. |
| 147 | |
| 148 | Cursor is the byte offset of the cursor within text buffer. |
| 149 | |
| 150 | Anchor is the byte offset of the selection anchor within text buffer. |
| 151 | If there is no selected text, anchor is the same as cursor. |
| 152 | |
| 153 | If any preedit text is present, it is replaced with a cursor for the |
| 154 | purpose of this event. |
| 155 | |
| 156 | Values set with this request are double-buffered. They will get applied |
| 157 | on the next zwp_text_input_v3.commit request, and stay valid until the |
| 158 | next committed enable or disable request. |
| 159 | |
| 160 | The initial state for affected fields is empty, meaning that the text |
| 161 | input does not support sending surrounding text. If the empty values |
| 162 | get applied, subsequent attempts to change them may have no effect. |
| 163 | </description> |
| 164 | <arg name="text" type="string"/> |
| 165 | <arg name="cursor" type="int"/> |
| 166 | <arg name="anchor" type="int"/> |
| 167 | </request> |
| 168 | |
| 169 | <enum name="change_cause"> |
| 170 | <description summary="text change reason"> |
| 171 | Reason for the change of surrounding text or cursor posision. |
| 172 | </description> |
| 173 | <entry name="input_method" value="0" summary="input method caused the change"/> |
| 174 | <entry name="other" value="1" summary="something else than the input method caused the change"/> |
| 175 | </enum> |
| 176 | |
| 177 | <request name="set_text_change_cause"> |
| 178 | <description summary="indicates the cause of surrounding text change"> |
| 179 | Tells the compositor why the text surrounding the cursor changed. |
| 180 | |
| 181 | Whenever the client detects an external change in text, cursor, or |
| 182 | anchor posision, it must issue this request to the compositor. This |
| 183 | request is intended to give the input method a chance to update the |
| 184 | preedit text in an appropriate way, e.g. by removing it when the user |
| 185 | starts typing with a keyboard. |
| 186 | |
| 187 | cause describes the source of the change. |
| 188 | |
| 189 | The value set with this request is double-buffered. It must be applied |
| 190 | and reset to initial at the next zwp_text_input_v3.commit request. |
| 191 | |
| 192 | The initial value of cause is input_method. |
| 193 | </description> |
| 194 | <arg name="cause" type="uint" enum="change_cause"/> |
| 195 | </request> |
| 196 | |
| 197 | <enum name="content_hint" bitfield="true"> |
| 198 | <description summary="content hint"> |
| 199 | Content hint is a bitmask to allow to modify the behavior of the text |
| 200 | input. |
| 201 | </description> |
| 202 | <entry name="none" value="0x0" summary="no special behavior"/> |
| 203 | <entry name="completion" value="0x1" summary="suggest word completions"/> |
| 204 | <entry name="spellcheck" value="0x2" summary="suggest word corrections"/> |
| 205 | <entry name="auto_capitalization" value="0x4" summary="switch to uppercase letters at the start of a sentence"/> |
| 206 | <entry name="lowercase" value="0x8" summary="prefer lowercase letters"/> |
| 207 | <entry name="uppercase" value="0x10" summary="prefer uppercase letters"/> |
| 208 | <entry name="titlecase" value="0x20" summary="prefer casing for titles and headings (can be language dependent)"/> |
| 209 | <entry name="hidden_text" value="0x40" summary="characters should be hidden"/> |
| 210 | <entry name="sensitive_data" value="0x80" summary="typed text should not be stored"/> |
| 211 | <entry name="latin" value="0x100" summary="just Latin characters should be entered"/> |
| 212 | <entry name="multiline" value="0x200" summary="the text input is multiline"/> |
| 213 | </enum> |
| 214 | |
| 215 | <enum name="content_purpose"> |
| 216 | <description summary="content purpose"> |
| 217 | The content purpose allows to specify the primary purpose of a text |
| 218 | input. |
| 219 | |
| 220 | This allows an input method to show special purpose input panels with |
| 221 | extra characters or to disallow some characters. |
| 222 | </description> |
| 223 | <entry name="normal" value="0" summary="default input, allowing all characters"/> |
| 224 | <entry name="alpha" value="1" summary="allow only alphabetic characters"/> |
| 225 | <entry name="digits" value="2" summary="allow only digits"/> |
| 226 | <entry name="number" value="3" summary="input a number (including decimal separator and sign)"/> |
| 227 | <entry name="phone" value="4" summary="input a phone number"/> |
| 228 | <entry name="url" value="5" summary="input an URL"/> |
| 229 | <entry name="email" value="6" summary="input an email address"/> |
| 230 | <entry name="name" value="7" summary="input a name of a person"/> |
| 231 | <entry name="password" value="8" summary="input a password (combine with sensitive_data hint)"/> |
| 232 | <entry name="pin" value="9" summary="input is a numeric password (combine with sensitive_data hint)"/> |
| 233 | <entry name="date" value="10" summary="input a date"/> |
| 234 | <entry name="time" value="11" summary="input a time"/> |
| 235 | <entry name="datetime" value="12" summary="input a date and time"/> |
| 236 | <entry name="terminal" value="13" summary="input for a terminal"/> |
| 237 | </enum> |
| 238 | |
| 239 | <request name="set_content_type"> |
| 240 | <description summary="set content purpose and hint"> |
| 241 | Sets the content purpose and content hint. While the purpose is the |
| 242 | basic purpose of an input field, the hint flags allow to modify some of |
| 243 | the behavior. |
| 244 | |
| 245 | Values set with this request are double-buffered. They will get applied |
| 246 | on the next zwp_text_input_v3.commit request. |
| 247 | Subsequent attempts to update them may have no effect. The values |
| 248 | remain valid until the next committed enable or disable request. |
| 249 | |
| 250 | The initial value for hint is none, and the initial value for purpose |
| 251 | is normal. |
| 252 | </description> |
| 253 | <arg name="hint" type="uint" enum="content_hint"/> |
| 254 | <arg name="purpose" type="uint" enum="content_purpose"/> |
| 255 | </request> |
| 256 | |
| 257 | <request name="set_cursor_rectangle"> |
| 258 | <description summary="set cursor position"> |
| 259 | Marks an area around the cursor as a x, y, width, height rectangle in |
| 260 | surface local coordinates. |
| 261 | |
| 262 | Allows the compositor to put a window with word suggestions near the |
| 263 | cursor, without obstructing the text being input. |
| 264 | |
| 265 | If the client is unaware of the position of edited text, it should not |
| 266 | issue this request, to signify lack of support to the compositor. |
| 267 | |
| 268 | Values set with this request are double-buffered. They will get applied |
| 269 | on the next zwp_text_input_v3.commit request, and stay valid until the |
| 270 | next committed enable or disable request. |
| 271 | |
| 272 | The initial values describing a cursor rectangle are empty. That means |
| 273 | the text input does not support describing the cursor area. If the |
| 274 | empty values get applied, subsequent attempts to change them may have |
| 275 | no effect. |
| 276 | </description> |
| 277 | <arg name="x" type="int"/> |
| 278 | <arg name="y" type="int"/> |
| 279 | <arg name="width" type="int"/> |
| 280 | <arg name="height" type="int"/> |
| 281 | </request> |
| 282 | |
| 283 | <request name="commit"> |
| 284 | <description summary="commit state"> |
| 285 | Atomically applies state changes recently sent to the compositor. |
| 286 | |
| 287 | The commit request establishes and updates the state of the client, and |
| 288 | must be issued after any changes to apply them. |
| 289 | |
| 290 | Text input state (enabled status, content purpose, content hint, |
| 291 | surrounding text and change cause, cursor rectangle) is conceptually |
| 292 | double-buffered within the context of a text input, i.e. between a |
| 293 | committed enable request and the following committed enable or disable |
| 294 | request. |
| 295 | |
| 296 | Protocol requests modify the pending state, as opposed to the current |
| 297 | state in use by the input method. A commit request atomically applies |
| 298 | all pending state, replacing the current state. After commit, the new |
| 299 | pending state is as documented for each related request. |
| 300 | |
| 301 | Requests are applied in the order of arrival. |
| 302 | |
| 303 | Neither current nor pending state are modified unless noted otherwise. |
| 304 | |
| 305 | The compositor must count the number of commit requests coming from |
| 306 | each zwp_text_input_v3 object and use the count as the serial in done |
| 307 | events. |
| 308 | </description> |
| 309 | </request> |
| 310 | |
| 311 | <event name="enter"> |
| 312 | <description summary="enter event"> |
| 313 | Notification that this seat's text-input focus is on a certain surface. |
| 314 | |
| 315 | If client has created multiple text input objects, compositor must send |
| 316 | this event to all of them. |
| 317 | |
| 318 | When the seat has the keyboard capability the text-input focus follows |
| 319 | the keyboard focus. This event sets the current surface for the |
| 320 | text-input object. |
| 321 | </description> |
| 322 | <arg name="surface" type="object" interface="wl_surface"/> |
| 323 | </event> |
| 324 | |
| 325 | <event name="leave"> |
| 326 | <description summary="leave event"> |
| 327 | Notification that this seat's text-input focus is no longer on a |
| 328 | certain surface. The client should reset any preedit string previously |
| 329 | set. |
| 330 | |
| 331 | The leave notification clears the current surface. It is sent before |
| 332 | the enter notification for the new focus. After leave event, compositor |
| 333 | must ignore requests from any text input instances until next enter |
| 334 | event. |
| 335 | |
| 336 | When the seat has the keyboard capability the text-input focus follows |
| 337 | the keyboard focus. |
| 338 | </description> |
| 339 | <arg name="surface" type="object" interface="wl_surface"/> |
| 340 | </event> |
| 341 | |
| 342 | <event name="preedit_string"> |
| 343 | <description summary="pre-edit"> |
| 344 | Notify when a new composing text (pre-edit) should be set at the |
| 345 | current cursor position. Any previously set composing text must be |
| 346 | removed. Any previously existing selected text must be removed. |
| 347 | |
| 348 | The argument text contains the pre-edit string buffer. |
| 349 | |
| 350 | The parameters cursor_begin and cursor_end are counted in bytes |
| 351 | relative to the beginning of the submitted text buffer. Cursor should |
| 352 | be hidden when both are equal to -1. |
| 353 | |
| 354 | They could be represented by the client as a line if both values are |
| 355 | the same, or as a text highlight otherwise. |
| 356 | |
| 357 | Values set with this event are double-buffered. They must be applied |
| 358 | and reset to initial on the next zwp_text_input_v3.done event. |
| 359 | |
| 360 | The initial value of text is an empty string, and cursor_begin, |
| 361 | cursor_end and cursor_hidden are all 0. |
| 362 | </description> |
| 363 | <arg name="text" type="string" allow-null="true"/> |
| 364 | <arg name="cursor_begin" type="int"/> |
| 365 | <arg name="cursor_end" type="int"/> |
| 366 | </event> |
| 367 | |
| 368 | <event name="commit_string"> |
| 369 | <description summary="text commit"> |
| 370 | Notify when text should be inserted into the editor widget. The text to |
| 371 | commit could be either just a single character after a key press or the |
| 372 | result of some composing (pre-edit). |
| 373 | |
| 374 | Values set with this event are double-buffered. They must be applied |
| 375 | and reset to initial on the next zwp_text_input_v3.done event. |
| 376 | |
| 377 | The initial value of text is an empty string. |
| 378 | </description> |
| 379 | <arg name="text" type="string" allow-null="true"/> |
| 380 | </event> |
| 381 | |
| 382 | <event name="delete_surrounding_text"> |
| 383 | <description summary="delete surrounding text"> |
| 384 | Notify when the text around the current cursor position should be |
| 385 | deleted. |
| 386 | |
| 387 | Before_length and after_length are the number of bytes before and after |
| 388 | the current cursor index (excluding the selection) to delete. |
| 389 | |
| 390 | If a preedit text is present, in effect before_length is counted from |
| 391 | the beginning of it, and after_length from its end (see done event |
| 392 | sequence). |
| 393 | |
| 394 | Values set with this event are double-buffered. They must be applied |
| 395 | and reset to initial on the next zwp_text_input_v3.done event. |
| 396 | |
| 397 | The initial values of both before_length and after_length are 0. |
| 398 | </description> |
| 399 | <arg name="before_length" type="uint" summary="length of text before current cursor position"/> |
| 400 | <arg name="after_length" type="uint" summary="length of text after current cursor position"/> |
| 401 | </event> |
| 402 | |
| 403 | <event name="done"> |
| 404 | <description summary="apply changes"> |
| 405 | Instruct the application to apply changes to state requested by the |
| 406 | preedit_string, commit_string and delete_surrounding_text events. The |
| 407 | state relating to these events is double-buffered, and each one |
| 408 | modifies the pending state. This event replaces the current state with |
| 409 | the pending state. |
| 410 | |
| 411 | The application must proceed by evaluating the changes in the following |
| 412 | order: |
| 413 | |
| 414 | 1. Replace existing preedit string with the cursor. |
| 415 | 2. Delete requested surrounding text. |
| 416 | 3. Insert commit string with the cursor at its end. |
| 417 | 4. Calculate surrounding text to send. |
| 418 | 5. Insert new preedit text in cursor position. |
| 419 | 6. Place cursor inside preedit text. |
| 420 | |
| 421 | The serial number reflects the last state of the zwp_text_input_v3 |
| 422 | object known to the compositor. The value of the serial argument must |
| 423 | be equal to the number of commit requests already issued on that object. |
| 424 | |
| 425 | When the client receives a done event with a serial different than the |
| 426 | number of past commit requests, it must proceed with evaluating and |
| 427 | applying the changes as normal, except it should not change the current |
| 428 | state of the zwp_text_input_v3 object. All pending state requests |
| 429 | (set_surrounding_text, set_content_type and set_cursor_rectangle) on |
| 430 | the zwp_text_input_v3 object should be sent and committed after |
| 431 | receiving a zwp_text_input_v3.done event with a matching serial. |
| 432 | </description> |
| 433 | <arg name="serial" type="uint"/> |
| 434 | </event> |
| 435 | </interface> |
| 436 | |
| 437 | <interface name="zwp_text_input_manager_v3" version="1"> |
| 438 | <description summary="text input manager"> |
| 439 | A factory for text-input objects. This object is a global singleton. |
| 440 | </description> |
| 441 | |
| 442 | <request name="destroy" type="destructor"> |
| 443 | <description summary="Destroy the wp_text_input_manager"> |
| 444 | Destroy the wp_text_input_manager object. |
| 445 | </description> |
| 446 | </request> |
| 447 | |
| 448 | <request name="get_text_input"> |
| 449 | <description summary="create a new text input object"> |
| 450 | Creates a new text-input object for a given seat. |
| 451 | </description> |
| 452 | <arg name="id" type="new_id" interface="zwp_text_input_v3"/> |
| 453 | <arg name="seat" type="object" interface="wl_seat"/> |
| 454 | </request> |
| 455 | </interface> |
| 456 | </protocol> |