Remove global variable to check the visibility of candidate 99/250699/3
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 4 Jan 2021 02:02:14 +0000 (11:02 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 5 Jan 2021 04:38:31 +0000 (13:38 +0900)
Change-Id: I50addf90a17b81f09d7fbed0a6b05e7e7983d6da
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/ise.cpp

index 1aa4bb9..bb4fdcc 100644 (file)
@@ -85,7 +85,6 @@ static const int MAX_DEFAULT_PUNCTUATION = 6;
 static string g_default_punctuation[MAX_DEFAULT_PUNCTUATION] = {"-", "@", "'", "!", "?", ","};
 static string g_current_punctuation[MAX_DEFAULT_PUNCTUATION-1] = {"RCENT1", "RCENT2", "RCENT3", "RCENT4", "RCENT5"};
 static vector<string> g_softcandidate_string;
-static bool g_softcandidate_show = false;
 static bool g_input_panel_show = false;
 static bool g_caps_mode_pending = false;
 static bool g_floating_mode = false;
@@ -506,7 +505,6 @@ static Eina_Bool softcandidate_hide_timer_callback(void *data)
     Candidate *candidate = get_candidate();
     if (candidate) {
         candidate->hide();
-        g_softcandidate_show = false;
     }
     return ECORE_CALLBACK_CANCEL;
 }
@@ -1185,7 +1183,8 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
                         if (keyboard_state->layout == ISE_LAYOUT_STYLE_NUMBER) {
                             ime_send_key_event(IME_KEY_Print, IME_KEY_MASK_CONTROL, false);
                         } else {
-                            if (word_timer == NULL && (!get_candidate() || !g_softcandidate_show)) {
+                            Candidate *candidate = get_candidate();
+                            if (word_timer == NULL && (!candidate || !candidate->get_visible())) {
                                 word_timer = ecore_timer_add(MULTITAP_TIMEOUT, _multi_tap_timer_cb, NULL);
                             }
                             ime_send_key_event(IME_KEY_Select, IME_KEY_MASK_CONTROL, false);
@@ -1852,7 +1851,7 @@ ise_set_screen_rotation(int degree)
     Candidate *candidate = get_candidate();
     if (candidate) {
         candidate->rotate(degree);
-        if (g_softcandidate_show) {
+        if (candidate->get_visible()) {
             candidate->update(g_softcandidate_string);
         }
     }
@@ -1903,7 +1902,8 @@ ise_hide()
     }
 
     g_input_panel_show = false;
-    if (g_softcandidate_show && get_candidate())
+    Candidate *candidate = get_candidate();
+    if (candidate && candidate->get_visible())
         set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
 #ifdef _WEARABLE
     hide_indicator_window();
@@ -2001,7 +2001,6 @@ static void ise_floating_mode_changed_cb(const char *key, void *user_data)
 
         create_softcandidate();
         if (g_candidate && g_candidate->get_visible()) {
-            g_softcandidate_show = true;
             g_candidate->show();
             set_ime_size(g_floating_mode, ISE_CANDIDATE_REQ_SHOW);
             return;
@@ -2198,16 +2197,17 @@ void
 ise_app_candidate_show()
 {
 #ifdef _WEARABLE
-    if (!g_softcandidate_show) {
+    if (!g_candidate)
+        return;
+
+    if (!g_candidate->get_visible())
         return;
-    }
 #endif
     LOGD("Enter\n");
     delete_softcandidate_hide_timer();
 
     create_softcandidate();
 
-    g_softcandidate_show = true;
     Candidate *candidate = get_candidate();
     if (candidate) {
         candidate->show();
@@ -2221,7 +2221,7 @@ ise_app_candidate_hide()
     LOGD("Enter\n");
 
     Candidate *candidate = get_candidate();
-    if (!candidate || !g_softcandidate_show) {
+    if (!candidate || !candidate->get_visible()) {
         LOGD("No candidate\n");
         return;
     }
@@ -2252,7 +2252,6 @@ void ise_check_wearable_candidate()
                   keyboard_state->layout == ISE_LAYOUT_STYLE_PASSWORD) {
         ise_app_candidate_hide();
     } else {
-        g_softcandidate_show = true;
         ise_app_candidate_show();
     }
 }
@@ -2443,11 +2442,12 @@ void ise_get_language_locale(char **locale)
 
 void ise_update_table(const vector<string> &vec_str)
 {
-    if (!get_candidate() || !g_softcandidate_show) {
+    Candidate *candidate = get_candidate();
+    if (!candidate || !candidate->get_visible()) {
         create_softcandidate();
     }
 
-    Candidate *candidate = get_candidate();
+    candidate = get_candidate();
     if (candidate) {
         candidate->update(vec_str);
     }
@@ -2863,8 +2863,8 @@ static void ime_app_focus_in_cb(int context_id, void *user_data)
     LOGD("Enter\n");
     ise_focus_in(context_id);
     Candidate *candidate = get_candidate();
-    if (input_smartreply_get_reply_num() == 0 && g_softcandidate_show) {
-        if (candidate) {
+    if (input_smartreply_get_reply_num() == 0) {
+        if (candidate && candidate->get_visible()) {
             ise_app_candidate_hide();
             candidate->hide();
         }