jihoon pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4b777ec1845c731285f842ec75aa464e5c2e3096

commit 4b777ec1845c731285f842ec75aa464e5c2e3096
Author: Haifeng Deng <haifeng.d...@samsung.com>
Date:   Tue Nov 24 17:30:14 2015 +0800

    ecore_imf/wayland: Fix IME hide -> show issue in case of focus-out and then 
focus-in
    
    Change-Id: I1d3d7023dbd10b78f510380ff3c46087228f9180
---
 AUTHORS                                           |  1 +
 src/modules/ecore_imf/wayland/wayland_imcontext.c | 62 ++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 0ee154e..a3b0e1e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -460,3 +460,4 @@ Viacheslav Lvov <v.l...@samsung.com>
 Vitaliy Venzak <v.ven...@samsung.com>
 perepelits.m <perepelit...@samsung.com>
 rustyBSD <rusty...@gmx.fr>
+Haifeng Deng <haifeng.d...@samsung.com>
diff --git a/src/modules/ecore_imf/wayland/wayland_imcontext.c 
b/src/modules/ecore_imf/wayland/wayland_imcontext.c
index f2a2dce..cecd275 100644
--- a/src/modules/ecore_imf/wayland/wayland_imcontext.c
+++ b/src/modules/ecore_imf/wayland/wayland_imcontext.c
@@ -31,6 +31,11 @@
 
 #include "wayland_imcontext.h"
 
+#define HIDE_TIMER_INTERVAL     0.05
+
+static Eina_Bool _clear_hide_timer();
+static Ecore_Timer *_hide_timer  = NULL;
+
 struct _WaylandIMContext
 {
    Ecore_IMF_Context *ctx;
@@ -137,6 +142,55 @@ update_state(WaylandIMContext *imcontext)
 
         wl_text_input_commit_state(imcontext->text_input, ++imcontext->serial);
      }
+
+   _clear_hide_timer();
+}
+
+static Eina_Bool _clear_hide_timer()
+{
+   if (_hide_timer)
+     {
+        ecore_timer_del(_hide_timer);
+        _hide_timer = NULL;
+        return EINA_TRUE;
+     }
+
+   return EINA_FALSE;
+}
+
+static void _send_input_panel_hide_request(Ecore_IMF_Context *ctx)
+{
+   WaylandIMContext *imcontext = (WaylandIMContext 
*)ecore_imf_context_data_get(ctx);
+   if (imcontext && imcontext->text_input)
+     wl_text_input_hide_input_panel(imcontext->text_input);
+}
+
+static Eina_Bool _hide_timer_handler(void *data)
+{
+   Ecore_IMF_Context *ctx = (Ecore_IMF_Context *)data;
+   _send_input_panel_hide_request(ctx);
+
+   _hide_timer = NULL;
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void _input_panel_hide_timer_start(void *data)
+{
+   if (!_hide_timer)
+     _hide_timer = ecore_timer_add(HIDE_TIMER_INTERVAL, _hide_timer_handler, 
data);
+}
+
+static void _input_panel_hide(Ecore_IMF_Context *ctx, Eina_Bool instant)
+{
+   if (instant || (_hide_timer && ecore_timer_pending_get(_hide_timer) <= 0.0))
+     {
+        _clear_hide_timer();
+        _send_input_panel_hide_request(ctx);
+     }
+   else
+     {
+        _input_panel_hide_timer_start(ctx);
+     }
 }
 
 static Eina_Bool
@@ -311,6 +365,7 @@ show_input_panel(Ecore_IMF_Context *ctx)
 
    if (ecore_imf_context_input_panel_enabled_get(ctx))
      {
+        _clear_hide_timer();
         wl_text_input_show_input_panel(imcontext->text_input);
         wl_text_input_activate(imcontext->text_input, seat,
                                
ecore_wl2_window_surface_get(imcontext->window));
@@ -715,7 +770,7 @@ wayland_im_context_focus_out(Ecore_IMF_Context *ctx)
    if (imcontext->text_input)
      {
         if (ecore_imf_context_input_panel_enabled_get(ctx))
-          wl_text_input_hide_input_panel(imcontext->text_input);
+          _input_panel_hide(ctx, EINA_FALSE);
 
         wl_text_input_deactivate(imcontext->text_input,
                                  ecore_wl2_input_seat_get(imcontext->input));
@@ -828,7 +883,10 @@ wayland_im_context_show(Ecore_IMF_Context *ctx)
    EINA_LOG_DOM_INFO(_ecore_imf_wayland_log_dom, "context_show");
 
    if (imcontext->text_input)
-     wl_text_input_show_input_panel(imcontext->text_input);
+     {
+        _clear_hide_timer();
+        wl_text_input_show_input_panel(imcontext->text_input);
+     }
 }
 
 EAPI void

-- 


Reply via email to