[PATCH 10/13] text: Order requests and events in a nice way

Jan Arne Petersen jpetersen at openismus.com
Tue Feb 19 10:27:04 PST 2013


From: Jan Arne Petersen <jpetersen at openismus.com>

Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
 clients/editor.c   |  14 ++---
 protocol/text.xml  | 172 ++++++++++++++++++++++++++---------------------------
 src/text-backend.c |  24 ++++----
 tests/text-test.c  |  14 ++---
 4 files changed, 112 insertions(+), 112 deletions(-)

diff --git a/clients/editor.c b/clients/editor.c
index d640acc..3927019 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -428,17 +428,17 @@ text_model_text_direction(void *data,
 }
 
 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_delete_surrounding_text,
-	text_model_cursor_position,
 	text_model_preedit_styling,
 	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_enter,
-	text_model_leave,
-	text_model_input_panel_state,
 	text_model_language,
 	text_model_text_direction
 };
diff --git a/protocol/text.xml b/protocol/text.xml
index ea5bfe1..97ac8b4 100644
--- a/protocol/text.xml
+++ b/protocol/text.xml
@@ -37,17 +37,6 @@
       removes the need for applications to directly process hardware key events
       and compose text out of them.
     </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">
       <description summary="request activation">
         Requests the model to be activated (typically when the text entry gets
@@ -68,6 +57,16 @@
       </description>
       <arg name="seat" type="object" interface="wl_seat"/>
     </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">
       <description summary="reset">
         Should be called by an editor widget when the input state should be
@@ -76,11 +75,16 @@
       </description>
       <arg name="serial" type="uint"/>
     </request>
-    <request name="set_cursor_rectangle">
-      <arg name="x" type="int"/>
-      <arg name="y" type="int"/>
-      <arg name="width" type="int"/>
-      <arg name="height" type="int"/>
+    <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>
     <enum name="content_hint">
       <description summary="content hint">
@@ -136,21 +140,11 @@
       <arg name="hint" type="uint"/>
       <arg name="purpose" type="uint"/>
     </request>
-    <request name="invoke_action">
-      <arg name="button" type="uint"/>
-      <arg name="index" type="uint"/>
-    </request>
-    <request name="commit_state">
-    </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 name="set_cursor_rectangle">
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+      <arg name="width" type="int"/>
+      <arg name="height" type="int"/>
     </request>
     <request name="set_preferred_language">
       <description summary="sets preferred language">
@@ -164,17 +158,39 @@
       </description>
       <arg name="language" type="string"/>
     </request>
-    <event name="commit_string">
-      <description summary="commit">
-        Notify when text should be inserted into the editor widget. The text to
-        commit could be either just a single character after a key press or the
-        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.
+    <request name="commit_state">
+    </request>
+    <request name="invoke_action">
+      <arg name="button" type="uint"/>
+      <arg name="index" type="uint"/>
+    </request>
+    <event name="enter">
+      <description summary="enter event">
+        Notify the model when it is activated. Typically in response to an
+        activate request.
       </description>
-      <arg name="serial" type="uint"/>
-      <arg name="text" type="string"/>
+      <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="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 name="preedit_string">
       <description summary="pre-edit">
@@ -189,25 +205,6 @@
       <arg name="text" type="string"/>
       <arg name="commit" type="string"/>
     </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">
       <entry name="default" value="1"/>
       <entry name="active" value="2"/>
@@ -243,13 +240,36 @@
       <arg name="serial" type="uint"/>
       <arg name="index" type="int"/>
     </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.
+    <event name="commit_string">
+      <description summary="commit">
+        Notify when text should be inserted into the editor widget. The text to
+        commit could be either just a single character after a key press or the
+        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>
-      <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 name="keysym">
       <description summary="keysym">
@@ -266,26 +286,6 @@
       <arg name="state" type="uint"/>
       <arg name="modifiers" type="uint"/>
     </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">
       <description summary="language">
         Sets the language of the input text. The "language" argument is a RFC-3066 
diff --git a/src/text-backend.c b/src/text-backend.c
index 7d1d7d7..c083683 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -219,12 +219,12 @@ text_model_reset(struct wl_client *client,
 }
 
 static void
-text_model_set_micro_focus(struct wl_client *client,
-			   struct wl_resource *resource,
-			   int32_t x,
-			   int32_t y,
-			   int32_t width,
-			   int32_t height)
+text_model_set_cursor_rectangle(struct wl_client *client,
+				struct wl_resource *resource,
+				int32_t x,
+				int32_t y,
+				int32_t width,
+				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 = {
-	text_model_set_surrounding_text,
 	text_model_activate,
 	text_model_deactivate,
+	text_model_show_input_panel,
+	text_model_hide_input_panel,
 	text_model_reset,
-	text_model_set_micro_focus,
+	text_model_set_surrounding_text,
 	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_show_input_panel,
-	text_model_hide_input_panel,
-	text_model_set_preferred_language
+	text_model_invoke_action
 };
 
 static void text_model_factory_create_text_model(struct wl_client *client,
diff --git a/tests/text-test.c b/tests/text-test.c
index 41bf750..8983ac4 100644
--- a/tests/text-test.c
+++ b/tests/text-test.c
@@ -148,17 +148,17 @@ text_model_text_direction(void *data,
 }
 
 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_delete_surrounding_text,
-	text_model_cursor_position,
 	text_model_preedit_styling,
 	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_enter,
-	text_model_leave,
-	text_model_input_panel_state,
 	text_model_language,
 	text_model_text_direction
 };
-- 
1.8.1.2



More information about the wayland-devel mailing list