Revert "Process key down or up event in input thread" 65/292365/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 4 May 2023 09:52:17 +0000 (09:52 +0000)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 4 May 2023 09:54:32 +0000 (18:54 +0900)
This reverts commit e72ad331d6156e3ed2d3c9597eea030070f736b1.

Change-Id: I5969854f13c071607af2cf5a03fda5824d1391a5

src/e_mod_main.c

index b236968f4887a75da4d5940fe2b3150c001886e3..996031baf84d123f46f350d28f6dcb85220dd011 100644 (file)
@@ -2,9 +2,6 @@
 #include "e.h"
 #include "e_mod_main.h"
 #include "e_mod_input_method_manager.h"
-#include "e_device.h"
-#include "e_input_event.h"
-
 #include <text-server-protocol.h>
 #include <input-method-server-protocol.h>
 #include <vconf.h>
@@ -14,7 +11,6 @@
 #include <stdlib.h>
 #include <system_info.h>
 #include <xkbcommon/xkbcommon.h>
-#include <glib.h>
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -150,10 +146,10 @@ static struct wl_client *g_client = NULL;
 static Eina_List *shutdown_list = NULL;
 static Eina_Bool g_disable_show_panel = EINA_FALSE;
 static Eeze_Udev_Watch *eeze_udev_watch_handler = NULL;
-static E_Input_Event_Filter *e_input_key_down_filter = NULL;
+static Ecore_Event_Handler *ecore_key_down_handler = NULL;
 static Eina_List *handlers = NULL;
 static uint32_t g_text_input_count = 1;
-static gint g_timer_will_hide = 0;
+static Ecore_Timer *g_timer_will_hide  = NULL;
 static enum _E_Input_Panel_State g_input_panel_state = E_INPUT_PANEL_STATE_DID_HIDE;
 static E_Client *client_surface_ec = NULL;
 static E_Text_Input *g_show_text_input = NULL;
@@ -229,8 +225,8 @@ _e_text_input_send_input_panel_geometry(struct wl_resource *resource, int x, int
    wl_text_input_send_input_panel_geometry(resource, x, y, w, h);
 }
 
-static gboolean
-_will_hide_timer_handler(gpointer data)
+static Eina_Bool
+_will_hide_timer_handler(void *data)
 {
    INF("TIMED OUT while waiting for WILL_HIDE_ACK : %d", g_input_panel_state);
    if (g_input_panel_state == E_INPUT_PANEL_STATE_WILL_HIDE)
@@ -240,18 +236,9 @@ _will_hide_timer_handler(gpointer data)
         g_input_panel_state = E_INPUT_PANEL_STATE_DID_HIDE;
      }
 
-   g_timer_will_hide = 0;
-
-   return FALSE;
-}
+   g_timer_will_hide = NULL;
 
-static void _cancel_will_hide_timer()
-{
-   if (g_timer_will_hide > 0)
-     {
-        g_source_remove(g_timer_will_hide);
-        g_timer_will_hide = 0;
-     }
+   return ECORE_CALLBACK_CANCEL;
 }
 
 static void
@@ -287,7 +274,11 @@ _input_panel_hide(struct wl_client *client, struct wl_resource *resource, Eina_B
         if (text_input->resource)
           wl_text_input_send_private_command(text_input->resource, 0, "CONFORMANT_RESET");
 
-        _cancel_will_hide_timer();
+        if (g_timer_will_hide)
+          {
+             ecore_timer_del(g_timer_will_hide);
+             g_timer_will_hide = NULL;
+          }
 
         zone = e_zone_current_get();
         effect_run = e_input_panel_is_effect_running();
@@ -297,8 +288,7 @@ _input_panel_hide(struct wl_client *client, struct wl_resource *resource, Eina_B
           timeout = 0.0f;
         else
           timeout = WILL_HIDE_TIMER_INTERVAL;
-
-        g_timer_will_hide = g_timeout_add(timeout*1000, _will_hide_timer_handler, NULL);
+        g_timer_will_hide = ecore_timer_add(timeout, _will_hide_timer_handler, NULL);
      }
 
    if (g_input_method && g_input_method->resource)
@@ -318,9 +308,7 @@ _input_panel_hide(struct wl_client *client, struct wl_resource *resource, Eina_B
    if (_context_created)
      _e_text_input_deactivate(text_input, input_method, EINA_FALSE);
 
-   ecore_thread_main_loop_begin();
    e_input_panel_wait_update_set(EINA_FALSE);
-   ecore_thread_main_loop_end();
 
    /* When the input panel surface is hidden, the candidate will hide too */
    g_show_state_candidate = EINA_FALSE;
@@ -468,13 +456,12 @@ _e_text_input_method_context_grab_set(E_Input_Method_Context *context, Eina_Bool
         if (context->kbd.state) xkb_state_unref(context->kbd.state);
         context->kbd.keymap = xkb_map_ref(e_comp_wl->xkb.keymap);
         context->kbd.state = xkb_state_new(e_comp_wl->xkb.keymap);
-
-        E_Input_Event_Source *input_event_source = e_input_event_source_get();
-        if (input_event_source)
-          {
-             _key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_text_input_method_context_ecore_cb_key_down, context);
-             _key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_text_input_method_context_ecore_cb_key_up, context);
-          }
+        E_LIST_HANDLER_APPEND(context->kbd.handlers, ECORE_EVENT_KEY_DOWN,
+                              _e_text_input_method_context_ecore_cb_key_down,
+                              context);
+        E_LIST_HANDLER_APPEND(context->kbd.handlers, ECORE_EVENT_KEY_UP,
+                              _e_text_input_method_context_ecore_cb_key_up,
+                              context);
 
         e_comp_grab_input(0, 1);
      }
@@ -482,19 +469,6 @@ _e_text_input_method_context_grab_set(E_Input_Method_Context *context, Eina_Bool
      {
         E_FREE_LIST(context->kbd.handlers, ecore_event_handler_del);
 
-        E_Input_Event_Source *input_event_source = e_input_event_source_get();
-        if (input_event_source)
-          {
-             if (_key_down_handler)
-               e_input_event_handler_del(input_event_source, _key_down_handler);
-
-             if (_key_up_handler)
-               e_input_event_handler_del(input_event_source, _key_up_handler);
-
-             _key_down_handler = NULL;
-             _key_up_handler = NULL;
-          }
-
         e_comp_ungrab_input(0, 1);
 
         if (context->kbd.keymap)
@@ -662,9 +636,7 @@ feed_key_event(const char *keyname, const char *key, const char *string, int key
    e->same_screen = 1;
    e->keycode = keycode;
 
-   E_Input_Event_Source *input_event_source = e_input_event_source_get();
-   if (input_event_source)
-     e_input_event_add(input_event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_keyevent_free, NULL);
+   ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_keyevent_free, NULL);
 }
 
 static void
@@ -1040,7 +1012,7 @@ _e_text_input_method_context_cb_resource_destroy(struct wl_resource *resource)
    free(context);
 }
 
-static gboolean
+static Eina_Bool
 _e_mod_ecore_key_down_cb(void *data, int type, void *event)
 {
    Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
@@ -1053,11 +1025,9 @@ _e_mod_ecore_key_down_cb(void *data, int type, void *event)
    if (g_disable_show_panel == EINA_TRUE)
      return ECORE_CALLBACK_PASS_ON;
 
-   E_Device *dev = (E_Device *)ev->dev;
-
    /* process remote controller key exceptionally */
-   if (e_device_class_get(dev) == ECORE_DEVICE_CLASS_KEYBOARD &&
-       e_device_subclass_get(dev) == ECORE_DEVICE_SUBCLASS_REMOCON)
+   if (ecore_device_class_get(ev->dev) == ECORE_DEVICE_CLASS_KEYBOARD &&
+       ecore_device_subclass_get(ev->dev) == ECORE_DEVICE_SUBCLASS_REMOCON)
      return ECORE_CALLBACK_PASS_ON;
 
    /* process up/down/left/right and some keys exceptionally */
@@ -1126,11 +1096,10 @@ _e_text_input_deactivate(E_Text_Input *text_input, E_Input_Method *input_method,
                }
           }
 
-        if (e_input_key_down_filter)
+        if (ecore_key_down_handler)
           {
-             E_Input_Event_Source *input_event_source = e_input_event_source_get();
-             e_input_event_filter_del(input_event_source, e_input_key_down_filter);
-             e_input_key_down_filter = NULL;
+             ecore_event_handler_del(ecore_key_down_handler);
+             ecore_key_down_handler = NULL;
           }
 
         LOGI("Resetting input_method->input : %p, text_input : %p, %p %p",
@@ -1222,9 +1191,10 @@ _e_text_input_cb_activate(struct wl_client *client, struct wl_resource *resource
 
    if (input_method->resource)
      {
-       E_Input_Event_Source *input_event_source = e_input_event_source_get();
-       if (!e_input_key_down_filter)
-         e_input_key_down_filter = e_input_event_filter_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_mod_ecore_key_down_cb, NULL);
+        if (!ecore_key_down_handler)
+          ecore_key_down_handler = ecore_event_handler_prepend(ECORE_EVENT_KEY_DOWN,
+                                                               _e_mod_ecore_key_down_cb,
+                                                               NULL);
 
         context = create_input_method_context(client, input_method);
         EINA_SAFETY_ON_NULL_GOTO(context, err);
@@ -1597,8 +1567,11 @@ _e_text_input_cb_input_panel_data_set(struct wl_client *client EINA_UNUSED, stru
    const char *szWillHideAck = "WILL_HIDE_ACK";
    if (strncmp(data, szWillHideAck, strlen(szWillHideAck)) == 0)
      {
-        _cancel_will_hide_timer();
-
+        if (g_timer_will_hide)
+          {
+             ecore_timer_del(g_timer_will_hide);
+             g_timer_will_hide = NULL;
+          }
         INF("WILL_HIDE_ACK_RECVED, %d", g_input_panel_state);
         if (g_input_panel_state == E_INPUT_PANEL_STATE_WILL_HIDE)
           {
@@ -2237,8 +2210,11 @@ _pol_cb_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
           LOGE("fail to remove surface\n");
 
         g_input_panel_state = E_INPUT_PANEL_STATE_DID_HIDE;
-        _cancel_will_hide_timer();
-
+        if (g_timer_will_hide)
+          {
+             ecore_timer_del(g_timer_will_hide);
+             g_timer_will_hide = NULL;
+          }
         client_surface_ec = NULL;
         LOGI("TRANSIENT_FOR::Reset transient_for_ec to NULL\n");
      }
@@ -2346,7 +2322,11 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
    E_FREE_LIST(handlers, ecore_event_handler_del);
    E_FREE_LIST(hooks_ec, e_client_hook_del);
 
-   _cancel_will_hide_timer();
+   if (g_timer_will_hide)
+     {
+        ecore_timer_del(g_timer_will_hide);
+        g_timer_will_hide = NULL;
+     }
 
    vconf_ignore_key_changed(VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, _keyboard_mode_changed_cb);