e_input/e_comp_wl: add new event for touch - E_EVENT_INPUT_TOUCH_FRAME 87/312087/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Tue, 4 Jun 2024 06:32:57 +0000 (15:32 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Tue, 4 Jun 2024 06:33:00 +0000 (15:33 +0900)
We add a new event for touch - E_EVENT_INPUT_TOUCH_FRAME.

This event is generated when e receives the LIBINPUT_EVENT_TOUCH_FRAME event
from the libinput.
And e sends the wl_touch.frame event to the client if this event is generated.

Change-Id: Id3b882d8a42f44b06cf069382dda60fb7d96db31

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

index 157d911..2c40ab4 100644 (file)
@@ -1405,6 +1405,8 @@ _e_comp_wl_send_touch(E_Client *ec, int idx, int canvas_x, int canvas_y, uint32_
           }
         TRACE_INPUT_END();
      }
+
+   e_comp_wl_touch_frame_send_ec_set(ec);
 }
 
 static void
@@ -1434,6 +1436,34 @@ _e_comp_wl_send_touch_move(E_Client *ec, int idx, int canvas_x, int canvas_y, ui
         if (!e_comp_wl_input_touch_check(res)) continue;
         wl_touch_send_motion(res, timestamp, idx, x, y);
      }
+
+   e_comp_wl_touch_frame_send_ec_set(ec);
+}
+
+static void
+_e_comp_wl_send_touch_frame(E_Client *ec)
+{
+   Eina_List *l;
+   struct wl_client *wc;
+   struct wl_resource *res;
+
+   if (!ec) return;
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if (_e_comp_wl_check_block_input(ec)) return;
+
+   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
+   if (!surface) return;
+
+   wc = wl_resource_get_client(surface);
+
+   EINA_LIST_FOREACH(e_comp_wl->touch.resources, l, res)
+     {
+        if (wl_resource_get_client(res) != wc) continue;
+        if (!e_comp_wl_input_touch_check(res)) continue;
+        wl_touch_send_frame(res);
+     }
+
+   e_comp_wl_touch_frame_send_ec_set(NULL);
 }
 
 static void
@@ -1883,6 +1913,14 @@ _e_comp_wl_evas_cb_multi_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *o
      }
 }
 
+static Eina_Bool
+_e_comp_wl_cb_touch_frame(void *data, int type, void *event)
+{
+   E_Client *ec = e_comp_wl_touch_frame_send_ec_get();
+   _e_comp_wl_send_touch_frame(ec);
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 static void
 _e_comp_wl_client_priority_adjust(int pid, int set, int adj, Eina_Bool use_adj, Eina_Bool adj_child, Eina_Bool do_child)
 {
@@ -3952,6 +3990,7 @@ e_comp_wl_init(void)
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _e_comp_wl_cb_client_rot_change_begin, NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _e_comp_wl_cb_client_rot_change_cancel, NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END, _e_comp_wl_cb_client_rot_change_end, NULL);
+   E_LIST_HANDLER_APPEND(handlers, E_EVENT_INPUT_TOUCH_FRAME, _e_comp_wl_cb_touch_frame, NULL);
 
    /* add hooks to catch e_client events */
    E_LIST_HOOK_APPEND(hooks, E_CLIENT_HOOK_FOCUS_SET,    _e_comp_wl_client_cb_focus_set,    NULL);
@@ -4849,6 +4888,17 @@ e_comp_wl_key_cancel(E_Client *ec, int keycode, Ecore_Device *dev, uint32_t time
    return EINA_TRUE;
 }
 
+EINTERN E_Client*
+e_comp_wl_touch_frame_send_ec_get(void)
+{
+   return e_comp_wl->touch.frame_ec;
+}
+
+EINTERN void
+e_comp_wl_touch_frame_send_ec_set(E_Client *ec)
+{
+   e_comp_wl->touch.frame_ec = ec;
+}
 
 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)
index 9aafc47..65bd113 100644 (file)
@@ -275,6 +275,7 @@ struct _E_Comp_Wl_Data
         unsigned int num_devices;
         unsigned int pressed;
         E_Client *faked_ec;
+        E_Client *frame_ec;
      } touch;
 
    struct
@@ -631,6 +632,8 @@ EINTERN void e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timest
 
 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 E_Client* e_comp_wl_touch_frame_send_ec_get(void);
+EINTERN void e_comp_wl_touch_frame_send_ec_set(E_Client *ec);
 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);
 EINTERN Eina_Bool e_comp_wl_touch_cancel_send(E_Client *ec);
index 93f908f..595be06 100644 (file)
@@ -26,6 +26,8 @@ int _e_input_log_dom = -1;
 EINTERN int E_INPUT_EVENT_SEAT_ADD = -1;
 EINTERN int E_EVENT_INPUT_ENABLED = -1;
 EINTERN int E_EVENT_INPUT_DISABLED = -1;
+EINTERN int E_EVENT_INPUT_TOUCH_FRAME = -1;
+
 
 E_API E_Input *e_input = NULL;
 
@@ -152,6 +154,7 @@ e_input_init(Ecore_Evas *ee)
    E_INPUT_EVENT_SEAT_ADD = ecore_event_type_new();
    E_EVENT_INPUT_ENABLED = ecore_event_type_new();
    E_EVENT_INPUT_DISABLED = ecore_event_type_new();
+   E_EVENT_INPUT_TOUCH_FRAME = ecore_event_type_new();
 
    ecore_event_add(E_EVENT_INPUT_ENABLED, NULL, NULL, NULL);
 
@@ -297,6 +300,7 @@ e_input_shutdown(void)
    E_INPUT_EVENT_SEAT_ADD = -1;
    E_EVENT_INPUT_ENABLED = -1;
    E_EVENT_INPUT_DISABLED = -1;
+   E_EVENT_INPUT_TOUCH_FRAME = -1;
 
    EINA_LIST_FREE(e_input->handlers, h)
      ecore_event_handler_del(h);
index a2fc5fd..acfdfd3 100644 (file)
@@ -20,6 +20,7 @@ typedef struct _E_Input E_Input;
 EINTERN extern int E_INPUT_EVENT_SEAT_ADD;
 EINTERN extern int E_EVENT_INPUT_ENABLED;
 EINTERN extern int E_EVENT_INPUT_DISABLED;
+EINTERN extern int E_EVENT_INPUT_TOUCH_FRAME;
 
 typedef enum _E_Input_Hook_Point
 {
index 6f8ca90..4c80639 100644 (file)
@@ -2277,6 +2277,8 @@ _device_handle_touch_frame(struct libinput_device *device, struct libinput_event
 
    ecore_thread_main_loop_begin();
    _touch_event_pending_flush(edev);
+   ecore_event_add(E_EVENT_INPUT_TOUCH_FRAME, NULL, NULL, NULL);
+
    ecore_thread_main_loop_end();
 }