Get surrounding and selection text by fd 05/69605/3
authorLi Zhang <li2012.zhang@samsung.com>
Mon, 16 May 2016 02:47:37 +0000 (10:47 +0800)
committerZhang Li <li2012.zhang@samsung.com>
Fri, 3 Jun 2016 08:42:19 +0000 (01:42 -0700)
Change-Id: I0a52cf50bf97d6589f9bdfd0dd0b75d81e9098f0

src/e_mod_main.c

index 17e3bbfcb4b11122bb7bc5a04565e140fcd893ce..aa3af84be730bcfc285cf5d2cbf5313bb0e7553b 100644 (file)
@@ -623,7 +623,7 @@ _e_text_input_method_context_cb_hide_input_panel(struct wl_client *client EINA_U
 }
 
 static void
-_e_text_input_method_context_cb_get_selection_text(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial)
+_e_text_input_method_context_cb_get_selection_text(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t fd)
 {
    E_Input_Method_Context *context = wl_resource_get_user_data(resource);
 
@@ -632,16 +632,19 @@ _e_text_input_method_context_cb_get_selection_text(struct wl_client *client EINA
         wl_resource_post_error(resource,
                                WL_DISPLAY_ERROR_INVALID_OBJECT,
                                "No Input Method Context For Resource");
+        close (fd);
         return;
      }
 
    if ((context->model) && (context->model->resource))
-     wl_text_input_send_get_selection_text(context->model->resource, serial);
+     wl_text_input_send_get_selection_text(context->model->resource, fd);
+
+   close (fd);
 }
 
 static void
-_e_text_input_method_context_cb_get_surrounding_text(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial,
-                                                     uint32_t maxlen_before, uint32_t maxlen_after)
+_e_text_input_method_context_cb_get_surrounding_text(struct wl_client *client EINA_UNUSED, struct wl_resource *resource,
+                                                     uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd)
 {
    E_Input_Method_Context *context = wl_resource_get_user_data(resource);
 
@@ -650,11 +653,14 @@ _e_text_input_method_context_cb_get_surrounding_text(struct wl_client *client EI
         wl_resource_post_error(resource,
                                WL_DISPLAY_ERROR_INVALID_OBJECT,
                                "No Input Method Context For Resource");
+        close (fd);
         return;
      }
 
    if ((context->model) && (context->model->resource))
-     wl_text_input_send_get_surrounding_text(context->model->resource, serial, maxlen_before, maxlen_after);
+     wl_text_input_send_get_surrounding_text(context->model->resource, maxlen_before, maxlen_after, fd);
+
+   close (fd);
 }
 
 static const struct wl_input_method_context_interface _e_text_input_method_context_implementation = {
@@ -1010,30 +1016,6 @@ _e_text_input_cb_reset(struct wl_client *client EINA_UNUSED, struct wl_resource
      }
 }
 
-static void
-_e_text_input_cb_surrounding_text_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t serial, const char *text, uint32_t cursor_position)
-{
-   E_Text_Input *text_input = wl_resource_get_user_data(resource);
-   E_Input_Method *input_method = NULL;
-   Eina_List *l = NULL;
-
-   if (!text_input)
-     {
-        wl_resource_post_error(resource,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "No Text Input For Resource");
-        return;
-     }
-
-   EINA_LIST_FOREACH(text_input->input_methods, l, input_method)
-     {
-        if (!input_method || !input_method->context) continue;
-        if (input_method->context->resource)
-          wl_input_method_context_send_surrounding_text(input_method->context->resource,
-                                                        serial, text, cursor_position);
-     }
-}
-
 static void
 _e_text_input_cb_content_type_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t hint, uint32_t purpose)
 {
@@ -1249,31 +1231,6 @@ _e_text_input_cb_bidi_direction_set(struct wl_client *client EINA_UNUSED, struct
      }
 }
 
-static void
-_e_text_input_cb_selection_text_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource,  uint32_t serial, const char *text)
-{
-   E_Text_Input *text_input = wl_resource_get_user_data(resource);
-   E_Input_Method *input_method = NULL;
-   Eina_List *l = NULL;
-
-   if (!text_input)
-     {
-        wl_resource_post_error(resource,
-                               WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "No Text Input For Resource");
-        return;
-     }
-
-   EINA_LIST_FOREACH(text_input->input_methods, l, input_method)
-     {
-        if (!input_method || !input_method->context) continue;
-
-        if (input_method->context->resource)
-          wl_input_method_context_send_selection_text(input_method->context->resource,
-                                                      serial, text);
-     }
-}
-
 static void
 _e_text_input_cb_cursor_position_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource,  uint32_t cursor_position)
 {
@@ -1304,7 +1261,6 @@ static const struct wl_text_input_interface _e_text_input_implementation = {
      _e_text_input_cb_input_panel_show,
      _e_text_input_cb_input_panel_hide,
      _e_text_input_cb_reset,
-     _e_text_input_cb_surrounding_text_set,
      _e_text_input_cb_content_type_set,
      _e_text_input_cb_cursor_rectangle_set,
      _e_text_input_cb_preferred_language_set,
@@ -1314,7 +1270,6 @@ static const struct wl_text_input_interface _e_text_input_implementation = {
      _e_text_input_cb_return_key_disabled_set,
      _e_text_input_cb_input_panel_data_set,
      _e_text_input_cb_bidi_direction_set,
-     _e_text_input_cb_selection_text_set,
      _e_text_input_cb_cursor_position_set
 };