From 9b0e303048e7a0e7cd37c0f5b62273e8fa4f2ec0 Mon Sep 17 00:00:00 2001 From: dcz Date: Tue, 1 Jul 2025 04:57:25 +0000 Subject: [PATCH] xx-input-method-v2: Add actions including selection finishing This update solves the mobile problem of the "enter" key. It also makes precise cursor placement possible from the IME. Signed-off-by: Dorota Czaplejewicz --- .../xx-input-method/xx-input-method-v2.xml | 90 ++++++++++-- .../xx-text-input/xx-text-input-v3.xml | 129 ++++++++++++++---- 2 files changed, 181 insertions(+), 38 deletions(-) diff --git a/experimental/xx-input-method/xx-input-method-v2.xml b/experimental/xx-input-method/xx-input-method-v2.xml index de8d406..b9902db 100644 --- a/experimental/xx-input-method/xx-input-method-v2.xml +++ b/experimental/xx-input-method/xx-input-method-v2.xml @@ -47,7 +47,7 @@ mechanism is discouraged. - + An input method object allows for clients to compose text. @@ -168,7 +168,7 @@ The initial value of cause is input_method. - + @@ -183,8 +183,38 @@ The initial value for hint is none, and the initial value for purpose is normal. - - + + + + + + + Announces the actions available for the currently active text input. + + Values set with this event are double-buffered. They will get applied + on the next .done event. + They get reset to the initial value on the next committed deactivate event. + + The initial value is an empty set: no actions are available. + + Values in the available_actions array come from text-input-v3.action. + + + + + + + Notifies the input method what the currently active text input client is able to do. + + This event should come within the same .done sequence as .activate. Otherwise, the input method may ignore it. + + Values set with this event are double-buffered. They will get applied + on the next .done event. + They get reset to initial on the next committed deactivate event. + + The initial value for features is none. + + @@ -209,6 +239,18 @@ + + + Perform an action on this text input. + + Values set with this event are double-buffered. They must be applied + and reset to initial on the next commit request. + + The initial value of action is none. + + + + Send the commit string text for insertion to the application. @@ -283,6 +325,34 @@ + + + Unselects text, moves the cursor and selects text. + + This is equivalent to dragging the mouse over some text: it deselects whatever might be currently selected and selects a new range of text. + + The offsets used in arguments are in bytes relative to the current cursor position. Cursor is the new position of the cursor, and anchor is the opposite end of selection. If there's no selection, anchor should be equal to cursor. + + The offsets do not take preedit contents into account, nor is preedit changed in any way with this request. + + Both cursor and anchor must fall on code point boundaries, otherwise text input client may ignore the request. It is therefore not recommended for an input method to move any of them beyond the text received in surrounding_text. + + When surrounding_text is not supported, the offsets must not be interpreted as bytes, but as some human-readable unit at least as big as a code point, for example a grapheme. + + The cursor and anchor arguments can also take the following special values: + BEGINNING := 0x8000_0000 = i32::MIN + END := 0x7fff_ffff = i32::MAX + meaning, respectively, the beginning and the end of of all text in the input field. + + Values set with this event are double-buffered. They must be applied + and reset to initial on the next commit request. + + The initial values of both cursor and anchor are 0. + + + + + Apply state changes from commit_string, set_preedit_string and @@ -298,10 +368,14 @@ 1. Replace existing preedit string with the cursor. 2. Delete requested surrounding text. 3. Insert commit string with the cursor at its end. - 4. Calculate surrounding text to send. - 5. Insert new preedit text in cursor position. - 6. Place cursor inside preedit text. + 4. Move the cursor and selection. + 5. Calculate surrounding text to send. + 6. Insert new preedit text in cursor position. + 7. Place cursor inside preedit text. + 8. Perform the requested action. + Note that the input method can not receive more than 4000 bytes of selection text, which might be the case for example when the entire document is selected. Nevertheless, the text input must delete the entire selected range before inserting the commit string. + The serial number reflects the last state of the xx_input_method_v1 object known to the client. The value of the serial argument must be equal to the number of done events already issued by that object. When @@ -793,7 +867,7 @@ - + The input method manager allows the client to become the input method on a chosen seat. diff --git a/experimental/xx-text-input/xx-text-input-v3.xml b/experimental/xx-text-input/xx-text-input-v3.xml index 29cfccf..7add990 100644 --- a/experimental/xx-text-input/xx-text-input-v3.xml +++ b/experimental/xx-text-input/xx-text-input-v3.xml @@ -402,6 +402,43 @@ + + + Unselects text, moves the cursor and selects text. + + This is equivalent to dragging the mouse over some text: it deselects whatever might be currently selected and selects a new range of text. + + The offsets used in arguments are in bytes relative to the current cursor position. Cursor is the new position of the cursor, and anchor is the opposite end of selection. If there's no selection, anchor should be equal to cursor. + In terms of dragging the mouse, the anchor is the start, and cursor the end. + + The offsets do not take preedit contents into account, nor is preedit changed in any way with this request. + + Both cursor and anchor must fall on code point boundaries, otherwise text input client may ignore the request. It is therefore not recommended for an input method to move any of them beyond the text received in surrounding_text. + + + When surrounding_text is not supported, the offsets must not be interpreted as bytes, but as some human-readable unit at least as big as a code point, for example a grapheme. + + The cursor and anchor arguments can also take the following special values: + BEGINNING := 0x8000_0000 = i32::MIN + END := 0x7fff_ffff = i32::MAX + meaning, respectively, the beginning and the end of of all text in the input field. + + Values set with this event are double-buffered. They must be applied + and reset to initial on the next commit request. + + The initial values of both cursor and anchor are 0. + + + + + Instruct the application to apply changes to state requested by the @@ -417,10 +454,11 @@ 1. Replace existing preedit string with the cursor. 2. Delete requested surrounding text. 3. Insert commit string with the cursor at its end. - 4. Calculate surrounding text to send. - 5. Insert new preedit text in cursor position. - 6. Place cursor inside preedit text. - 7. Perform the requested action. + 4. Move the cursor and selection. + 5. Calculate surrounding text to send. + 6. Insert new preedit text in cursor position. + 7. Place cursor inside preedit text. + 8. Perform the requested action. The serial number reflects the last state of the xx_text_input_v3 object known to the compositor. The value of the serial argument must @@ -437,51 +475,82 @@ - - - - A possible action to perform on a text input. - - The backspace and delete actions should be handled in a similar manner - to backpace and delete keys being pressed on a keyboard. - - - - - + - + + + + This should be triggered when the user is done with editing the field and wants to move on. For example, the query was typed and the user wants the search result. Or the name was entered and the address needs to be typed next. + + The action to perform depends on the application, and should match the value of the current content_purpose. + + All clients SHOULD implement this action. Without it, on-screen keyboards don't work as expected. + + + + + - An action was performed on this text input. + The input method issued an action to perform on this text input. Values set with this event are double-buffered. They must be applied - and reset to initial on the next zwp_text_input_v4.done event. + and reset to initial on the next .done event. The initial value of action is none. - - + - - Set the actions available for this text input. + + Announces the actions available for the currently active text input. - Values set with this request are double-buffered. They will get applied - on the next zwp_text_input_v4.commit request. + Values set with this event are double-buffered. They will get applied + on the next .done event. + They get reset to the initial value on the next committed deactivate event. - If the available_actions array contains the none action, or contains the - same action multiple times, the compositor must raise the invalid_action - protocol error. - - Initially, no actions are available. + The initial value is an empty set: no actions are available. + + Values in the available_actions array come from text-input-v3.action. + + + + + + + Client functionality over the baseline that isn't indicated implicitly. + + This does not include events coming with .enable: when the input method receives such an event, it is clear the text input supports it, e.g. content_type, available_actions. + + Baseline functionality like commit_string, set_preedit_string must always be supported for the protocol to be useful. + + The flags match text-input protocol versions, but should be kept general enough to support other protocols. + + + + + + + Notifies the input method what the currently active text input client is able to do. + + This event should come within the same .done sequence as .activate. Otherwise, the input method may ignore it. + + Values set with this event are double-buffered. They will get applied + on the next .done event. + They get reset to initial on the next committed deactivate event. + + The initial value for features is none. + + +