e_devicemgr: enhance keyboard_grab by sending device info when sending key event 83/300683/1
authorduna.oh <duna.oh@samsung.com>
Tue, 31 Oct 2023 07:40:18 +0000 (16:40 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 31 Oct 2023 09:09:13 +0000 (18:09 +0900)
Change-Id: I7a78368fd67d6a1a12fcc039bae90c5d0b116409

src/bin/e_comp_wl.c
src/bin/e_comp_wl.h
src/bin/e_devicemgr_keyboard_grab.c
src/bin/e_input.h
src/bin/e_input_evdev.c

index 607875e..ffd083f 100644 (file)
@@ -4663,7 +4663,7 @@ e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device
 }
 
 EINTERN Eina_Bool
-e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, Ecore_Device *dev, uint32_t time)
+e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time)
 {
    struct wl_resource *res;
    struct wl_client *wc;
@@ -4671,6 +4671,7 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, Ecore_Device *d
    uint32_t serial, wl_keycode;
    enum wl_keyboard_key_state state;
    E_Comp_Config *comp_conf = NULL;
+   const char *dev_name = NULL;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
@@ -4695,11 +4696,30 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, Ecore_Device *d
    EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res)
      {
         if (wl_resource_get_client(res) != wc) continue;
-        if (dev) _e_comp_wl_send_event_device(wc, time, dev, serial);
-        else _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
+        if (!e_input_thread_mode_get())
+          {
+             if (dev)
+               {
+                  _e_comp_wl_send_event_device(wc, time, (Ecore_Device *)dev, serial);
+                  dev_name = ecore_device_name_get((Ecore_Device *)dev);
+               }
+             else
+               {
+                  _e_comp_wl_device_send_last_event_device(ec, ECORE_DEVICE_CLASS_KEYBOARD, time);
+               }
+          }
+        else
+          {
+             if (dev)
+               {
+                  e_comp_wl_send_event_e_device(wc, time, (E_Device *)dev, serial);
+                  dev_name = e_device_name_get(dev);
+               }
+          }
 
         if (comp_conf && comp_conf->input_log_enable)
-          ELOGF("Key", "Send Key %s (time: %d)", ec, (state ? "Down" : "Up"), time);
+          ELOGF("Key", "Send Key %s (keycode: %d, time: %d, device: %s)", ec, (state ? "Down" : "Up"), wl_keycode, time,
+                dev_name);
 
         wl_keyboard_send_key(res, serial, time,
                              wl_keycode, state);
index 085897f..dc0baca 100644 (file)
@@ -630,7 +630,7 @@ E_API void e_comp_wl_input_cursor_timer_enable_set(Eina_Bool enabled);
 EINTERN void e_comp_wl_send_event_device(struct wl_client *wc, uint32_t timestamp, Ecore_Device *dev, uint32_t serial);
 EINTERN void e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Device *dev, uint32_t serial);
 
-EINTERN Eina_Bool e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, Ecore_Device *dev, uint32_t time);
+EINTERN Eina_Bool e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint32_t time);
 EINTERN Eina_Bool e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time);
 EINTERN Eina_Bool e_comp_wl_touch_send(E_Client *ec, int idx, int x, int y, Eina_Bool pressed, Ecore_Device *dev, double radius_x, double radius_y, double pressure, double angle, uint32_t time);
 EINTERN Eina_Bool e_comp_wl_touch_update_send(E_Client *ec, int idx, int x, int y, Ecore_Device *dev, double radius_x, double radius_y, double pressure, double angle, uint32_t time);
index 883de08..9e127f6 100644 (file)
@@ -23,13 +23,13 @@ e_devicemgr_keyboard_grab_subtype_is_grabbed(Ecore_Device_Subclass subclas)
 
 static void
 _e_devicemgr_keyboard_grab_key_handler(uint32_t keycode, uint32_t state,
-                                           uint32_t timestamp)
+                                           uint32_t timestamp, void *dev)
 {
     DMINF("key(%d-%s) event is delivered to grab ec(%p)",
           keycode, state ? "Pressed" : "Released", e_devicemgr->keyboard_grab.ec);
 
    if (!e_comp_wl_key_send(e_devicemgr->keyboard_grab.ec, keycode, state ? EINA_TRUE : EINA_FALSE,
-                      NULL, timestamp))
+                      dev, timestamp))
       {
          DMERR("Could not send keyboard_grab_key to client(%p)", e_devicemgr->keyboard_grab.client);
       }
index 915f847..0416277 100644 (file)
@@ -57,7 +57,7 @@ typedef struct _E_Input_Seat E_Input_Seat;
 typedef struct _E_Input_Coord E_Input_Coord;
 
 typedef void (*e_input_relative_motion_cb)(double dx[2], double dy[2], uint64_t time_us);
-typedef void (*e_input_keyboard_grab_key_cb)(uint32_t keycode, uint32_t state, uint32_t timestamp);
+typedef void (*e_input_keyboard_grab_key_cb)(uint32_t keycode, uint32_t state, uint32_t timestamp, void *dev);
 
 struct _E_Input
 {
index ffccc23..f6ab341 100644 (file)
@@ -542,7 +542,7 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
    E_Comp_Config *comp_conf = NULL;
    int *pressed_keycode = NULL, *idata = NULL;
    Eina_Bool dup_found = EINA_FALSE;
-   const chardevice_name = NULL;
+   const char *device_name = NULL;
    Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
 
    if (!(edev = libinput_device_get_user_data(device)))
@@ -694,7 +694,10 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
      {
         if (e_devicemgr_keyboard_grab_subtype_is_grabbed(device_subclas))
           {
-             func(code, state, timestamp);
+             if (!e_input_thread_mode_get())
+               func(code, state, timestamp, ecore_dev);
+             else
+               func(code, state, timestamp, e_dev);
              return;
           }
      }