Register EVAS_CALLBACK_CANVAS_FOCUS_IN when set_focus fails 64/167864/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 22 Jan 2018 11:31:30 +0000 (20:31 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 22 Jan 2018 23:13:36 +0000 (23:13 +0000)
Change-Id: I592ce087d3fd6beb6975feb3a02a2c77741cf018

ism/extras/wayland_immodule/wayland_imcontext.c

index 35bbbbb..fd34f82 100644 (file)
@@ -117,6 +117,7 @@ static Ecore_IMF_Context    *_show_req_ctx               = NULL;
 static Ecore_IMF_Context    *_hide_req_ctx               = NULL;
 static Ecore_IMF_Context    *_focus_req_ctx              = NULL;
 static Ecore_IMF_Context    *_input_panel_ctx            = NULL;
+static Eina_Bool             _focus_req_only             = EINA_TRUE;
 
 static Eina_Rectangle        _keyboard_geometry = {0, 0, 0, 0};
 
@@ -1581,16 +1582,19 @@ get_purpose(Ecore_IMF_Context *ctx)
 
 static void _canvas_focus_in_cb(void *data, Evas *e, void *event_info)
 {
-    LOGD("ctx : %p", _focus_req_ctx);
+    LOGD("ctx : %p %d", _focus_req_ctx, _focus_req_only);
 
     if (_focus_req_ctx) {
         set_focus(_focus_req_ctx);
-        show_input_panel(_focus_req_ctx);
+        if (ecore_imf_context_input_panel_enabled_get (_focus_req_ctx) || !_focus_req_only)
+            if (!ecore_imf_context_input_panel_show_on_demand_get (_focus_req_ctx) || !_focus_req_only)
+                show_input_panel (_focus_req_ctx);
 
         WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(_focus_req_ctx);
         if (imcontext && imcontext->canvas)
             evas_event_callback_del(imcontext->canvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb);
         _focus_req_ctx = NULL;
+        _focus_req_only = EINA_TRUE;
     }
 }
 
@@ -1609,6 +1613,7 @@ show_input_panel(Ecore_IMF_Context *ctx)
         set_focus(ctx);
         if (!imcontext->input) {
             _focus_req_ctx = ctx;
+            _focus_req_only = EINA_FALSE;
             if (imcontext->canvas) {
                 evas_event_callback_del(imcontext->canvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb);
                 evas_event_callback_add(imcontext->canvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb, NULL);
@@ -2705,6 +2710,7 @@ wayland_im_context_del (Ecore_IMF_Context *ctx)
             evas_event_callback_del(imcontext->canvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb);
 
         _focus_req_ctx = NULL;
+        _focus_req_only = EINA_TRUE;
     }
     //
 
@@ -2799,6 +2805,16 @@ wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
 #endif
 
     if (!set_focus(ctx)) {
+        WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
+        if (imcontext && !imcontext->input) {
+            if (_focus_req_ctx != ctx)
+                _focus_req_only = EINA_TRUE;
+            _focus_req_ctx = ctx;
+            if (imcontext->canvas) {
+                evas_event_callback_del(imcontext->canvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb);
+                evas_event_callback_add(imcontext->canvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb, NULL);
+            }
+        }
         LOGW("ctx : %p. Fail to set focus!", ctx);
         return;
     }
@@ -2846,8 +2862,10 @@ wayland_im_context_focus_out(Ecore_IMF_Context *ctx)
 
     LOGD("ctx : %p", ctx);
 
-    if (_focus_req_ctx == ctx)
+    if (_focus_req_ctx == ctx) {
         _focus_req_ctx = NULL;
+        _focus_req_only = EINA_TRUE;
+    }
 
     if (!imcontext || !imcontext->input) return;