Fixed the remote_surrounding_text not being delivered when typing preedit string 30/274830/4
authorInHong Han <inhong1.han@samsung.com>
Tue, 10 May 2022 07:16:05 +0000 (16:16 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 26 May 2022 04:52:12 +0000 (13:52 +0900)
Change-Id: I3c4facf531f8046c1f4ce77db3344c9103ddc2a9

ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp

index 86b64ef..3a44f12 100644 (file)
@@ -215,6 +215,7 @@ static bool                                             _support_hw_keyboard_mod
 static bool                                             _x_key_event_is_valid       = false;
 
 static Ecore_Timer                                     *_resource_check_timer       = NULL;
+static Ecore_Timer                                     *_request_surrounding_text_timer = NULL;
 
 static bool                                             _need_wl_im_init           = false;
 static struct _wl_im                                    *_wl_im_ctx                = NULL;
@@ -225,6 +226,7 @@ static bool                                             _send_focus_in_event
 
 #define WAYLAND_MODULE_CLIENT_ID (0)
 #define MAX_PREEDIT_BUFSIZE 4000
+#define GET_SURROUNDING_TIMER_INTERVAL 0.2
 
 #define MOD_SHIFT_MASK      0x01
 #define MOD_CAPS_MASK       0x02
@@ -823,6 +825,10 @@ wl_im_destroy ()
         ecore_timer_del (_resource_check_timer);
     _resource_check_timer = NULL;
 
+    if (_request_surrounding_text_timer)
+        ecore_timer_del (_request_surrounding_text_timer);
+    _request_surrounding_text_timer = NULL;
+
     isf_wsc_context_del (wsc_ctx);
     delete wsc_ctx;
     _wl_im_ctx->wsc->wsc_ctx = NULL;
@@ -2023,6 +2029,18 @@ wsc_send_preedit_style (WSCContextISF* wsc_ctx)
     }
 }
 
+static Eina_Bool
+get_surrounding_text_timer_cb (void *data)
+{
+    WSCContextISF* wsc_ctx = static_cast<WSCContextISF*>(data);
+    _request_surrounding_text_timer = NULL;
+
+    if (wsc_ctx)
+        remote_surrounding_get (wsc_ctx);
+
+    return ECORE_CALLBACK_CANCEL;
+}
+
 static void
 wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor)
 {
@@ -2046,8 +2064,11 @@ wsc_send_preedit (WSCContextISF* wsc_ctx, int32_t cursor)
                                             wsc_ctx->preedit_str,
                                             utf8_wcstombs (wsc_ctx->impl->commit_string).c_str ());
 
-    if (_TV)
-        remote_surrounding_get (wsc_ctx);
+    if (_TV) {
+        if (_request_surrounding_text_timer)
+            ecore_timer_del (_request_surrounding_text_timer);
+        _request_surrounding_text_timer = ecore_timer_add (GET_SURROUNDING_TIMER_INTERVAL, get_surrounding_text_timer_cb, wsc_ctx);
+    }
 }
 
 bool wsc_context_surrounding_get (WSCContextISF *wsc_ctx, char **text, int *cursor_pos)