Implement auto capitalization feature in IMModule 68/92568/9
authorLi Zhang <li2012.zhang@samsung.com>
Mon, 17 Oct 2016 11:07:29 +0000 (19:07 +0800)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 28 Oct 2016 06:10:16 +0000 (15:10 +0900)
Change-Id: I6ac42815310c65c197b0dd7b4fc41f26bd7f778c

ism/extras/wayland_immodule/wayland_imcontext.c
ism/modules/panelagent/wayland/isf_wsc_context.h
ism/modules/panelagent/wayland/isf_wsc_control_ui.cpp
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp

index d34de16..210342c 100644 (file)
@@ -54,6 +54,7 @@
 #define MOD_Mod5_MASK       0x80
 
 #define VCONFKEY_AUTOPERIOD_ALLOW_BOOL  "file/private/isf/autoperiod_allow"
+#define VCONFKEY_AUTOCAPITAL_ALLOW_BOOL "file/private/isf/autocapital_allow"
 
 typedef enum {
     INPUT_LANG_URDU,
@@ -71,6 +72,7 @@ typedef enum {
     INPUT_LANG_CN_TW,
     INPUT_LANG_JAPANESE,
     INPUT_LANG_KHMER,
+    INPUT_LANG_KOREAN,
     INPUT_LANG_BURMESE,
     INPUT_LANG_OTHER
 } Input_Language;
@@ -110,31 +112,36 @@ static Ecore_Device         *_ime_device = NULL;
 
 static double                space_key_time               = 0.0;
 static Eina_Bool             autoperiod_allow             = EINA_FALSE;
+static Eina_Bool             autocap_allow                = EINA_FALSE;
+static Eina_Bool             hw_keyboard_mode             = EINA_FALSE;
+
 static Input_Language        input_lang                   = INPUT_LANG_OTHER;
 //
 
-typedef struct __Punctuations {
+typedef struct __LanguageInfo {
     const char *code;
     Input_Language lang;
     Eina_Unicode punc_code;
-} Punctuations;
-
-static Punctuations __punctuations [] = {
-    { "ur_PK",  INPUT_LANG_URDU,        0x06D4 },
-    { "hi_IN",  INPUT_LANG_HINDI,       0x0964 },
-    { "bn_IN",  INPUT_LANG_BENGALI_IN,  0x0964 },
-    { "bn_BD",  INPUT_LANG_BENGALI_BD,  0x0964 },
-    { "as_IN",  INPUT_LANG_ASSAMESE,    0x0964 },
-    { "pa_IN",  INPUT_LANG_PUNJABI,     0x0964 },
-    { "ne_NP",  INPUT_LANG_NEPALI,      0x0964 },
-    { "or_IN",  INPUT_LANG_ORIYA,       0x0964 },
-    { "mai_IN", INPUT_LANG_MAITHILI,    0x0964 },
-    { "hy_AM",  INPUT_LANG_ARMENIAN,    0x0589 },
-    { "zh_CN",  INPUT_LANG_CN,          0x3002 },
-    { "zh_HK",  INPUT_LANG_CN_HK,       0x3002 },
-    { "zh_TW",  INPUT_LANG_CN_TW,       0x3002 },
-    { "ja_JP",  INPUT_LANG_JAPANESE,    0x3002 },
-    { "km_KH",  INPUT_LANG_KHMER,       0x17D4 },
+    Eina_Bool auto_capital_valid;
+} LanguageInfo;
+
+static LanguageInfo __language_infos [] = {
+    { "ur_PK",  INPUT_LANG_URDU,        0x06D4, EINA_TRUE },
+    { "hi_IN",  INPUT_LANG_HINDI,       0x0964, EINA_FALSE },
+    { "bn_IN",  INPUT_LANG_BENGALI_IN,  0x0964, EINA_TRUE },
+    { "bn_BD",  INPUT_LANG_BENGALI_BD,  0x0964, EINA_TRUE },
+    { "as_IN",  INPUT_LANG_ASSAMESE,    0x0964, EINA_TRUE },
+    { "pa_IN",  INPUT_LANG_PUNJABI,     0x0964, EINA_TRUE },
+    { "ne_NP",  INPUT_LANG_NEPALI,      0x0964, EINA_TRUE },
+    { "or_IN",  INPUT_LANG_ORIYA,       0x0964, EINA_TRUE },
+    { "mai_IN", INPUT_LANG_MAITHILI,    0x0964, EINA_TRUE },
+    { "hy_AM",  INPUT_LANG_ARMENIAN,    0x0589, EINA_TRUE },
+    { "zh_CN",  INPUT_LANG_CN,          0x3002, EINA_FALSE },
+    { "zh_HK",  INPUT_LANG_CN_HK,       0x3002, EINA_FALSE },
+    { "zh_TW",  INPUT_LANG_CN_TW,       0x3002, EINA_FALSE },
+    { "ja_JP",  INPUT_LANG_JAPANESE,    0x3002, EINA_FALSE },
+    { "km_KH",  INPUT_LANG_KHMER,       0x17D4, EINA_TRUE },
+    { "ko_KR",  INPUT_LANG_KOREAN,      0x002E, EINA_FALSE },
 };
 
 struct _WaylandIMContext
@@ -247,12 +254,12 @@ get_input_language ()
     unsigned int i;
     char *input_lang_str = vconf_get_str (VCONFKEY_ISF_INPUT_LANGUAGE);
     if (!input_lang_str) return;
-
+    LOGD ("language %s", input_lang_str);
     input_lang = INPUT_LANG_OTHER;
 
-    for (i = 0; i < (sizeof (__punctuations) / sizeof (__punctuations[0])); i++) {
-        if (strcmp (input_lang_str, __punctuations[i].code) == 0) {
-            input_lang = __punctuations[i].lang;
+    for (i = 0; i < (sizeof (__language_infos) / sizeof (__language_infos[0])); i++) {
+        if (strcmp (input_lang_str, __language_infos[i].code) == 0) {
+            input_lang = __language_infos[i].lang;
             break;
         }
     }
@@ -265,6 +272,11 @@ static void autoperiod_allow_changed_cb (keynode_t *key, void* data)
     autoperiod_allow = vconf_keynode_get_bool (key);
 }
 
+static void autocapital_allow_changed_cb (keynode_t *key, void* data)
+{
+    autocap_allow = vconf_keynode_get_bool (key);
+}
+
 static void input_language_changed_cb (keynode_t *key, void* data)
 {
     get_input_language ();
@@ -360,7 +372,7 @@ autoperiod_insert (Ecore_IMF_Context *ctx)
             }
             else {
                 Eina_Unicode wbuf[2] = {0};
-                wbuf[0] = __punctuations[input_lang].punc_code;
+                wbuf[0] = __language_infos[input_lang].punc_code;
 
                 fullstop_mark = eina_unicode_unicode_to_utf8 (wbuf, NULL);
             }
@@ -381,6 +393,157 @@ done:
     space_key_time = ecore_time_get ();
 }
 
+static Eina_Bool
+check_except_autocapital (Eina_Unicode *ustr, int cursor_pos)
+{
+    const char *except_str[] = {"e.g.", "E.g."};
+    unsigned int i = 0, j = 0, len = 0;
+    for (i = 0; i < (sizeof (except_str) / sizeof (except_str[0])); i++) {
+        len = strlen (except_str[i]);
+        if (cursor_pos < (int)len)
+            continue;
+
+        for (j = len; j > 0; j--) {
+            if (ustr[cursor_pos-j] != except_str[i][len-j])
+                break;
+        }
+
+        if (j == 0) return EINA_TRUE;
+    }
+
+    return EINA_FALSE;
+}
+
+static Eina_Bool
+analyze_surrounding_text (Ecore_IMF_Context *ctx)
+{
+    char *plain_str = NULL;
+    Eina_Unicode puncs[] = {'\n','.', '!', '?', 0x00BF /* ¿ */, 0x00A1 /* ¡ */,
+                            0x3002 /* 。 */, 0x06D4 /* Urdu */, 0x0964 /* Hindi */,
+                            0x0589 /* Armenian */, 0x17D4 /* Khmer */, 0x104A /* Myanmar */};
+    Eina_Unicode *ustr = NULL;
+    Eina_Bool ret = EINA_FALSE;
+    Eina_Bool detect_space = EINA_FALSE;
+    int cursor_pos = 0;
+    int i = 0;
+    const int punc_num = sizeof (puncs) / sizeof (puncs[0]);
+    WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get (ctx);
+    if (!imcontext) return EINA_FALSE;
+
+    switch (ecore_imf_context_autocapital_type_get (ctx)) {
+        case ECORE_IMF_AUTOCAPITAL_TYPE_NONE:
+            return EINA_FALSE;
+        case ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER:
+            return EINA_TRUE;
+        default:
+            break;
+    }
+
+    if (imcontext->cursor_position == 0)
+        return EINA_TRUE;
+
+    if (imcontext->preedit_text && strcmp (imcontext->preedit_text, "") != 0)
+        return EINA_FALSE;
+
+    ecore_imf_context_surrounding_get (ctx, &plain_str, &cursor_pos);
+
+    if (!plain_str) goto done;
+
+    if (cursor_pos == 0) {
+        ret = EINA_TRUE;
+        goto done;
+    }
+
+    // Convert string from UTF-8 to unicode
+    ustr = eina_unicode_utf8_to_unicode (plain_str, NULL);
+    if (!ustr) goto done;
+
+    if (eina_unicode_strlen (ustr) < (size_t)cursor_pos) goto done;
+
+    if (cursor_pos >= 1) {
+        if (ecore_imf_context_autocapital_type_get (ctx) == ECORE_IMF_AUTOCAPITAL_TYPE_WORD) {
+            // Check space or no-break space
+            if (check_space_symbol (ustr[cursor_pos-1])) {
+                ret = EINA_TRUE;
+                goto done;
+            }
+        }
+
+        // Check paragraph separator <PS> or carriage return  <br>
+        if ((ustr[cursor_pos-1] == 0x2029) || (ustr[cursor_pos-1] == '\n')) {
+            ret = EINA_TRUE;
+            goto done;
+        }
+
+        for (i = cursor_pos; i > 0; i--) {
+            // Check space or no-break space
+            if (check_space_symbol (ustr[i-1])) {
+                detect_space = EINA_TRUE;
+                continue;
+            }
+
+            // Check punctuation and following the continuous space(s)
+            if (detect_space && check_symbol (ustr[i-1], puncs, punc_num)) {
+                if (check_except_autocapital (ustr, i))
+                    ret = EINA_FALSE;
+                else
+                    ret = EINA_TRUE;
+
+                goto done;
+            } else {
+                ret = EINA_FALSE;
+                goto done;
+            }
+        }
+
+        if ((i == 0) && (detect_space == EINA_TRUE)) {
+            // continuous space(s) without any character
+            ret = EINA_TRUE;
+            goto done;
+        }
+    }
+
+done:
+    if (ustr) free (ustr);
+    if (plain_str) free (plain_str);
+
+    return ret;
+}
+
+static void
+set_autocapital (Ecore_IMF_Context *ctx)
+{
+    Eina_Bool uppercase = EINA_FALSE;
+
+    WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get (ctx);
+    if (!imcontext || !imcontext->text_input) return;
+
+    if (hw_keyboard_mode) return;
+
+    if (input_lang != INPUT_LANG_OTHER && (!__language_infos[input_lang].auto_capital_valid))
+        return;
+
+    if (ecore_imf_context_input_panel_layout_get (ctx) != ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL)
+        return;
+
+    // Check autocapital type
+    if (ecore_imf_context_input_panel_caps_lock_mode_get (ctx)) {
+        uppercase = EINA_TRUE;
+    } else {
+        if (autocap_allow == EINA_FALSE)
+            return;
+
+        if (analyze_surrounding_text (ctx)) {
+            uppercase = EINA_TRUE;
+        } else {
+            uppercase = EINA_FALSE;
+        }
+    }
+
+    SECURE_LOGD ("ctx : %p, auto capital : %d\n", ctx, uppercase);
+    wl_text_input_set_capital_mode (imcontext->text_input, uppercase);
+}
+
 static Ecore_IMF_Context *
 get_using_ctx ()
 {
@@ -1386,6 +1549,8 @@ show_input_panel(Ecore_IMF_Context *ctx)
     if (imcontext->imdata_size > 0)
         wl_text_input_set_input_panel_data(imcontext->text_input, (const char *)imcontext->imdata, imcontext->imdata_size);
 
+    set_autocapital (ctx);
+
     SECURE_LOGD ("ctx : %p, layout : %d, layout variation : %d\n", ctx,
             layout, layout_variation);
     SECURE_LOGD ("language : %d, cursor position : %d\n",
@@ -2045,16 +2210,12 @@ static const struct wl_text_input_listener text_input_listener =
 static void
 keyboard_mode_changed_cb (keynode_t *key, void* data)
 {
-    int val;
+    hw_keyboard_mode = vconf_keynode_get_bool (key);
     Ecore_IMF_Context *active_ctx = get_using_ctx ();
-
-    if (vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &val) != 0)
-        return;
-
     if (active_ctx) {
-        LOGD ("ctx : %p, input detect : %d\n", active_ctx, val);
+        LOGD ("ctx : %p, input detect : %d\n", active_ctx, hw_keyboard_mode);
 
-        Ecore_IMF_Input_Panel_Keyboard_Mode input_mode = !val;
+        Ecore_IMF_Input_Panel_Keyboard_Mode input_mode = hw_keyboard_mode ? ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE : ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE;
         ecore_imf_context_input_panel_event_callback_call (active_ctx, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, input_mode);
 
         if ((input_mode == ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE) && _focused_ctx && (active_ctx == _focused_ctx)) {
@@ -2081,6 +2242,19 @@ EAPI void initialize ()
             autoperiod_allow = EINA_TRUE;
     }
 
+    /* get autocapital allow vconf value */
+    if (vconf_get_bool (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, &val) == 0) {
+        if (val == EINA_TRUE)
+            autocap_allow = EINA_TRUE;
+    }
+
+    /* get hardware keyboard input detected vconf value */
+    if (vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &val) == 0) {
+        if (val == EINA_TRUE)
+            hw_keyboard_mode = EINA_TRUE;
+    }
+
+    vconf_notify_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb, NULL);
     vconf_notify_key_changed (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, autoperiod_allow_changed_cb, NULL);
     vconf_notify_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb, NULL);
     vconf_notify_key_changed (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, keyboard_mode_changed_cb, NULL);
@@ -2104,6 +2278,7 @@ EAPI void uninitialize ()
 
 #ifdef HAVE_VCONF
     vconf_ignore_key_changed (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, autoperiod_allow_changed_cb);
+    vconf_ignore_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb);
     vconf_ignore_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb);
     vconf_ignore_key_changed (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, keyboard_mode_changed_cb);
 #endif
@@ -2348,6 +2523,7 @@ wayland_im_context_cursor_position_set (Ecore_IMF_Context *ctx,
         if (imcontext->input && imcontext->text_input) {
             LOGD ("ctx : %p, cursor pos : %d\n", ctx, cursor_pos);
             wl_text_input_set_cursor_position (imcontext->text_input, cursor_pos);
+            set_autocapital (ctx);
         }
     }
 }
index feaf48d..fe99fbf 100644 (file)
@@ -96,6 +96,7 @@ struct _WSCContextISF {
     uint32_t surrounding_cursor;
     uint32_t return_key_type;
     uint32_t bidi_direction;
+    uint32_t caps_mode;
 
     Eina_Bool return_key_disabled;
 
@@ -118,6 +119,7 @@ struct _WSCContextISF {
                        surrounding_cursor(0),
                        return_key_type(0),
                        bidi_direction(0),
+                       caps_mode(0),
                        return_key_disabled(EINA_FALSE),
                        impl(NULL),
                        id(0),
@@ -128,7 +130,6 @@ struct _WSCContextISF {
 
 void get_language(char **language);
 int get_panel_client_id ();
-Eina_Bool caps_mode_check (WSCContextISF *wsc_ctx, Eina_Bool force, Eina_Bool noti);
 
 WSCContextISF *get_focused_ic ();
 
index e9e9dc0..221922e 100644 (file)
@@ -139,7 +139,7 @@ void isf_wsc_context_input_panel_show (WSCContextISF* wsc_ctx)
     iseContext.return_key_disabled = wsc_ctx->return_key_disabled;
 
     /* set caps mode */
-    iseContext.caps_mode = caps_mode_check (wsc_ctx, EINA_TRUE, EINA_FALSE);
+    iseContext.caps_mode = wsc_ctx->caps_mode;
 
     /* set client window */
     iseContext.client_window = 0;
@@ -181,8 +181,6 @@ void isf_wsc_context_input_panel_show (WSCContextISF* wsc_ctx)
 
     free (packet);
 
-    caps_mode_check (wsc_ctx, EINA_TRUE, EINA_TRUE);
-
 #ifdef HAVE_VCONF
     vconf_set_int (VCONFKEY_ISF_INPUT_PANEL_STATE, VCONFKEY_ISF_INPUT_PANEL_STATE_SHOW);
 #endif
@@ -236,10 +234,7 @@ void isf_wsc_context_input_panel_caps_mode_set (WSCContextISF *ctx, unsigned int
 
 void isf_wsc_context_input_panel_caps_lock_mode_set (WSCContextISF *ctx, Eina_Bool mode)
 {
-    WSCContextISF *context_scim = ctx;
-
-    if (context_scim == get_focused_ic ())
-        caps_mode_check (ctx, EINA_TRUE, EINA_TRUE);
+    //FIXME: missing
 }
 
 void isf_wsc_context_input_panel_language_set (WSCContextISF *ctx, Ecore_IMF_Input_Panel_Lang language)
index f68e41f..1d17db3 100644 (file)
@@ -97,14 +97,11 @@ struct _WSCContextISFImpl {
     bool                     use_preedit;
     bool                     is_on;
     bool                     preedit_started;
-    bool                     preedit_updating;
     bool                     need_commit_preedit;
     bool                     init_remote_entry_metadata;
     bool                     init_remote_surrounding_text;
     bool                     block_input_resource;
     Input_Resource           input_resource;
-    int                      next_shift_status;
-    int                      shift_mode_enabled;
 
     WSCContextISFImpl        *next;
 
@@ -127,14 +124,11 @@ struct _WSCContextISFImpl {
                            use_preedit(true),
                            is_on(true),
                            preedit_started(false),
-                           preedit_updating(false),
                            need_commit_preedit(false),
                            init_remote_entry_metadata(true),
                            init_remote_surrounding_text(true),
                            block_input_resource(false),
                            input_resource(INPUT_RESOURCE_NONE),
-                           next_shift_status(0),
-                           shift_mode_enabled(0),
                            next(NULL)
     {
     }
@@ -203,18 +197,10 @@ static bool                                             _on_the_spot
 static bool                                             _change_keyboard_mode_by_focus_move = false;
 static bool                                             _support_hw_keyboard_mode   = false;
 
-static Eina_Bool                                        autocap_allow               = EINA_FALSE;
-
 static bool                                             _x_key_event_is_valid       = false;
 
 static Ecore_Timer                                     *_resource_check_timer       = NULL;
 
-//FIXME: remove this definitions
-#define SHIFT_MODE_OFF  0xffe1
-#define SHIFT_MODE_ON   0xffe2
-#define SHIFT_MODE_LOCK 0xffe6
-#define SHIFT_MODE_ENABLE 0x9fe7
-#define SHIFT_MODE_DISABLE 0x9fe8
 
 #define WAYLAND_MODULE_CLIENT_ID (0)
 
@@ -270,8 +256,6 @@ _wsc_im_ctx_content_type (void *data, struct wl_input_method_context *im_ctx, ui
 
     isf_wsc_context_input_panel_language_set (wsc_ctx, wsc_context_input_panel_language_get (wsc_ctx));
 
-    caps_mode_check (wsc_ctx, EINA_TRUE, EINA_TRUE);
-
     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));
 
@@ -389,7 +373,6 @@ _wsc_im_ctx_cursor_position (void *data, struct wl_input_method_context *im_ctx,
     if (!wsc_ctx || !wsc_ctx->impl) return;
     wsc_ctx->impl->cursor_pos = cursor_pos;
     wsc_ctx->surrounding_cursor = cursor_pos;
-    caps_mode_check (wsc_ctx, EINA_FALSE, EINA_TRUE);
     g_info_manager->socket_update_cursor_position (cursor_pos);
 
 #if ENABLE_REMOTE_INPUT
@@ -420,6 +403,16 @@ _wsc_im_ctx_filter_key_event (void *data, struct wl_input_method_context *im_ctx
 #endif
 }
 
+static void
+_wsc_im_ctx_captial_mode (void *data, struct wl_input_method_context *im_ctx, uint32_t mode)
+{
+    LOGD ("capital mode %d", mode);
+    WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+    if (!wsc_ctx) return;
+    wsc_ctx->caps_mode = mode;
+    isf_wsc_context_input_panel_caps_mode_set (wsc_ctx, mode);
+}
+
 static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_reset,
      _wsc_im_ctx_content_type,
@@ -432,7 +425,9 @@ static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_bidi_direction,
      _wsc_im_ctx_cursor_position,
      _wsc_im_ctx_process_input_device_event,
-     _wsc_im_ctx_filter_key_event
+     _wsc_im_ctx_filter_key_event,
+     NULL,
+     _wsc_im_ctx_captial_mode
 };
 
 #if ENABLE_GRAB_KEYBOARD
@@ -930,202 +925,6 @@ check_valid_ic (WSCContextISF * ic)
         return false;
 }
 
-static Eina_Bool
-check_symbol (Eina_Unicode ucode, Eina_Unicode symbols[], int symbol_num)
-{
-    for (int i = 0; i < symbol_num; i++) {
-        // Check symbol
-        if (ucode == symbols[i])
-            return EINA_TRUE;
-    }
-
-    return EINA_FALSE;
-}
-
-static Eina_Bool
-check_except_autocapital (Eina_Unicode *ustr, int cursor_pos)
-{
-    const char *except_str[] = {"e.g.", "E.g."};
-    unsigned int i = 0, j = 0, len = 0;
-    for (i = 0; i < (sizeof (except_str) / sizeof (except_str[0])); i++) {
-        len = strlen (except_str[i]);
-        if (cursor_pos < (int)len)
-            continue;
-
-        for (j = len; j > 0; j--) {
-            if (ustr[cursor_pos-j] != except_str[i][len-j])
-                break;
-        }
-
-        if (j == 0) return EINA_TRUE;
-    }
-
-    return EINA_FALSE;
-}
-
-static Eina_Bool
-check_space_symbol (Eina_Unicode uchar)
-{
-    Eina_Unicode space_symbols[] = {' ', 0x00A0 /* no-break space */, 0x3000 /* ideographic space */};
-    const int symbol_num = sizeof (space_symbols) / sizeof (space_symbols[0]);
-
-    return check_symbol (uchar, space_symbols, symbol_num);
-}
-
-static Eina_Bool
-analyze_surrounding_text (WSCContextISF *wsc_ctx)
-{
-    char *plain_str = NULL;
-    Eina_Unicode puncs[] = {'\n','.', '!', '?', 0x00BF /* ¿ */, 0x00A1 /* ¡ */,
-                            0x3002 /* 。 */, 0x06D4 /* Urdu */, 0x0964 /* Hindi */,
-                            0x0589 /* Armenian */, 0x17D4 /* Khmer */, 0x104A /* Myanmar */};
-    Eina_Unicode *ustr = NULL;
-    Eina_Bool ret = EINA_FALSE;
-    Eina_Bool detect_space = EINA_FALSE;
-    int cursor_pos = 0;
-    int i = 0;
-    const int punc_num = sizeof (puncs) / sizeof (puncs[0]);
-    WSCContextISF *context_scim;
-
-    if (!wsc_ctx) return EINA_FALSE;
-    context_scim = wsc_ctx;
-    if (!context_scim || !context_scim->impl) return EINA_FALSE;
-
-    switch (context_scim->impl->autocapital_type) {
-        case ECORE_IMF_AUTOCAPITAL_TYPE_NONE:
-            return EINA_FALSE;
-        case ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER:
-            return EINA_TRUE;
-        default:
-            break;
-    }
-
-    if (context_scim->impl->cursor_pos == 0)
-        return EINA_TRUE;
-
-    if (context_scim->impl->preedit_updating)
-        return EINA_FALSE;
-
-    wsc_context_surrounding_get (wsc_ctx, &plain_str, &cursor_pos);
-    if (!plain_str) goto done;
-
-    if (cursor_pos == 0) {
-        ret = EINA_TRUE;
-        goto done;
-    }
-
-    // Convert string from UTF-8 to unicode
-    ustr = eina_unicode_utf8_to_unicode (plain_str, NULL);
-    if (!ustr) goto done;
-
-    if (eina_unicode_strlen (ustr) < (size_t)cursor_pos) goto done;
-
-    if (cursor_pos >= 1) {
-        if (context_scim->impl->autocapital_type == ECORE_IMF_AUTOCAPITAL_TYPE_WORD) {
-            // Check space or no-break space
-            if (check_space_symbol (ustr[cursor_pos-1])) {
-                ret = EINA_TRUE;
-                goto done;
-            }
-        }
-
-        // Check paragraph separator <PS> or carriage return  <br>
-        if ((ustr[cursor_pos-1] == 0x2029) || (ustr[cursor_pos-1] == '\n')) {
-            ret = EINA_TRUE;
-            goto done;
-        }
-
-        for (i = cursor_pos; i > 0; i--) {
-            // Check space or no-break space
-            if (check_space_symbol (ustr[i-1])) {
-                detect_space = EINA_TRUE;
-                continue;
-            }
-
-            // Check punctuation and following the continuous space(s)
-            if (detect_space && check_symbol (ustr[i-1], puncs, punc_num)) {
-                if (check_except_autocapital (ustr, i))
-                    ret = EINA_FALSE;
-                else
-                    ret = EINA_TRUE;
-
-                goto done;
-            } else {
-                ret = EINA_FALSE;
-                goto done;
-            }
-        }
-
-        if ((i == 0) && (detect_space == EINA_TRUE)) {
-            // continuous space(s) without any character
-            ret = EINA_TRUE;
-            goto done;
-        }
-    }
-
-done:
-    if (ustr) free (ustr);
-    if (plain_str) free (plain_str);
-
-    return ret;
-}
-
-Eina_Bool
-caps_mode_check (WSCContextISF *wsc_ctx, Eina_Bool force, Eina_Bool noti)
-{
-    Eina_Bool uppercase;
-    WSCContextISF *context_scim;
-
-    if (get_keyboard_mode () == TOOLBAR_KEYBOARD_MODE) return EINA_FALSE;
-
-    if (!wsc_ctx) return EINA_FALSE;
-    context_scim = wsc_ctx;
-
-    if (!context_scim || !context_scim->impl)
-        return EINA_FALSE;
-
-    if (context_scim->impl->next_shift_status == SHIFT_MODE_LOCK) return EINA_TRUE;
-
-    Ecore_IMF_Input_Panel_Layout layout = wsc_context_input_panel_layout_get (wsc_ctx);
-    if (layout != ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL)
-        return EINA_FALSE;
-
-    // Check autocapital type
-    if (wsc_context_input_panel_caps_lock_mode_get (wsc_ctx)) {
-        uppercase = EINA_TRUE;
-    } else {
-        if (autocap_allow == EINA_FALSE)
-            return EINA_FALSE;
-
-        if (analyze_surrounding_text (wsc_ctx)) {
-            uppercase = EINA_TRUE;
-        } else {
-            uppercase = EINA_FALSE;
-        }
-    }
-
-    if (force) {
-        context_scim->impl->next_shift_status = uppercase ? SHIFT_MODE_ON : SHIFT_MODE_OFF;
-        if (noti)
-            isf_wsc_context_input_panel_caps_mode_set (wsc_ctx, uppercase);
-    } else {
-        if (context_scim->impl->next_shift_status != (uppercase ? SHIFT_MODE_ON : SHIFT_MODE_OFF)) {
-            context_scim->impl->next_shift_status = uppercase ? SHIFT_MODE_ON : SHIFT_MODE_OFF;
-            if (noti)
-                isf_wsc_context_input_panel_caps_mode_set (wsc_ctx, uppercase);
-        }
-    }
-
-    return uppercase;
-}
-
-static void autocapital_allow_changed_cb (keynode_t *key, void* data)
-{
-    SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n";
-
-    autocap_allow = vconf_keynode_get_bool (key);
-}
-
 void context_scim_imdata_get (WSCContextISF *wsc_ctx, void* data, int* length)
 {
     WSCContextISF* context_scim = wsc_ctx;
@@ -1205,7 +1004,6 @@ isf_wsc_context_init (void)
 {
     SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
     LOGD ("");
-    int val;
 
     if (!_scim_initialized) {
         ecore_wl_init (NULL);
@@ -1213,14 +1011,6 @@ isf_wsc_context_init (void)
         _scim_initialized = true;
         isf_wsc_input_panel_init ();
         //isf_wsc_context_set_hardware_keyboard_mode(context_scim);
-
-        /* get autocapital allow vconf value */
-        if (vconf_get_bool (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, &val) == 0) {
-            if (val == EINA_TRUE)
-                autocap_allow = EINA_TRUE;
-        }
-
-        vconf_notify_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb, NULL);
     }
 }
 
@@ -1233,8 +1023,6 @@ isf_wsc_context_shutdown (void)
     if (_scim_initialized) {
         _scim_initialized = false;
 
-        vconf_ignore_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb);
-
         isf_wsc_input_panel_shutdown ();
         finalize ();
         ecore_wl_shutdown ();
@@ -1271,7 +1059,6 @@ isf_wsc_context_add (WSCContextISF *wsc_ctx)
     context_scim->impl->is_on               = true;
     context_scim->impl->use_preedit         = _on_the_spot;
     context_scim->impl->preedit_started     = false;
-    context_scim->impl->preedit_updating    = false;
     context_scim->impl->need_commit_preedit = false;
 
     if (!_ic_list)
@@ -1446,18 +1233,6 @@ isf_wsc_context_focus_in (WSCContextISF *wsc_ctx)
         context_scim->impl->init_remote_surrounding_text = false;
         context_scim->impl->block_input_resource = false;
         context_scim->impl->input_resource = INPUT_RESOURCE_NONE;
-
-        /* At the moment we received focus_in, our surrounding text has not been updated yet -
-        which means it will always turn Shift key on, resulting the whole keyboard blinking.
-        This is only a temporary solution - the caps_mode_check() needs be executed on
-        client application side. The code below, will still be needed when we implement the
-        auto capitalization logic on immodule, so just commenting out */
-        /*
-        if (caps_mode_check (wsc_ctx, EINA_FALSE, EINA_TRUE) == EINA_FALSE) {
-            context_scim->impl->next_shift_status = 0;
-        }
-
-        */
     }
 
     LOGD ("ctx : %p\n", wsc_ctx);
@@ -2571,11 +2346,6 @@ panel_slot_update_preedit_string (int context, const WideString str, const Attri
                 else
                     ic->impl->preedit_caret    = str.length ();
 
-                ic->impl->preedit_updating = true;
-
-                if (check_valid_ic (ic))
-                    ic->impl->preedit_updating = false;
-
                 wsc_context_send_preedit_string (ic);
             } else {
                 String _str = utf8_wcstombs (str);
@@ -2999,9 +2769,6 @@ public:
                     ic->impl->preedit_caret    = caret;
                 else
                     ic->impl->preedit_caret    = preedit.length ();
-                ic->impl->preedit_updating = true;
-                if (check_valid_ic (ic))
-                    ic->impl->preedit_updating = false;
                 wsc_context_send_preedit_string (ic);
             } else {
                 String _str = utf8_wcstombs (preedit);