e_dnd: move mouse motion callback for drag to e_dnd 15/309915/1
authorJunseok Kim <juns.kim@samsung.com>
Tue, 5 Mar 2024 10:59:14 +0000 (19:59 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 18 Apr 2024 06:57:36 +0000 (15:57 +0900)
Change-Id: I37e5a90dbe9f1e3cc4eaa76d6a7cde6adcdfb96e

src/bin/e_comp_wl.c
src/bin/e_comp_wl_data.c
src/bin/e_comp_wl_data_intern.h
src/bin/e_dnd.c

index 45ad598..f00f5d7 100644 (file)
@@ -2377,65 +2377,9 @@ _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Ev
 static Eina_Bool
 _e_comp_wl_cb_mouse_move(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
 {
-   int ec_x, ec_y;
-
    e_comp_wl->ptr.x = wl_fixed_from_int(ev->x);
    e_comp_wl->ptr.y = wl_fixed_from_int(ev->y);
 
-   if (e_comp_wl->selection.target &&
-       e_comp_wl->drag)
-     {
-        struct wl_resource *res;
-        int x, y;
-        E_Client *ec = NULL;
-        E_Client *legacy_target = e_comp_wl->selection.target;
-        int device_id = e_comp_wl_data_current_device_id_get();
-
-        if (device_id < 0)
-          {
-             e_comp_wl_data_current_device_id_set(ev->multi.device);
-          }
-        else if (device_id != ev->multi.device)
-          {
-             return ECORE_CALLBACK_RENEW;
-          }
-
-        ec = e_client_under_position_input_get(legacy_target->desk, ev->x, ev->y);
-        EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
-
-        struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
-        EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
-
-        res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
-        EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
-
-        if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
-            (ec != legacy_target))
-          {
-             e_comp_wl_data_device_send_leave(legacy_target);
-             e_comp_wl_data_device_send_enter(ec);
-          }
-
-        if (e_comp_wl->drag)
-          e_drag_move(e_comp_wl->drag, ev->x, ev->y);
-
-        if (e_client_transform_core_enable_get(ec))
-          {
-             int trans_x, trans_y;
-             e_client_transform_core_input_transform(ec, ev->x, ev->y, &trans_x, &trans_y);
-             x = trans_x - ec->client.x;
-             y = trans_y - ec->client.y;
-          }
-        else
-          {
-             e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
-             x = ev->x - ec_x;
-             y = ev->y - ec_y;
-          }
-
-        wl_data_device_send_motion(res, ev->timestamp, wl_fixed_from_int(x), wl_fixed_from_int(y));
-     }
-
    return ECORE_CALLBACK_RENEW;
 }
 
index 8b30ac9..088c7eb 100644 (file)
@@ -1359,6 +1359,36 @@ e_comp_wl_data_device_send_leave(E_Client *ec)
      wl_data_device_send_leave(res);
 }
 
+EINTERN void
+e_comp_wl_data_device_send_motion(E_Client *ec, int x, int y, uint32_t timestamp)
+{
+   int motion_x, motion_y;
+   struct wl_resource *surface, *data_device_res;
+
+   surface = e_comp_wl_client_surface_get(ec);
+   if (!surface) return;
+
+   data_device_res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
+   if (!data_device_res) return;
+
+   if (e_client_transform_core_enable_get(ec))
+     {
+         int trans_x, trans_y;
+         e_client_transform_core_input_transform(ec, x, y, &trans_x, &trans_y);
+         motion_x = trans_x - ec->client.x;
+         motion_y = trans_y - ec->client.y;
+     }
+   else
+     {
+         int ec_x, ec_y;
+         e_client_geometry_get(ec, &ec_x, &ec_y, NULL, NULL);
+         motion_x = x - ec_x;
+         motion_y = y - ec_y;
+     }
+
+   wl_data_device_send_motion(data_device_res, timestamp, wl_fixed_from_int(motion_x), wl_fixed_from_int(motion_y));
+}
+
 EINTERN void *
 e_comp_wl_data_device_send_offer(E_Client *ec)
 {
index 93f626b..539dc5f 100644 (file)
@@ -95,6 +95,7 @@ EINTERN void      e_comp_wl_data_manager_shutdown(void);
 
 EINTERN void  e_comp_wl_data_device_send_enter(E_Client *ec);
 EINTERN void  e_comp_wl_data_device_send_leave(E_Client *ec);
+EINTERN void  e_comp_wl_data_device_send_motion(E_Client *ec, int x, int y, uint32_t timestamp);
 EINTERN void *e_comp_wl_data_device_send_offer(E_Client *ec);
 
 EINTERN struct wl_resource    *e_comp_wl_data_find_for_client(struct wl_client *client);
index 744eefe..a8bec55 100644 (file)
@@ -1,4 +1,5 @@
 #include "e_dnd_intern.h"
+#include "e_comp_wl_intern.h"
 #include "e_comp_wl_data_intern.h"
 #include "e_grabinput_intern.h"
 
@@ -142,7 +143,7 @@ e_dnd_init(void)
      {
 
         E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_BUTTON_UP, _e_dnd_cb_mouse_up, NULL);
-        E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_MOVE, _e_dnd_cb_mouse_move, NULL);
+        E_LIST_HANDLER_PREPEND(_event_handlers, ECORE_EVENT_MOUSE_MOVE, _e_dnd_cb_mouse_move, NULL);
      }
 
    if (!_zone_event_handlers)
@@ -376,9 +377,51 @@ _e_dnd_cb_mouse_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 static Eina_Bool
 _e_dnd_cb_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 {
+   int x, y;
    Ecore_Event_Mouse_Move *ev = event;
 
-   if (ev->window != _drag_win) return ECORE_CALLBACK_PASS_ON;
+   if (e_comp_wl->selection.target &&
+       e_comp_wl->drag)
+     {
+        struct wl_resource *res;
+        E_Client *ec = NULL;
+        E_Client *legacy_target = e_comp_wl->selection.target;
+        int device_id = e_comp_wl_data_current_device_id_get();
+
+        x = ev->x;
+        y = ev->y;
+
+        if (device_id < 0)
+          {
+             e_comp_wl_data_current_device_id_set(ev->multi.device);
+          }
+        else if (device_id != ev->multi.device)
+          {
+             return ECORE_CALLBACK_RENEW;
+          }
+
+        ec = e_client_under_position_input_get(legacy_target->desk, x, y);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_RENEW);
+
+        struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
+        EINA_SAFETY_ON_NULL_RETURN_VAL(surface, ECORE_CALLBACK_RENEW);
+
+        res = e_comp_wl_data_find_for_client(wl_resource_get_client(surface));
+        EINA_SAFETY_ON_NULL_RETURN_VAL(res, ECORE_CALLBACK_RENEW);
+
+        if ((e_comp_wl->drag_offer != wl_resource_get_user_data(res)) &&
+            (ec != legacy_target))
+          {
+             e_comp_wl_data_device_send_leave(legacy_target);
+             e_comp_wl_data_device_send_enter(ec);
+          }
+
+        if (e_comp_wl->drag)
+          e_drag_move(e_comp_wl->drag, x, y);
+
+        e_comp_wl_data_device_send_motion(ec, x, y, ev->timestamp);
+     }
+
 
    return ECORE_CALLBACK_PASS_ON;
 }