Reduce the number of slot_*** signal calls in IME 49/120449/4
authorSungmin Kwak <sungmin.kwak@samsung.com>
Thu, 23 Mar 2017 02:45:29 +0000 (11:45 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 27 Mar 2017 01:06:48 +0000 (18:06 -0700)
Change-Id: Id9ca9fe7bb0db81d1a402c47f62791b65837555d

ism/modules/panelagent/wayland/isf_wsc_control_ui.cpp
ism/modules/panelagent/wayland/isf_wsc_control_ui.h
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp

index d92a692..221922e 100644 (file)
@@ -52,7 +52,6 @@ using namespace scim;
 static TOOLBAR_MODE_T     kbd_mode = TOOLBAR_HELPER_MODE;
 WSCContextISF            *input_panel_ctx = NULL;
 static bool               _support_hw_keyboard_mode = false;
-static Ecore_IMF_Input_Panel_Layout _prev_input_panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
 
 static int _get_context_id (WSCContextISF *ctx)
 {
@@ -209,16 +208,12 @@ void isf_wsc_context_set_keyboard_mode (WSCContextISF *ctx, TOOLBAR_MODE_T mode)
 }
 
 void
-isf_wsc_context_input_panel_layout_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Layout layout, Eina_Bool ctx_changed)
+isf_wsc_context_input_panel_layout_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Layout layout)
 {
     WSCContextISF *context_scim = ctx;
 
     if (context_scim == get_focused_ic ()) {
-        if (!ctx_changed && _prev_input_panel_layout == layout)
-            return;
-
         LOGD ("layout type : %d\n", layout);
-        _prev_input_panel_layout = layout;
         _isf_wsc_context_input_panel_layout_set (_get_context_id (ctx), layout);
     }
 }
index 38d2c4f..4145eea 100644 (file)
@@ -44,7 +44,7 @@ extern "C"
     void isf_wsc_context_input_panel_show (WSCContextISF *ctx);
     void isf_wsc_context_input_panel_hide (WSCContextISF *ctx);
     void isf_wsc_context_input_panel_language_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Lang lang);
-    void isf_wsc_context_input_panel_layout_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Layout layout, Eina_Bool ctx_changed);
+    void isf_wsc_context_input_panel_layout_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Layout layout);
     Ecore_IMF_Input_Panel_Layout isf_wsc_context_input_panel_layout_get (WSCContextISF *ctx);
     void isf_wsc_context_input_panel_caps_mode_set (WSCContextISF *ctx, unsigned int mode);
     void isf_wsc_context_input_panel_caps_lock_mode_set (WSCContextISF *ctx, Eina_Bool mode);
index 3e091f0..59befec 100644 (file)
@@ -195,7 +195,6 @@ static int                                              _valid_key_mask
 static ConfigPointer                                    _config;
 
 static WSCContextISF                                   *_focused_ic                 = 0;
-static WSCContextISF                                   *_prev_layout_set_ic         = 0;
 
 static bool                                             _scim_initialized           = false;
 
@@ -257,26 +256,48 @@ _wsc_im_ctx_reset (void *data, struct wl_input_method_context *im_ctx)
 static void
 _wsc_im_ctx_content_type (void *data, struct wl_input_method_context *im_ctx, uint32_t hint, uint32_t purpose)
 {
-    Eina_Bool ctx_changed = EINA_FALSE;
     WSCContextISF *wsc_ctx = (WSCContextISF*)data;
     if (!wsc_ctx) return;
 
-    LOGD ("im_context = %p hint = %d purpose = %d\n", im_ctx, hint, purpose);
+    LOGD ("im_context = %p hint = %04x purpose = %d\n", im_ctx, hint, purpose);
 
-    wsc_ctx->content_hint = hint;
-    wsc_ctx->content_purpose = purpose;
+    // Set layout
+    if (wsc_ctx->content_purpose != purpose) {
+        wsc_ctx->content_purpose = purpose;
+        isf_wsc_context_input_panel_layout_set (wsc_ctx, wsc_context_input_panel_layout_get (wsc_ctx));
+    }
+
+    if (wsc_ctx->content_hint != hint) {
+        uint32_t hint_copy, old_hintbit, new_hintbit;
+        const uint32_t autocap_type = WL_TEXT_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION |
+                                      WL_TEXT_INPUT_CONTENT_HINT_UPPERCASE |
+                                      WL_TEXT_INPUT_CONTENT_HINT_WORD_CAPITALIZATION;
 
-    ctx_changed = (_prev_layout_set_ic == wsc_ctx ? EINA_FALSE : EINA_TRUE);
-    isf_wsc_context_input_panel_layout_set (wsc_ctx,
-                                            wsc_context_input_panel_layout_get (wsc_ctx), ctx_changed);
-    _prev_layout_set_ic = wsc_ctx;
+        hint_copy = wsc_ctx->content_hint;
+        wsc_ctx->content_hint = hint;
 
-    g_info_manager->set_prediction_allow (WAYLAND_MODULE_CLIENT_ID,
-                                          wsc_context_prediction_allow_get (wsc_ctx));
+        // Set prediction allow
+        old_hintbit = hint_copy & WL_TEXT_INPUT_CONTENT_HINT_AUTO_COMPLETION;
+        new_hintbit = hint & WL_TEXT_INPUT_CONTENT_HINT_AUTO_COMPLETION;
+        if (old_hintbit != new_hintbit) {
+            g_info_manager->set_prediction_allow (WAYLAND_MODULE_CLIENT_ID, wsc_context_prediction_allow_get (wsc_ctx));
+        }
 
-    isf_wsc_context_autocapital_type_set (wsc_ctx, wsc_context_autocapital_type_get (wsc_ctx));
+        // Set autocapital type
+        old_hintbit = hint_copy & autocap_type;
+        new_hintbit = hint & autocap_type;
+        if (old_hintbit != new_hintbit) {
+            isf_wsc_context_autocapital_type_set (wsc_ctx, wsc_context_autocapital_type_get (wsc_ctx));
+        }
+
+        // Set language
+        old_hintbit = hint_copy & WL_TEXT_INPUT_CONTENT_HINT_LATIN;
+        new_hintbit = hint & WL_TEXT_INPUT_CONTENT_HINT_LATIN;
+        if (old_hintbit != new_hintbit) {
+            isf_wsc_context_input_panel_language_set (wsc_ctx, wsc_context_input_panel_language_get (wsc_ctx));
+        }
+    }
 
-    isf_wsc_context_input_panel_language_set (wsc_ctx, wsc_context_input_panel_language_get (wsc_ctx));
 #if ENABLE_REMOTE_INPUT
     isf_wsc_context_send_entry_metadata (wsc_ctx, wsc_context_input_hint_get (wsc_ctx), wsc_context_input_panel_layout_get (wsc_ctx),
         wsc_context_input_panel_layout_variation_get (wsc_ctx), wsc_context_autocapital_type_get (wsc_ctx), wsc_ctx->return_key_disabled);