ecore_wl2: wait for receiving result of keygrab_set/unset 65/306465/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 22 Feb 2024 01:24:17 +0000 (10:24 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 22 Feb 2024 04:01:42 +0000 (13:01 +0900)
Change-Id: I6b5e5f4d4d7913ca76abf3765fdc073d6b99d3ac
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/lib/ecore_wl2/ecore_wl2_input.c

index c7399dc..94a8f0f 100644 (file)
@@ -46,6 +46,8 @@
 #include <locale.h>
 //
 
+#define MAX_WAIT_COUNT 20
+
 typedef struct _Ecore_Wl2_Mouse_Down_Info
 {
    EINA_INLIST;
@@ -2941,6 +2943,17 @@ _ecore_wl2_keygrab_error_set()
    else set_last_result(TIZEN_ERROR_NONE);
 }
 
+static void
+_ecore_wl2_keygrab_result_wait(Ecore_Wl2_Display *ewd)
+{
+   unsigned int wait_count = 0;
+   while ((_ecore_wl2_keygrab_error == -1) && (wait_count < MAX_WAIT_COUNT))
+     {
+        wl_display_dispatch(ewd->wl.display);
+        wait_count++;
+     }
+}
+
 //I'm not sure that keygrab function should be changed to Ecore_evas_XXX.
 //In the future, keyrouter feature can be added upstream or finish stabilizing.
 //After that time, we maybe change API name or other thing.
@@ -3037,6 +3050,8 @@ ecore_wl2_window_keygrab_set(Ecore_Wl2_Window *win, const char *key, int mod EIN
         /* Send sync to wayland compositor and register sync callback to exit while dispatch loop below */
         ecore_wl2_display_sync(ewd);
 
+        _ecore_wl2_keygrab_result_wait(ewd);
+
         INF("After keygrab _ecore_wl2_keygrab_error = %d", _ecore_wl2_keygrab_error);
         if (!_ecore_wl2_keygrab_error)
           {
@@ -3133,6 +3148,8 @@ ecore_wl2_window_keygrab_unset(Ecore_Wl2_Window *win, const char *key, int mod E
         /* Send sync to wayland compositor and register sync callback to exit while dispatch loop below */
         ecore_wl2_display_sync(ewd);
 
+        _ecore_wl2_keygrab_result_wait(ewd);
+
         INF("After keygrab unset  _ecore_wl2_keygrab_error = %d", _ecore_wl2_keygrab_error);
         if (!_ecore_wl2_keygrab_error)
           {