text: Order requests and events in a nice way

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
dev
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent fa3573852d
commit 7ef8effca5
  1. 14
      clients/editor.c
  2. 172
      protocol/text.xml
  3. 24
      src/text-backend.c
  4. 14
      tests/text-test.c

@ -428,17 +428,17 @@ text_model_text_direction(void *data,
} }
static const struct text_model_listener text_model_listener = { static const struct text_model_listener text_model_listener = {
text_model_commit_string, text_model_enter,
text_model_leave,
text_model_modifiers_map,
text_model_input_panel_state,
text_model_preedit_string, text_model_preedit_string,
text_model_delete_surrounding_text,
text_model_cursor_position,
text_model_preedit_styling, text_model_preedit_styling,
text_model_preedit_cursor, text_model_preedit_cursor,
text_model_modifiers_map, text_model_commit_string,
text_model_cursor_position,
text_model_delete_surrounding_text,
text_model_keysym, text_model_keysym,
text_model_enter,
text_model_leave,
text_model_input_panel_state,
text_model_language, text_model_language,
text_model_text_direction text_model_text_direction
}; };

@ -37,17 +37,6 @@
removes the need for applications to directly process hardware key events removes the need for applications to directly process hardware key events
and compose text out of them. and compose text out of them.
</description> </description>
<request name="set_surrounding_text">
<description summary="sets the surrounding text">
Sets the plain surrounding text around the input position. Cursor is the
byte index within the surrounding text. Anchor is the byte index of the
selection anchor within the surrounding text. If there is no selected
text anchor then it is the same as cursor.
</description>
<arg name="text" type="string"/>
<arg name="cursor" type="uint"/>
<arg name="anchor" type="uint"/>
</request>
<request name="activate"> <request name="activate">
<description summary="request activation"> <description summary="request activation">
Requests the model to be activated (typically when the text entry gets Requests the model to be activated (typically when the text entry gets
@ -68,6 +57,16 @@
</description> </description>
<arg name="seat" type="object" interface="wl_seat"/> <arg name="seat" type="object" interface="wl_seat"/>
</request> </request>
<request name="show_input_panel">
<description summary="show input panels">
Requests input panels (virtual keyboard) to show.
</description>
</request>
<request name="hide_input_panel">
<description summary="hide input panels">
Requests input panels (virtual keyboard) to hide.
</description>
</request>
<request name="reset"> <request name="reset">
<description summary="reset"> <description summary="reset">
Should be called by an editor widget when the input state should be Should be called by an editor widget when the input state should be
@ -76,11 +75,16 @@
</description> </description>
<arg name="serial" type="uint"/> <arg name="serial" type="uint"/>
</request> </request>
<request name="set_cursor_rectangle"> <request name="set_surrounding_text">
<arg name="x" type="int"/> <description summary="sets the surrounding text">
<arg name="y" type="int"/> Sets the plain surrounding text around the input position. Cursor is the
<arg name="width" type="int"/> byte index within the surrounding text. Anchor is the byte index of the
<arg name="height" type="int"/> selection anchor within the surrounding text. If there is no selected
text anchor then it is the same as cursor.
</description>
<arg name="text" type="string"/>
<arg name="cursor" type="uint"/>
<arg name="anchor" type="uint"/>
</request> </request>
<enum name="content_hint"> <enum name="content_hint">
<description summary="content hint"> <description summary="content hint">
@ -136,21 +140,11 @@
<arg name="hint" type="uint"/> <arg name="hint" type="uint"/>
<arg name="purpose" type="uint"/> <arg name="purpose" type="uint"/>
</request> </request>
<request name="invoke_action"> <request name="set_cursor_rectangle">
<arg name="button" type="uint"/> <arg name="x" type="int"/>
<arg name="index" type="uint"/> <arg name="y" type="int"/>
</request> <arg name="width" type="int"/>
<request name="commit_state"> <arg name="height" type="int"/>
</request>
<request name="show_input_panel">
<description summary="show input panels">
Requests input panels (virtual keyboard) to show.
</description>
</request>
<request name="hide_input_panel">
<description summary="hide input panels">
Requests input panels (virtual keyboard) to hide.
</description>
</request> </request>
<request name="set_preferred_language"> <request name="set_preferred_language">
<description summary="sets preferred language"> <description summary="sets preferred language">
@ -164,17 +158,39 @@
</description> </description>
<arg name="language" type="string"/> <arg name="language" type="string"/>
</request> </request>
<event name="commit_string"> <request name="commit_state">
<description summary="commit"> </request>
Notify when text should be inserted into the editor widget. The text to <request name="invoke_action">
commit could be either just a single character after a key press or the <arg name="button" type="uint"/>
result of some composing (pre-edit). It also sets the new cursor <arg name="index" type="uint"/>
position (as byte index) relative to the beginning of inserted text. </request>
<event name="enter">
Any previously set composing text should be removed. <description summary="enter event">
Notify the model when it is activated. Typically in response to an
activate request.
</description> </description>
<arg name="serial" type="uint"/> <arg name="surface" type="object" interface="wl_surface"/>
<arg name="text" type="string"/> </event>
<event name="leave">
<description summary="leave event">
Notify the model when it is deactivated. Either in response to a
deactivate request or when the assigned surface lost focus or was
destroyed.
</description>
</event>
<event name="modifiers_map">
<description summary="modifiers map">
Transfer an array of 0-terminated modifiers names. The position in
the array is the index of the modifier as used in the modifiers
bitmask in the keysym event.
</description>
<arg name="map" type="array"/>
</event>
<event name="input_panel_state">
<description summary="state of the input panel">
Notify when the visibility state of the input panel changed.
</description>
<arg name="state" type="uint"/>
</event> </event>
<event name="preedit_string"> <event name="preedit_string">
<description summary="pre-edit"> <description summary="pre-edit">
@ -189,25 +205,6 @@
<arg name="text" type="string"/> <arg name="text" type="string"/>
<arg name="commit" type="string"/> <arg name="commit" type="string"/>
</event> </event>
<event name="delete_surrounding_text">
<description summary="delete surrounding text">
Notify when the text around the current cursor position should be
deleted. Index is relative to the current cursor (as byte index).
Length is the length of deleted text (in bytes).
</description>
<arg name="serial" type="uint"/>
<arg name="index" type="int"/>
<arg name="length" type="uint"/>
</event>
<event name="cursor_position">
<description summary="set cursor to new position">
Notify when the cursor or anchor position should be modified. It
should take effect after the next commit_string event.
</description>
<arg name="serial" type="uint"/>
<arg name="index" type="int"/>
<arg name="anchor" type="int"/>
</event>
<enum name="preedit_style"> <enum name="preedit_style">
<entry name="default" value="1"/> <entry name="default" value="1"/>
<entry name="active" value="2"/> <entry name="active" value="2"/>
@ -243,13 +240,36 @@
<arg name="serial" type="uint"/> <arg name="serial" type="uint"/>
<arg name="index" type="int"/> <arg name="index" type="int"/>
</event> </event>
<event name="modifiers_map"> <event name="commit_string">
<description summary="modifiers map"> <description summary="commit">
Transfer an array of 0-terminated modifiers names. The position in Notify when text should be inserted into the editor widget. The text to
the array is the index of the modifier as used in the modifiers commit could be either just a single character after a key press or the
bitmask in the keysym event. result of some composing (pre-edit). It also sets the new cursor
position (as byte index) relative to the beginning of inserted text.
Any previously set composing text should be removed.
</description> </description>
<arg name="map" type="array"/> <arg name="serial" type="uint"/>
<arg name="text" type="string"/>
</event>
<event name="cursor_position">
<description summary="set cursor to new position">
Notify when the cursor or anchor position should be modified. It
should take effect after the next commit_string event.
</description>
<arg name="serial" type="uint"/>
<arg name="index" type="int"/>
<arg name="anchor" type="int"/>
</event>
<event name="delete_surrounding_text">
<description summary="delete surrounding text">
Notify when the text around the current cursor position should be
deleted. Index is relative to the current cursor (as byte index).
Length is the length of deleted text (in bytes).
</description>
<arg name="serial" type="uint"/>
<arg name="index" type="int"/>
<arg name="length" type="uint"/>
</event> </event>
<event name="keysym"> <event name="keysym">
<description summary="keysym"> <description summary="keysym">
@ -266,26 +286,6 @@
<arg name="state" type="uint"/> <arg name="state" type="uint"/>
<arg name="modifiers" type="uint"/> <arg name="modifiers" type="uint"/>
</event> </event>
<event name="enter">
<description summary="enter event">
Notify the model when it is activated. Typically in response to an
activate request.
</description>
<arg name="surface" type="object" interface="wl_surface"/>
</event>
<event name="leave">
<description summary="leave event">
Notify the model when it is deactivated. Either in response to a
deactivate request or when the assigned surface lost focus or was
destroyed.
</description>
</event>
<event name="input_panel_state">
<description summary="state of the input panel">
Notify when the visibility state of the input panel changed.
</description>
<arg name="state" type="uint"/>
</event>
<event name="language"> <event name="language">
<description summary="language"> <description summary="language">
Sets the language of the input text. The "language" argument is a RFC-3066 Sets the language of the input text. The "language" argument is a RFC-3066

@ -219,12 +219,12 @@ text_model_reset(struct wl_client *client,
} }
static void static void
text_model_set_micro_focus(struct wl_client *client, text_model_set_cursor_rectangle(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
int32_t x, int32_t x,
int32_t y, int32_t y,
int32_t width, int32_t width,
int32_t height) int32_t height)
{ {
} }
@ -317,17 +317,17 @@ text_model_set_preferred_language(struct wl_client *client,
} }
static const struct text_model_interface text_model_implementation = { static const struct text_model_interface text_model_implementation = {
text_model_set_surrounding_text,
text_model_activate, text_model_activate,
text_model_deactivate, text_model_deactivate,
text_model_show_input_panel,
text_model_hide_input_panel,
text_model_reset, text_model_reset,
text_model_set_micro_focus, text_model_set_surrounding_text,
text_model_set_content_type, text_model_set_content_type,
text_model_invoke_action, text_model_set_cursor_rectangle,
text_model_set_preferred_language,
text_model_commit_state, text_model_commit_state,
text_model_show_input_panel, text_model_invoke_action
text_model_hide_input_panel,
text_model_set_preferred_language
}; };
static void text_model_factory_create_text_model(struct wl_client *client, static void text_model_factory_create_text_model(struct wl_client *client,

@ -148,17 +148,17 @@ text_model_text_direction(void *data,
} }
static const struct text_model_listener text_model_listener = { static const struct text_model_listener text_model_listener = {
text_model_commit_string, text_model_enter,
text_model_leave,
text_model_modifiers_map,
text_model_input_panel_state,
text_model_preedit_string, text_model_preedit_string,
text_model_delete_surrounding_text,
text_model_cursor_position,
text_model_preedit_styling, text_model_preedit_styling,
text_model_preedit_cursor, text_model_preedit_cursor,
text_model_modifiers_map, text_model_commit_string,
text_model_cursor_position,
text_model_delete_surrounding_text,
text_model_keysym, text_model_keysym,
text_model_enter,
text_model_leave,
text_model_input_panel_state,
text_model_language, text_model_language,
text_model_text_direction text_model_text_direction
}; };

Loading…
Cancel
Save