Ecore_Wayland: Some more work on getting drag-n-drop flushed out.
authordevilhorns <devilhorns@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 13 Jan 2012 09:33:33 +0000 (09:33 +0000)
committerdevilhorns <devilhorns@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 13 Jan 2012 09:33:33 +0000 (09:33 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@67182 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/ecore_wl_private.h

index 00a84a4..edb1356 100644 (file)
@@ -23,6 +23,8 @@ typedef struct _Ecore_Wl_Event_Mouse_Out Ecore_Wl_Event_Mouse_Out;
 typedef struct _Ecore_Wl_Event_Focus_In Ecore_Wl_Event_Focus_In;
 typedef struct _Ecore_Wl_Event_Focus_Out Ecore_Wl_Event_Focus_Out;
 
+typedef struct _Ecore_Wl_Drag_Source Ecore_Wl_Drag_Source;
+
 typedef struct _Ecore_Wl_Event_Drag_Start Ecore_Wl_Event_Drag_Start;
 typedef struct _Ecore_Wl_Event_Drag_Stop Ecore_Wl_Event_Drag_Stop;
 
@@ -106,8 +108,10 @@ EAPI unsigned int ecore_wl_format_get(void);
 EAPI void ecore_wl_flush(void);
 EAPI void ecore_wl_sync(void);
 EAPI void ecore_wl_pointer_xy_get(int *x, int *y);
-EAPI void ecore_wl_drag_start();
-EAPI void ecore_wl_drag_stop();
+
+EAPI Ecore_Wl_Drag_Source *ecore_wl_drag_source_create(int hotspot_x, int hotspot_y, int offset_x, int offset_y, const char *mimetype, unsigned int timestamp, void *data);
+EAPI void ecore_wl_drag_start(Ecore_Wl_Drag_Source *source, struct wl_surface *surface);
+EAPI void ecore_wl_drag_stop(void);
 
 EAPI extern int ECORE_WL_EVENT_MOUSE_IN;
 EAPI extern int ECORE_WL_EVENT_MOUSE_OUT;
index 3884c3d..e18bd3a 100644 (file)
@@ -180,6 +180,8 @@ ecore_wl_init(const char *name)
         ECORE_WL_EVENT_MOUSE_OUT = ecore_event_type_new();
         ECORE_WL_EVENT_FOCUS_IN = ecore_event_type_new();
         ECORE_WL_EVENT_FOCUS_OUT = ecore_event_type_new();
+        ECORE_WL_EVENT_DRAG_START = ecore_event_type_new();
+        ECORE_WL_EVENT_DRAG_STOP = ecore_event_type_new();
      }
 
    /* init xkb */
@@ -307,6 +309,49 @@ ecore_wl_pointer_xy_get(int *x, int *y)
    if (y) *y = _ecore_wl_screen_y;
 }
 
+EAPI Ecore_Wl_Drag_Source *
+ecore_wl_drag_source_create(int hotspot_x, int hotspot_y, int offset_x, int offset_y, const char *mimetype, unsigned int timestamp, void *data)
+{
+   Ecore_Wl_Drag_Source *source;
+
+   if (!(source = calloc(1, sizeof(Ecore_Wl_Drag_Source)))) return NULL;
+
+   source->data_dev = _ecore_wl_data_dev;
+   source->hotspot_x = hotspot_x;
+   source->hotspot_y = hotspot_y;
+   source->offset_x = offset_x;
+   source->offset_y = offset_y;
+   source->mimetype = mimetype;
+   source->timestamp = timestamp;
+   source->data = data;
+
+   source->data_source = 
+     wl_data_device_manager_create_data_source(_ecore_wl_data_manager);
+
+   wl_data_source_add_listener(source->data_source, 
+                               &_ecore_wl_source_listener, source);
+
+   wl_data_source_offer(source->data_source, source->mimetype);
+
+   /* NB: Do we add some default mimetypes here ?? */
+   /* text/plain, etc */
+
+   return source;
+}
+
+EAPI void 
+ecore_wl_drag_start(Ecore_Wl_Drag_Source *source, struct wl_surface *surface)
+{
+   wl_data_device_start_drag(source->data_dev, source->data_source, 
+                             surface, source->timestamp);
+}
+
+EAPI void 
+ecore_wl_drag_stop(void)
+{
+
+}
+
 /* local functions */
 static Eina_Bool 
 _ecore_wl_shutdown(Eina_Bool close_display) 
@@ -617,6 +662,8 @@ _ecore_wl_cb_handle_touch_down(void *data __UNUSED__, struct wl_input_device *de
 {
    Ecore_Event_Mouse_Button *ev;
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
    _ecore_wl_touch_surface = surface;
    _ecore_wl_touch_x = x;
    _ecore_wl_touch_y = y;
@@ -668,6 +715,8 @@ _ecore_wl_cb_handle_touch_up(void *data __UNUSED__, struct wl_input_device *dev
 {
    Ecore_Event_Mouse_Button *ev;
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
    if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return;
 
    ev->timestamp = timestamp;
@@ -718,6 +767,8 @@ _ecore_wl_cb_handle_touch_motion(void *data __UNUSED__, struct wl_input_device *
 {
    Ecore_Event_Mouse_Move *ev;
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
    if (!_ecore_wl_touch_surface) return;
 
    if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return;
@@ -760,12 +811,16 @@ _ecore_wl_cb_handle_touch_motion(void *data __UNUSED__, struct wl_input_device *
 static void 
 _ecore_wl_cb_handle_touch_frame(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__)
 {
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
    /* FIXME: Need to get a device and actually test what happens here */
 }
 
 static void 
 _ecore_wl_cb_handle_touch_cancel(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__)
 {
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
    /* FIXME: Need to get a device and actually test what happens here */
    _ecore_wl_touch_surface = NULL;
 }
@@ -773,25 +828,17 @@ _ecore_wl_cb_handle_touch_cancel(void *data __UNUSED__, struct wl_input_device *
 static void 
 _ecore_wl_cb_source_target(void *data, struct wl_data_source *source, const char *mime_type)
 {
-   Ecore_Wl_Event_Drag_Start *ev;
-
-   if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Drag_Start)))) return;
+   /* Ecore_Wl_Drag_Source *source; */
 
-//   wl_data_device_set_user_data(data_dev, source);
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   /* ev->device = ; */
-   /* ev->surface = ; */
-   /* ev->mime_type = mime_type; */
-   /* ev->timestamp = ; */
+   /* if (!(source = data)) return; */
 
-   /* will need to pass the device to the callback/event */
-   /* raise a callback/event to have Ecore_Evas do: */
+//   wl_data_device_set_user_data(data_dev, source);
 
    /* create a surface & buffer to represent the dragging object */
    /* attach buffer to the surface */
    /* attach to device */
-
-   ecore_event_add(ECORE_WL_EVENT_DRAG_START, ev, NULL, NULL);
 }
 
 static void 
@@ -877,7 +924,7 @@ _ecore_wl_mouse_move_send(uint32_t timestamp)
 {
    Ecore_Event_Mouse_Move *ev;
 
-   if (!_ecore_wl_input_surface) return;
+//   if (!_ecore_wl_input_surface) return;
 
    if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return;
 
index 9ec2224..6c12f57 100644 (file)
@@ -56,7 +56,27 @@ typedef struct _Ecore_Wl_Dnd_Source
 
 typedef struct _Ecore_Wl_Dnd_Target
 {
+   /* NB: These are not the real fields for this structure, 
+    * and it is Bound to change....soon */
+   struct wl_data_offer *offer;
+   int refs;
 
+   Eina_Array *types;
+
+   void *data;
 } Ecore_Wl_Dnd_Target;
 
+struct _Ecore_Wl_Drag_Source
+{
+   struct wl_data_device *data_dev;
+
+   int32_t hotspot_x, hotspot_y;
+   int32_t offset_x, offset_y;
+   const char *mimetype;
+   uint32_t timestamp;
+   void *data;
+
+   struct wl_data_source *data_source;
+};
+
 #endif