e_comp_wl: Process mouse move, down, up with ecore event instead of evas event 72/321972/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 18 Mar 2025 11:15:48 +0000 (20:15 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 2 Apr 2025 01:11:18 +0000 (10:11 +0900)
Change-Id: If008d257d76736e330f6c86b1e8fe6d83124df58
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/bin/core/e_config.c
src/bin/debug/e_info_server.c
src/bin/inputmgr/e_input_backend.c
src/bin/inputmgr/e_input_intern.h
src/bin/server/e_comp_wl.c
src/include/e_config.h

index 1bd7a50e83a66b234bf1cbc027a06673cc103b69..93d6d31176d44cb0485752198f03e60da0aebaea 100644 (file)
@@ -317,6 +317,7 @@ _e_config_edd_init(Eina_Bool old)
    E_CONFIG_VAL(D, T, key_input_ttrace_enable, UCHAR);
    E_CONFIG_VAL(D, T, input_thread_data_clone, UCHAR);
    E_CONFIG_VAL(D, T, pointer_thread_mode, UCHAR);
+   E_CONFIG_VAL(D, T, input_use_ecore_event, UCHAR);
 }
 
 static Eina_Bool
@@ -581,6 +582,7 @@ e_config_load(void)
    E_CONFIG_LIMIT(e_config->key_input_ttrace_enable, 0, 1);
    E_CONFIG_LIMIT(e_config->input_thread_data_clone, 0, 1);
    E_CONFIG_LIMIT(e_config->pointer_thread_mode, 0, 1);
+   E_CONFIG_LIMIT(e_config->input_use_ecore_event, 0, 1);
 }
 
 E_API void
index 1f2e3971470b1b7a505c4a4e95faf0f84ba3873d..dc926ad690a251cc0d29a33ccc8438e900ba9761 100644 (file)
@@ -7695,6 +7695,23 @@ _e_info_server_cb_pointer_thread_mode(const Eldbus_Service_Interface *iface EINA
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_input_use_ecore_event(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   int set = 0;
+
+   if (!eldbus_message_arguments_get(msg, "i", &set))
+     {
+        ERR("Failed to get argument");
+        return reply;
+     }
+
+   e_input_use_ecore_event_set(!!set);
+
+   return reply;
+}
+
 static Eldbus_Message *
 _e_info_server_cb_zone_focus_get(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
@@ -7903,6 +7920,7 @@ static const Eldbus_Method methods[] = {
    { "zone_focus_get", ELDBUS_ARGS({"i", "Zone ID"}), ELDBUS_ARGS({"ius", "focused ec info"}), _e_info_server_cb_zone_focus_get, 0 },
    { "default_zone_set", ELDBUS_ARGS({"i", "Zone ID to set default zone"}), ELDBUS_ARGS({"b", "result"}), _e_info_server_cb_default_zone_set, 0 },
    { "default_zone_get", NULL, ELDBUS_ARGS({"i", "Zone ID to set default zone"}), _e_info_server_cb_default_zone_get, 0 },
+   { "input_use_ecore_event", ELDBUS_ARGS({"i", "set input_use_ecore_event"}), NULL, _e_info_server_cb_input_use_ecore_event, 0 },
    { NULL, NULL, NULL, NULL, 0 }
 };
 
index aece0074b9a8ed4fc060c3e454f3cbeec66a445b..586d0c7ec7c8be341cf34466b3897d5438bdc8dc 100644 (file)
@@ -1526,6 +1526,24 @@ e_input_thread_mode_get()
      return EINA_TRUE;
 }
 
+EINTERN Eina_Bool
+e_input_use_ecore_event_get()
+{
+   if (e_config)
+     return e_config->input_use_ecore_event;
+   else
+     return EINA_TRUE;
+}
+
+EINTERN void
+e_input_use_ecore_event_set(Eina_Bool mode)
+{
+   if (!e_config)
+     return;
+
+   e_config->input_use_ecore_event = mode;
+}
+
 EINTERN void
 e_input_backend_create_event_source(E_Input_Backend *input)
 {
index 88718602b00eaf08c4f850dfa1a90a67f8e6c6a5..e19acdda019468acb4f1c7b368d46861f7f997de 100644 (file)
@@ -71,4 +71,7 @@ EINTERN void e_input_hook_call(E_Input_Hook_Point hookpoint, const char *device_
 EINTERN Eina_Bool e_input_pointer_thread_mode_get();
 EINTERN void e_input_pointer_thread_mode_set(Eina_Bool set);
 
+EINTERN Eina_Bool e_input_use_ecore_event_get();
+EINTERN void e_input_use_ecore_event_set(Eina_Bool set);
+
 #endif
index 2e536224ac045b1c40d2bf71fcefeb4ddcb06109..43ea8572c32b8f18d0f3ac59718256d6ba3c6317 100644 (file)
@@ -49,6 +49,8 @@
 #include "e_seat_intern.h"
 #include "e_surface_view_intern.h"
 #include "e_focus_intern.h"
+#include "e_zone_intern.h"
+#include "ecore_device_ex_intern.h"
 
 #include <tizen-extension-server-protocol.h>
 #include <relative-pointer-unstable-v1-server-protocol.h>
@@ -975,6 +977,30 @@ _e_comp_wl_send_event_e_device(struct wl_client *wc, uint32_t timestamp, E_Devic
    g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
 }
 
+static void
+_e_comp_wl_device_send_event_ecore_device(E_Comp_Wl_Data *comp_wl, E_Client *ec, Ecore_Device *dev, uint32_t timestamp)
+{
+   struct wl_client *wc;
+   uint32_t serial;
+
+   EINA_SAFETY_ON_NULL_RETURN(dev);
+
+   if (!ec) return;
+   if (ec->cur_mouse_action || comp_wl->drag)
+     return;
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if ((ec->ignored) && (!ec->remote_surface.provider)) return;
+   struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
+   if (!surface) return;
+
+   serial = wl_display_next_serial(comp_wl->wl.disp);
+
+   wc = wl_resource_get_client(surface);
+   EINA_SAFETY_ON_NULL_RETURN(wc);
+
+   _e_comp_wl_send_event_device(wc, timestamp, dev, serial);
+}
+
 static void
 _e_comp_wl_cursor_reload(E_Comp_Wl_Data *comp_wl, E_Client *ec)
 {
@@ -1573,6 +1599,8 @@ _e_comp_wl_evas_handle_mouse_button_to_touch(E_Comp_Wl_Data *comp_wl, E_Client *
 {
    struct wl_resource *surface;
 
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
    if (ec->cur_mouse_action || comp_wl->drag) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
    if (!(surface = e_comp_wl_client_surface_get(ec))) return;
@@ -2208,9 +2236,12 @@ _e_comp_wl_client_evas_init(E_Client *ec)
 
    evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_IN,    EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_in,    ec);
    evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_OUT,   EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_out,   ec);
-   evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE,  EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move,  ec);
-   evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN,  EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down,  ec);
-   evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP,    EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up,    ec);
+   if (!e_input_use_ecore_event_get())
+     {
+        evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_MOVE,  EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_move,  ec);
+        evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_DOWN,  EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_down,  ec);
+        evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_UP,    EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_up,    ec);
+     }
    evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_mouse_wheel, ec);
 
    evas_object_event_callback_priority_add(ec->frame, EVAS_CALLBACK_MULTI_DOWN, EVAS_CALLBACK_PRIORITY_AFTER, _e_comp_wl_evas_cb_multi_down, ec);
@@ -2235,9 +2266,12 @@ _e_comp_wl_client_evas_deinit(E_Client *ec)
 
    evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_IN,    _e_comp_wl_evas_cb_mouse_in);
    evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_OUT,   _e_comp_wl_evas_cb_mouse_out);
-   evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE,  _e_comp_wl_evas_cb_mouse_move);
-   evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN,  _e_comp_wl_evas_cb_mouse_down);
-   evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP,    _e_comp_wl_evas_cb_mouse_up);
+   if (!e_input_use_ecore_event_get())
+     {
+        evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_MOVE,  _e_comp_wl_evas_cb_mouse_move);
+        evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_DOWN,  _e_comp_wl_evas_cb_mouse_down);
+        evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_UP,    _e_comp_wl_evas_cb_mouse_up);
+     }
    evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MOUSE_WHEEL, _e_comp_wl_evas_cb_mouse_wheel);
 
    evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_MULTI_DOWN, _e_comp_wl_evas_cb_multi_down);
@@ -2394,14 +2428,215 @@ _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Ev
    return ECORE_CALLBACK_RENEW;
 }
 
+static E_Client *
+_e_comp_wl_under_position_input_ec_get(E_Zone *client_zone, int x, int y)
+{
+   E_Desk *desk = NULL;
+   E_Client *ec = NULL;
+
+   desk = e_desk_current_get(client_zone);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(desk, NULL);
+
+   ec = e_client_under_position_input_get(desk, x, y);
+   if (!ec)
+     ERR("Can't find ec at (%d, %d)", x, y);
+
+   return ec;
+}
+
 static Eina_Bool
 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
 {
    E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   E_Client *ec = NULL;
+   Evas_Device *dev = NULL;
+   E_Comp_Config *comp_conf;
+   Ecore_Device_Class dev_class;
+   E_Zone *client_zone;
+   const char *dev_name;
+   char *seat_name;
+   struct wl_resource *surface;
+
+   comp_wl->ptr.x = wl_fixed_from_int(ev->x);
+   comp_wl->ptr.y = wl_fixed_from_int(ev->y);
+
+   dev = ev->dev;
+   dev_name = ecore_device_description_get(dev);
+   dev_class = ecore_device_class_get(dev);
+
+   seat_name = ecore_device_ex_seatname_get(dev);
+   client_zone = e_seat_zone_get(e_seat_find(seat_name));
+   ec = _e_comp_wl_under_position_input_ec_get(client_zone, ev->x, ev->y);
+
+   if (!ec) goto end;
+   if (e_object_is_del(E_OBJECT(ec))) goto end;
+   if ((ec->ignored) && (!ec->remote_surface.provider)) goto end;
+   if (!(surface = e_comp_wl_client_surface_get(ec))) goto end;
+
+   if ((!need_send_motion) && (!need_send_released) && (e_client_visibility_get(ec) == E_VISIBILITY_FULLY_OBSCURED)) goto end;
+
+   comp_conf = e_comp_config_get();
+   if (comp_conf && comp_conf->input_log_enable)
+     ELOGF("Mouse", "Move (time: %d, position(%d, %d), name:%20s) (dev:%s)",
+           NULL, ev->timestamp, ev->x, ev->y,
+           e_client_util_name_get(ec), dev_name);
+
+   if (e_input_backend_mouse_printing_needed())
+     e_input_backend_mouse_timestamp_append(ev->timestamp);
+
+   if (dev && (dev_class == ECORE_DEVICE_CLASS_TOUCH))
+     {
+        if (!comp_wl->drag_client)
+          {
+             comp_wl->touch.faked_ec = ec;
+             if (comp_wl->touch.pressed & (1 << 0))
+               {
+                  _e_comp_wl_device_send_event_ecore_device(comp_wl, ec, dev, ev->timestamp);
+                  if (dev_name)
+                    _e_comp_wl_device_handle_axes(dev_name, dev_class,
+                                                  ec, 0, ev->multi.radius_x, ev->multi.radius_y, ev->multi.pressure, ev->multi.angle);
+                  _e_comp_wl_send_touch_move(comp_wl, ec, 0, ev->x, ev->y, ev->timestamp);
+               }
+          }
+
+        e_pointer_touch_move(e_comp_pointer_get(), ev->x, ev->y);
+     }
+   else
+     {
+        if (!comp_wl->drag_client)
+          {
+             if (_e_comp_wl_check_cursor_timer_needed(ec))
+               {
+                  if (!_e_comp_wl_cursor_timer_control(EVAS_CALLBACK_MOUSE_MOVE, comp_wl, ec))
+                    goto end;
+               }
+
+             _e_comp_wl_device_send_event_ecore_device(comp_wl, ec, dev, ev->timestamp);
+             _e_comp_wl_send_mouse_move(comp_wl, ec, ev->x, ev->y, ev->timestamp);
+
+             if (!need_send_released) // set cursor's hide_tmr only when mouse button is not pressed
+               {
+                  if (_e_comp_wl_check_cursor_timer_needed(ec))
+                    _e_comp_wl_cursor_move_timer_control(comp_wl, ec);
+               }
+          }
+        else
+          E_FREE_FUNC(comp_wl->ptr.hide_tmr, ecore_timer_del);
+
+        e_pointer_mouse_move(e_comp_pointer_get(), ev->x, ev->y);
+     }
+
+end:
+   return ECORE_CALLBACK_RENEW;
+}
+
+static void
+_e_comp_wl_zone_send_mouse_button(Ecore_Event_Mouse_Button *ev, Eina_Bool pressed)
+{
+   E_Comp_Wl_Data *comp_wl = e_comp_wl_get();
+   Ecore_Device *dev = NULL;
+   Ecore_Device_Class dev_class;
+   const char *dev_name, *dev_identifier;
+   char *seat_name;
+   E_Client *ec = NULL;
+   E_Comp_Config *comp_conf;
+   E_Zone *client_zone;
 
    comp_wl->ptr.x = wl_fixed_from_int(ev->x);
    comp_wl->ptr.y = wl_fixed_from_int(ev->y);
 
+   dev = ev->dev;
+   if (!dev) return;
+
+   dev_class = ecore_device_class_get(dev);
+   dev_name = ecore_device_name_get(dev);
+   dev_identifier = ecore_device_identifier_get(dev);
+   seat_name = ecore_device_ex_seatname_get(dev);
+
+   comp_conf = e_comp_config_get();
+   if (comp_conf && comp_conf->input_log_enable)
+     ELOGF("Mouse", "%s (time: %d, position(%d, %d), dev_name:%s, identifier: %s, clas: %d, seatname:%s)",
+           NULL, pressed ? "Down" : "Up", ev->timestamp, ev->x, ev->y,
+           dev_name, dev_identifier, dev_class, seat_name);
+
+   seat_name = ecore_device_ex_seatname_get(dev);
+   client_zone = e_seat_zone_get(e_seat_find(seat_name));
+
+   ec = _e_comp_wl_under_position_input_ec_get(client_zone, ev->x, ev->y);
+
+   comp_wl = e_comp_wl_get();
+   _e_comp_wl_device_send_event_ecore_device(comp_wl, ec, dev, ev->timestamp);
+
+   if (dev_class == ECORE_DEVICE_CLASS_TOUCH)
+     {
+        if (pressed)
+          comp_wl->touch.faked_ec = ec;
+        else
+          {
+             comp_wl->touch.pressed &= ~(1 << 0);
+
+             if (!comp_wl->touch.pressed && comp_wl->touch.faked_ec)
+               comp_wl->touch.faked_ec = NULL;
+          }
+
+        if (dev_name)
+          {
+             if (pressed)
+               {
+                  _e_comp_wl_device_renew_axis(dev_name, dev_class,
+                                               ec, 0, ev->multi.radius_x, ev->multi.radius_y, ev->multi.pressure, ev->multi.angle);
+               }
+             else
+               {
+                  _e_comp_wl_device_handle_axes(dev_name, dev_class,
+                                                ec, 0, ev->multi.radius_x, ev->multi.radius_y, ev->multi.pressure, ev->multi.angle);
+               }
+          }
+
+        _e_comp_wl_evas_handle_mouse_button_to_touch(comp_wl, ec, ev->timestamp, ev->x, ev->y, pressed);
+
+        if (pressed)
+          {
+             e_pointer_touch_move(e_comp_pointer_get(), ev->x, ev->y);
+             comp_wl->touch.pressed |= (1 << 0);
+          }
+     }
+   else
+     {
+        if (_e_comp_wl_check_cursor_timer_needed(ec))
+          {
+             if (!_e_comp_wl_cursor_timer_control(pressed ? EVAS_CALLBACK_MOUSE_DOWN : EVAS_CALLBACK_MOUSE_UP, comp_wl, ec))
+               return;
+          }
+
+        e_comp_wl_evas_handle_mouse_button(comp_wl, ec, ev->timestamp, ev->buttons,
+                                           pressed ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED);
+
+        if (pressed)
+          e_pointer_mouse_move(e_comp_pointer_get(), ev->x, ev->y);
+        else
+          {
+             if (_e_comp_wl_check_cursor_timer_needed(ec))
+               _e_comp_wl_cursor_move_timer_control(comp_wl, ec);
+          }
+     }
+
+   need_send_released = pressed;
+}
+
+static Eina_Bool
+_e_comp_wl_cb_mouse_button_down(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
+{
+   _e_comp_wl_zone_send_mouse_button(ev, EINA_TRUE);
+
+   return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool
+_e_comp_wl_cb_mouse_button_up(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
+{
+   _e_comp_wl_zone_send_mouse_button(ev, EINA_FALSE);
+
    return ECORE_CALLBACK_RENEW;
 }
 
@@ -3504,7 +3739,12 @@ e_comp_wl_init(void)
    /* add event handlers to catch E events */
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE,            _e_comp_wl_cb_randr_change,        NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD,         _e_comp_wl_cb_comp_object_add,     NULL);
-   E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE,          _e_comp_wl_cb_mouse_move,          NULL);
+   if (e_input_use_ecore_event_get())
+     {
+        E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE,          _e_comp_wl_cb_mouse_move,          NULL);
+        E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_DOWN,   _e_comp_wl_cb_mouse_button_down,   NULL);
+        E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_UP,     _e_comp_wl_cb_mouse_button_up,     NULL);
+     }
    if (e_input_thread_mode_get())
      {
         if (e_input_thread_id_get())
index e1f9145b969241cb8b78ff18cf7567bae097987f..e20b74481e029edb19e5c2697fe7c2c119140ed4 100644 (file)
@@ -313,6 +313,7 @@ struct _E_Config
    Eina_Bool key_input_ttrace_enable; // 0: disable the performance measurement of key inputs , 1: enable the performance measurement of key inputs
    Eina_Bool input_thread_data_clone; // 0: disable to clone data into input thread, 1: enable to clone data into input thread
    Eina_Bool pointer_thread_mode; // 0: process pointer/touch event in main thread, 1: process pointer/touch in input thread
+   Eina_Bool input_use_ecore_event; // 0: process pointer/touch event without evas event, 1: process pointer/touch event with evas event
 };
 
 struct _E_Config_Desklock_Background