e_input/e_comp_wl: add new event for touch - E_EVENT_INPUT_TOUCH_FRAME 44/316044/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Sat, 10 Aug 2024 05:00:41 +0000 (14:00 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 13 Aug 2024 01:04:45 +0000 (10:04 +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: I5e0539fbb5018efaa5d3c110123b44fd1e800fe9

src/bin/inputmgr/e_input.c
src/bin/inputmgr/e_input_evdev.c
src/bin/server/e_comp_wl.c
src/bin/server/e_comp_wl_intern.h
src/include/e_comp_wl.h
src/include/e_input.h

index 069860a0a02190f7d9f90a71b6575f55cb0a8750..2da00ce96fdecff3908a5ea07cd77b7b5e68758a 100644 (file)
@@ -34,6 +34,7 @@ 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;
 atomic_bool main_thread_display_flushing = EINA_FALSE;
@@ -162,6 +163,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);
 
@@ -302,6 +304,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 47448c6f32477fd42f72eea23b0c5b2cf7e2c0da..c1237569f8d5a856a7f586ab1ce027b08c98eb7f 100644 (file)
@@ -2325,6 +2325,8 @@ e_input_evdev_handle_touch_frame(E_Input_Evdev *evdev, struct libinput_event_tou
 
    ecore_thread_main_loop_begin();
    _touch_event_pending_flush(evdev);
+   ecore_event_add(E_EVENT_INPUT_TOUCH_FRAME, NULL, NULL, NULL);
+
    ecore_thread_main_loop_end();
 }
 
index 094bcb2bd5ff1a56593462c3301eeb6817caf05b..6d331d95c61ddc820039a6244373e8b5a3b5b337 100644 (file)
@@ -1452,6 +1452,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
@@ -1481,6 +1483,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
@@ -1930,6 +1960,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)
 {
@@ -3660,6 +3698,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);
@@ -4870,6 +4909,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 42b30512d4f89a6857684fc89b45c36177509a47..75007cff9df4c67e5572191c4a3ca1c47ea94778 100644 (file)
@@ -28,6 +28,9 @@ EINTERN Eina_Bool e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool presse
 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_key_process(Ecore_Event_Key *ev, E_Device *dev, int type);
 
+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 350c20623357a796abbc766d64154c836159738d..5ccb5c09473c011ba9498114a24c4c0ae438b800 100644 (file)
@@ -283,6 +283,7 @@ struct _E_Comp_Wl_Data
         unsigned int num_devices;
         unsigned int pressed;
         E_Client *faked_ec;
+        E_Client *frame_ec;
      } touch;
 
    struct
index 8462d54a086e345b67df9129072a570a0c694c03..2987c2f7fee76966b6a80717876cb477732fe20b 100644 (file)
@@ -39,6 +39,7 @@ typedef enum _E_Input_Libinput_Backend
 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;
 
 E_API const Eina_List *e_input_devices_get(void);
 E_API Eina_Bool        e_input_device_pointer_warp(E_Input_Device *dev, int x, int y);