ecore_wl2: add keyboard_grab/ungrab API 19/297719/3 accepted/tizen/unified/20230828.102406
authorduna.oh <duna.oh@samsung.com>
Wed, 23 Aug 2023 08:15:21 +0000 (17:15 +0900)
committerduna.oh <duna.oh@samsung.com>
Thu, 24 Aug 2023 03:34:26 +0000 (12:34 +0900)
@tizen_only

Change-Id: Idf6f63a1d2986e3f59dfbd26dd577ed47810c7ef

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_input.c

index e9364df..9c341da 100644 (file)
@@ -2639,6 +2639,10 @@ EAPI void ecore_wl2_window_locked_pointer_cursor_position_hint_set(Ecore_Wl2_Win
 EAPI void ecore_wl2_window_cursor_visible_set(Ecore_Wl2_Window *win, Eina_Bool visible);
 //
 
+// TIZEN_ONLY(20230823) : add keyboard_grab/ungrab API
+EAPI Eina_Bool ecore_wl2_window_keyboard_grab(Ecore_Wl2_Window *win, unsigned int subtype);
+EAPI Eina_Bool ecore_wl2_window_keyboard_ungrab(Ecore_Wl2_Window *win);
+
 # undef EAPI
 # define EAPI
 
index c2c27c9..56dfeff 100644 (file)
@@ -85,6 +85,8 @@ static void _keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSE
 static void _cb_pointer_frame(void *data, struct wl_callback *callback, unsigned int timestamp EINA_UNUSED);
 //
 
+static int _devicemgr_error = -1;
+
 static unsigned int _timestamp_get()
 {
    struct timespec ts;
@@ -3776,9 +3778,9 @@ _ecore_wl2_input_device_manager_cb_device_remove(void *data, struct tizen_input_
 }
 
 static void
-_ecore_wl2_input_device_manager_cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode EINA_UNUSED)
+_ecore_wl2_input_device_manager_cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode)
 {
-   ;
+   _devicemgr_error = errorcode;
 }
 
 static void
@@ -3824,7 +3826,7 @@ void
 _ecore_wl2_input_device_manager_setup(Ecore_Wl2_Display *ewd, unsigned int id, unsigned int version EINA_UNUSED)
 {
    ewd->wl.tz_input_device_manager =
-   wl_registry_bind(ewd->wl.registry, id, &tizen_input_device_manager_interface, 4);
+   wl_registry_bind(ewd->wl.registry, id, &tizen_input_device_manager_interface, 6);
 
    tizen_input_device_manager_add_listener(ewd->wl.tz_input_device_manager,
                                        &_tz_input_device_mgr_listener, ewd);
@@ -4298,4 +4300,70 @@ ecore_wl2_window_cursor_visible_set(Ecore_Wl2_Window *win, Eina_Bool visible)
         ecore_wl2_input_pointer_set(input, NULL, 0, 0);
      }
 }
+
+// TIZEN_ONLY(20230823) : add keyboard_grab/ungrab API
+EAPI Eina_Bool
+ecore_wl2_window_keyboard_grab(Ecore_Wl2_Window *win, unsigned int subtype)
+{
+   Ecore_Wl2_Display *ewd;
+   Ecore_Device_Subclass subclas = (Ecore_Device_Subclass)subtype;
+
+   if (!win || !win->surface) return EINA_FALSE;
+   ewd = win->display;
+   if (!ewd || !ewd->wl.tz_input_device_manager) return EINA_FALSE;
+
+   _devicemgr_error = -1;
+   if (subclas == ECORE_DEVICE_SUBCLASS_NONE)
+     {
+        tizen_input_device_manager_keyboard_grab(ewd->wl.tz_input_device_manager,
+                                                 win->surface,
+                                                 TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_NONE);
+     }
+   else if (subtype == ECORE_DEVICE_SUBCLASS_REMOCON)
+     {
+        tizen_input_device_manager_keyboard_grab(ewd->wl.tz_input_device_manager,
+                                                 win->surface,
+                                                 TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_REMOCON);
+     }
+   else if (subtype == ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD)
+     {
+        tizen_input_device_manager_keyboard_grab(ewd->wl.tz_input_device_manager,
+                                                 win->surface,
+                                                 TIZEN_INPUT_DEVICE_MANAGER_SUBCLAS_VIRTUAL_KEYBOARD);
+     }
+   ecore_wl2_display_sync(ewd);
+
+   if (_devicemgr_error != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
+     {
+        ERR("Keyboard grab failed. subtype: %d", subtype);
+        return EINA_FALSE;
+     }
+
+   INF("Keyboard grab succeeded. subtype: %d", subtype);
+   return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+ecore_wl2_window_keyboard_ungrab(Ecore_Wl2_Window *win)
+{
+   Ecore_Wl2_Display *ewd;
+
+   if (!win || !win->surface) return EINA_FALSE;
+   ewd = win->display;
+   if (!ewd || !ewd->wl.tz_input_device_manager) return EINA_FALSE;
+
+   _devicemgr_error = -1;
+   tizen_input_device_manager_keyboard_ungrab(ewd->wl.tz_input_device_manager,
+                                              win->surface);
+   ecore_wl2_display_sync(ewd);
+
+   if (_devicemgr_error != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
+     {
+        ERR("Keyboard ungrab failed.");
+        return EINA_FALSE;
+     }
+
+   INF("Keyboard ungrab succeeded.");
+   return EINA_TRUE;
+}
 //