ecore_input: support ECORE_EVENT_MOUSE_FRAME event 40/312440/2
authorDoyoun Kang <doyoun.kang@samsung.com>
Wed, 5 Jun 2024 05:14:21 +0000 (14:14 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Tue, 11 Jun 2024 04:30:57 +0000 (04:30 +0000)
We add a new event and structure as below.
- Event: ECORE_EVENT_MOUSE_FRAME
- Struncture: Ecore_Event_Mouse_Frame

This event is generaged when the ecore_wl2 receives the wl_touch.frame or wl_pointer.frame event.
Through this event, clients can group and process the touch or mouse events.

For example,
toolkit which uses Ecore library can accumulate all ECORE_EVENT_MOUSE_DOWN/MOVE/UP events as
they're received, then process pending inputs when the ECORE_EVENT_MOUSE_FRAME event is received.

@tizen_only

Change-Id: Ia4c7446a1f3a03a688e518b3a88afa84cc5696bd

src/lib/ecore_input/Ecore_Input.h
src/lib/ecore_input/ecore_input.c
src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h

index 77601dd..d1aacd4 100644 (file)
@@ -72,6 +72,9 @@ extern "C" {
    // TIZEN_ONLY(20230802): ecore_input: add Ecore_Event_Mouse_Relative_Move struct
    EAPI extern int ECORE_EVENT_MOUSE_RELATIVE_MOVE;
    //
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   EAPI extern int ECORE_EVENT_MOUSE_FRAME;
+   //
 
 #define ECORE_EVENT_MODIFIER_SHIFT      0x0001
 #define ECORE_EVENT_MODIFIER_CTRL       0x0002
@@ -112,6 +115,9 @@ extern "C" {
    // TIZEN_ONLY(20230802): ecore_input: add Ecore_Event_Mouse_Relative_Move struct
    typedef struct _Ecore_Event_Mouse_Relative_Move   Ecore_Event_Mouse_Relative_Move;
    //
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   typedef struct _Ecore_Event_Mouse_Frame Ecore_Event_Mouse_Frame;
+   //
 
    /**
     * @typedef Ecore_Event_Modifier
@@ -495,6 +501,15 @@ extern "C" {
 
         Eo *dev; /**< The Efl_Input_Device that originated the event @since 1.19 */
      };
+
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   struct _Ecore_Event_Mouse_Frame
+     {
+        Ecore_Window window;
+        int dev_clas; // device class such as mouse, touch, etc
+     };
+   //
+
    //
    /**
     * Initializes the Ecore Event system.
index 653a4eb..3fd3f7a 100644 (file)
@@ -37,7 +37,9 @@ EAPI int ECORE_EVENT_DEVICE_SUBCLASS_UPDATE = 0;
 // TIZEN_ONLY(20230802): ecore_input: add Ecore_Event_Mouse_Relative_Move struct
 EAPI int ECORE_EVENT_MOUSE_RELATIVE_MOVE = 0;
 //
-
+// TIZEN_ONLY(20240604): ecore_input: support frame event
+EAPI int ECORE_EVENT_MOUSE_FRAME = 0;
+//
 
 static int _ecore_event_init_count = 0;
 
@@ -85,6 +87,10 @@ ecore_event_init(void)
    ECORE_EVENT_MOUSE_RELATIVE_MOVE = ecore_event_type_new();
    //
 
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   ECORE_EVENT_MOUSE_FRAME = ecore_event_type_new();
+   //
+
    //TIZEN_ONLY(20170307) Remove warning message
    #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    if (getenv("ECORE_INPUT_ENABLE_JOYSTICK_INIT"))
@@ -123,7 +129,10 @@ ecore_event_shutdown(void)
                           ECORE_EVENT_DEVICE_SUBCLASS_UPDATE,
                           //
                           // TIZEN_ONLY(20230802): ecore_input: add Ecore_Event_Mouse_Relative_Move struct
-                          ECORE_EVENT_MOUSE_RELATIVE_MOVE
+                          ECORE_EVENT_MOUSE_RELATIVE_MOVE,
+                          //
+                          // TIZEN_ONLY(20240604): ecore_input: support frame event
+                          ECORE_EVENT_MOUSE_FRAME
                           //
                           );
    //TIZEN_ONLY(20170307) Remove warning message
index 5902b68..a4c85c0 100644 (file)
@@ -1835,6 +1835,20 @@ static const struct wl_keyboard_listener _keyboard_listener =
    _keyboard_cb_repeat_setup
 };
 
+// TIZEN_ONLY(20240604): ecore_input: support frame event
+static void
+_mouse_frame_target_window_set(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window)
+{
+   input->focus.frame = window;
+}
+
+static Ecore_Wl2_Window *
+_mouse_frame_target_window_get(Ecore_Wl2_Input *input)
+{
+   return input->focus.frame;
+}
+//
+
 static void
 _touch_cb_down(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, struct wl_surface *surface, int id, wl_fixed_t x, wl_fixed_t y)
 {
@@ -1891,6 +1905,10 @@ _touch_cb_down(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int seri
    #endif
    //
 
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   _mouse_frame_target_window_set(input, input->focus.touch);
+   //
+
 // TIZEN_ONLY(20171107): always send move event when touch down event is occurred
    _ecore_wl2_input_mouse_move_send(input, input->focus.touch, id);
 //
@@ -1921,6 +1939,10 @@ _touch_cb_up(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial
    input->timestamp = timestamp;
    input->display->serial = serial;
 
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   _mouse_frame_target_window_set(input, input->focus.touch);
+   //
+
    _ecore_wl2_input_mouse_up_send(input, input->focus.touch, id,
                                   BTN_LEFT, timestamp);
 
@@ -1965,13 +1987,51 @@ _touch_cb_motion(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int ti
    _ecore_wl2_input_touch_axis_process(input, id);
    //
 
+   // TIZEN_ONLY(20240604): ecore_input: support frame event
+   _mouse_frame_target_window_set(input, input->focus.touch);
+   //
+
    _ecore_wl2_input_mouse_move_send(input, input->focus.touch, id);
 }
 
+// TIZEN_ONLY(20240604): ecore_input: support frame event
 static void
-_touch_cb_frame(void *data EINA_UNUSED, struct wl_touch *touch EINA_UNUSED)
+_mouse_frame_cb_free(void *data EINA_UNUSED, void *event)
 {
+   Ecore_Event_Mouse_Frame *ev = event;
+   free(ev);
+}
+//
 
+static void
+_touch_cb_frame(void *data, struct wl_touch *touch EINA_UNUSED)
+{
+// TIZEN_ONLY(20240604): ecore_input: support frame event
+   Ecore_Wl2_Input *input;
+   Ecore_Wl2_Window *window;
+   Ecore_Event_Mouse_Frame *ev;
+
+   input = data;
+   if (!input)
+     {
+        ERR("input is NULL");
+        return;
+     }
+
+   window = _mouse_frame_target_window_get(input);
+   if (!window) return;
+
+   ev = calloc(1, sizeof(Ecore_Event_Mouse_Frame));
+   if (!ev) return;
+
+   ev->window = window->id;
+   ev->dev_clas = ECORE_DEVICE_CLASS_TOUCH;
+
+   ERR("[ECORE_WL2_INPUT] GET wl_touch.frame event. Generate ECORE_EVENT_TOUCH_FRAME");
+   ecore_event_add(ECORE_EVENT_MOUSE_FRAME, ev, _mouse_frame_cb_free, NULL);
+
+   _mouse_frame_target_window_set(input, NULL);
+//
 }
 
 static void
index b9126ce..a941dff 100644 (file)
@@ -768,6 +768,9 @@ struct _Ecore_Wl2_Input
         Ecore_Wl2_Window *prev_pointer;
         Ecore_Wl2_Window *keyboard;
         Ecore_Wl2_Window *touch;
+        // TIZEN_ONLY(20240604): ecore_input: support frame event
+        Ecore_Wl2_Window *frame; // window to be get frame event
+        //
      } focus;
 
    struct