Add timer for checking ready_set retrieval 77/171277/3
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 28 Feb 2018 06:05:27 +0000 (15:05 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 6 Mar 2018 05:10:28 +0000 (14:10 +0900)
Change-Id: Ie18aa26c228d9a65b0dbdec1e3e018be7a9731a3

src/e_mod_input_panel.c

index 9afcdc7..45e784e 100644 (file)
@@ -4,6 +4,7 @@
 #include <input-method-server-protocol.h>
 
 #define WTI_WARNING(resource, code, msg)     (_e_input_panel_log_show((resource), (code), (msg), __func__))
+#define WAIT_UPDATE_TIMER_INTERVAL 2.0f
 
 typedef struct _E_Input_Panel E_Input_Panel;
 typedef struct _E_Input_Panel_Surface E_Input_Panel_Surface;
@@ -67,6 +68,7 @@ E_Input_Panel *g_input_panel = NULL;
 E_Input_Panel_Floating_Info *g_floating_info = NULL;
 Eina_List *handlers = NULL;
 static Eina_Bool panel_show_need_rerun = EINA_FALSE;
+static Ecore_Timer *g_timer_wait_update  = NULL;
 
 static void
 _e_input_panel_log_show(struct wl_resource *resource, uint32_t code, const char *msg, const char *warning_msg)
@@ -154,25 +156,37 @@ _e_input_panel_surface_cb_overlay_panel_set(struct wl_client *client EINA_UNUSED
 }
 
 static void
-_e_input_panel_surface_cb_ready_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t state EINA_UNUSED)
+_e_input_panel_surface_show(E_Input_Panel_Surface *ips)
 {
-   E_Input_Panel_Surface *ips = wl_resource_get_user_data(resource);
+   Eina_List *l = NULL;
+   E_Input_Panel_Surface *surface = NULL;
    E_Client *focused_ec = NULL;
 
    if (!g_input_panel) return;
 
+   /* When NULL passed, find the most appropriate surface */
    if (!ips)
      {
-        WTI_WARNING(resource,
-                    WL_DISPLAY_ERROR_INVALID_OBJECT,
-                    "No Input Panel Surface For Surface");
-        return;
+        EINA_LIST_FOREACH(g_input_panel->surfaces, l, surface)
+          {
+             if (surface && surface->ec)
+               {
+                  if (surface->ec->parent == e_client_focused_get())
+                    {
+                       ips = surface;
+                    }
+               }
+          }
      }
 
+   if (!ips) return;
+
+   LOGD("parent:%p, focus:%p, wait_update %d\n",
+        ips->ec ? ips->ec->parent : NULL, e_client_focused_get(), g_input_panel->wait_update);
+
    if (g_input_panel->wait_update)
      {
         focused_ec = e_client_focused_get();
-        LOGD("IPS::SHOW::READY (parent:%p, focus:%p)\n", ips->ec ? ips->ec->parent:NULL, focused_ec);
         e_input_panel_wait_update_set(EINA_FALSE);
         if (ips->ec->parent)
           {
@@ -191,6 +205,48 @@ _e_input_panel_surface_cb_ready_set(struct wl_client *client EINA_UNUSED, struct
      }
 }
 
+static void _wait_update_timer_del()
+{
+   if (g_timer_wait_update)
+     {
+        LOGD("deleting wait_update timer");
+        ecore_timer_del(g_timer_wait_update);
+        g_timer_wait_update = NULL;
+     }
+}
+
+static Eina_Bool
+_wait_update_timer_handler(void *data)
+{
+   LOGE("TIMED OUT while waiting for ready_set");
+
+   _e_input_panel_surface_show(NULL);
+
+   g_timer_wait_update = NULL;
+
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_e_input_panel_surface_cb_ready_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t state EINA_UNUSED)
+{
+   E_Input_Panel_Surface *ips = wl_resource_get_user_data(resource);
+
+   if (!g_input_panel) return;
+
+   if (!ips)
+     {
+        WTI_WARNING(resource,
+                    WL_DISPLAY_ERROR_INVALID_OBJECT,
+                    "No Input Panel Surface For Surface");
+        return;
+     }
+
+   LOGD("IPS::SHOW::READY\n");
+
+   _e_input_panel_surface_show(ips);
+}
+
 static void
  _e_input_panel_surface_cb_floating_panel_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t state)
 {
@@ -946,6 +1002,8 @@ e_input_panel_visibility_change(Eina_Bool visible)
         ips->showing = visible;
         _e_input_panel_surface_visible_update(ips);
      }
+
+   if (!visible) _wait_update_timer_del();
 }
 
 Eina_Bool
@@ -1136,6 +1194,11 @@ e_input_panel_wait_update_set(Eina_Bool wait_update)
    /* If we are in wait_update mode, the input panel surfaces have to be updated forcibly */
    if (wait_update)
      {
+        LOGD("Registering wait_update_timer");
+        _wait_update_timer_del();
+        g_timer_wait_update = ecore_timer_add(WAIT_UPDATE_TIMER_INTERVAL,
+                                              _wait_update_timer_handler, NULL);
+
         EINA_LIST_FOREACH(g_input_panel->surfaces, l, ips)
           {
              if (!ips->ec) continue;