Fixed the bug that unwanted input mode reset occurs 67/100867/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 29 Nov 2016 11:42:14 +0000 (20:42 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 29 Nov 2016 11:46:15 +0000 (20:46 +0900)
Change-Id: I34077956ff84949add51396e44828f60428e1dfd

src/ise.cpp

index f4bb828..57702d3 100644 (file)
@@ -735,11 +735,6 @@ void CCoreEventCallback::on_process_input_device_event(sclu32 &type, sclchar *da
                 *ret = 1;
             }
         }
-        if (g_keyboard_state.layout == ISE_LAYOUT_STYLE_VOICE) {
-            ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
-        } else {
-            ise_hide_stt_mode();
-        }
     }
 #endif
 }
@@ -896,12 +891,6 @@ on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_t
                 SCLRotation rotation = g_ui->get_rotation();
                 ise_show_emoticon_layout(current_emoticon_group, ROTATION_TO_DEGREE(rotation), false, g_core.get_main_window());
             }
-
-            if (!strcmp(key_value, USER_KEYSTRING_VOICE)) {
-                ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
-            } else {
-                ise_hide_stt_mode();
-            }
         }
     }
 
@@ -976,13 +965,24 @@ SCLEventReturnType CUIEventCallback::on_event_notification(SCLUINotiType noti_ty
         }
     } else if (noti_type == SCL_UINOTITYPE_INPUT_MODE_CHANGE) {
         SclNotiInputModeChangeDesc *desc = static_cast<SclNotiInputModeChangeDesc*>(etc_info);
-        SclSize size_portrait = g_ui->get_input_mode_size(desc->input_mode, DISPLAYMODE_PORTRAIT);
-        SclSize size_landscape = g_ui->get_input_mode_size(desc->input_mode, DISPLAYMODE_LANDSCAPE);
-        if (g_candidate && g_candidate->get_visible()) {
-            size_portrait.height += g_candidate->get_height();
-            size_landscape.height += g_candidate->get_height();
+        if (desc && g_ui) {
+            SclSize size_portrait = g_ui->get_input_mode_size(desc->input_mode, DISPLAYMODE_PORTRAIT);
+            SclSize size_landscape = g_ui->get_input_mode_size(desc->input_mode, DISPLAYMODE_LANDSCAPE);
+            if (g_candidate && g_candidate->get_visible()) {
+                size_portrait.height += g_candidate->get_height();
+                size_landscape.height += g_candidate->get_height();
+            }
+            g_core.set_keyboard_size_hints(size_portrait, size_landscape);
+
+            if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 &&
+                strcmp(desc->input_mode, "STT_3X4") != 0) {
+                ise_hide_stt_mode();
+            }
+            if (strcmp(g_ui->get_input_mode(), "STT_3X4") != 0 &&
+                strcmp(desc->input_mode, "STT_3X4") == 0) {
+                ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
+            }
         }
-        g_core.set_keyboard_size_hints(size_portrait, size_landscape);
     }
 
     return ret;
@@ -1150,7 +1150,6 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                 if (strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
                     g_keyboard_state.need_reset = TRUE;
                     voice_result_string_flush();
-                    ise_hide_stt_mode();
                     ise_set_layout(g_keyboard_state.layout, g_keyboard_state.layout_variation);
                     if (g_keyboard_state.visible_state)
                         ise_show(g_keyboard_state.ic);
@@ -1222,11 +1221,6 @@ ise_reset_context()
     LOGD("");
     _reset_multitap_state(true);
     _language_manager.reset_language(g_config_values.selected_language.c_str());
-
-    if (strcmp(g_ui->get_input_mode(), "STT_3X4") != 0 ) {
-        g_keyboard_state.need_reset = TRUE;
-        ise_hide_stt_mode();
-    }
 }
 
 void
@@ -1312,8 +1306,13 @@ ise_show(int ic)
         }
 
         /* Reset input mode if the input context value has changed */
-        if (ic != g_keyboard_state.ic && !g_setting_window_open_status) {
-            reset_inputmode = TRUE;
+        if (ic != g_keyboard_state.ic) {
+            /* Do not reset input mode if STT's setting window was opened */
+            if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
+                LOGD("Setting window was opened while using STT, skip resetting input mode");
+            } else {
+                reset_inputmode = TRUE;
+            }
         }
 
         g_keyboard_state.ic = ic;
@@ -1326,8 +1325,13 @@ ise_show(int ic)
         }
 
         /* No matter what, just reset the inputmode if it needs to */
-        if (g_keyboard_state.need_reset && !g_setting_window_open_status) {
-            reset_inputmode = TRUE;
+        if (g_keyboard_state.need_reset) {
+            /* Do not reset input mode if STT's setting window was opened */
+            if (g_setting_window_open_status && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0) {
+                LOGD("Setting window was opened while using STT, skip resetting input mode");
+            } else {
+                reset_inputmode = TRUE;
+            }
         }
         g_keyboard_state.need_reset = FALSE;
 
@@ -1550,9 +1554,6 @@ ise_show(int ic)
     }
 #endif
 
-    if (g_setting_window_open_status) {
-        ise_show_stt_mode(NATIVE_WINDOW_CAST(g_core.get_main_window()));
-    }
     g_setting_window_open_status = FALSE;
 }
 
@@ -1605,6 +1606,7 @@ ise_hide()
     _reset_shift_state();
     _reset_multitap_state(true);
 
+    /* If we were in STT mode, try to reset input mode on our next show event */
     if (g_ui && strcmp(g_ui->get_input_mode(), "STT_3X4") == 0 ) {
         g_keyboard_state.need_reset = TRUE;
         ise_hide_stt_mode();
@@ -1715,6 +1717,8 @@ ise_create()
 void
 ise_destroy()
 {
+    ise_hide_stt_mode();
+
     if (g_ui) {
         LOGD("calling g_ui->fini()\n");
         g_ui->fini();