Enlightenment SVN wrote:
> Log:
> Bug 496, now internal drag and drop works without any X calls. If anyone
> knows what the format field in Ecore_X_Selection_Data is for, it'd be nice to
> know.
The format is 8, 16 or 32, indicates the block size of the data. So
sizeof(data) == len * format
Sebastian
>
> Author: jethomas
> Date: 2008-12-02 17:03:16 -0800 (Tue, 02 Dec 2008)
> New Revision: 37911
>
> Modified:
> trunk/ewl/src/bin/tests/dnd_snoop/ewl_dnd_snoop_test.c
> trunk/ewl/src/engines/x11/ewl_engine_x11.c trunk/ewl/src/lib/ewl_dnd.c
> trunk/ewl/src/lib/ewl_dnd.h trunk/ewl/src/lib/ewl_embed.c
> trunk/ewl/src/lib/ewl_embed.h trunk/ewl/src/lib/ewl_filelist_view.c
> trunk/ewl/src/lib/ewl_widget.c
>
> Modified: trunk/ewl/src/bin/tests/dnd_snoop/ewl_dnd_snoop_test.c
> ===================================================================
> --- trunk/ewl/src/bin/tests/dnd_snoop/ewl_dnd_snoop_test.c 2008-12-03
> 00:36:31 UTC (rev 37910)
> +++ trunk/ewl/src/bin/tests/dnd_snoop/ewl_dnd_snoop_test.c 2008-12-03
> 01:03:16 UTC (rev 37911)
> @@ -189,7 +189,7 @@
> {
> char buf[PATH_MAX];
> Ewl_Event_Dnd_Data_Received *ev = event;
> - snprintf(buf, PATH_MAX, "Data event on widget %p: %p length %d\n",
> w, ev->data, ev->len);
> + snprintf(buf, PATH_MAX, "Data event on widget %p: %p length %d
> format %d\n", w, ev->data, ev->len, ev->format);
> ewl_dnd_snoop_output(buf);
> }
>
> @@ -208,8 +208,7 @@
> ewl_dnd_snoop_output(buf);
> emb = ewl_embed_widget_find(w);
> if (emb)
> - ewl_engine_embed_dnd_drag_data_send(emb, ev->handle,
> - (void *)w->inheritance,
> + ewl_dnd_drag_data_send(emb, ev->handle, (void
> *)w->inheritance,
> strlen(w->inheritance) + 1);
> }
>
>
> Modified: trunk/ewl/src/engines/x11/ewl_engine_x11.c
> ===================================================================
> --- trunk/ewl/src/engines/x11/ewl_engine_x11.c 2008-12-03 00:36:31 UTC
> (rev 37910)
> +++ trunk/ewl/src/engines/x11/ewl_engine_x11.c 2008-12-03 01:03:16 UTC
> (rev 37911)
> @@ -1465,7 +1465,6 @@
> {
> Ewl_Embed *embed;
> Ecore_X_Event_Xdnd_Drop *ev;
> - int internal = 0;
>
> DENTER_FUNCTION(DLEVEL_STABLE);
> DCHECK_PARAM_PTR_RET(e, FALSE);
> @@ -1479,13 +1478,10 @@
>
> ewl_embed_window_position_get(embed, &wx, &wy);
>
> - if (ev->source == UINTPTR_TO_UINT(embed->canvas_window))
> - internal = 1;
> -
> x = ev->position.x - wx;
> y = ev->position.y - wy;
>
> - type = ewl_embed_dnd_drop_feed(embed, x, y, internal);
> + type = ewl_embed_dnd_drop_feed(embed, x, y);
> if (type)
> ecore_x_selection_xdnd_request(ev->win, (char
> *)type);
> }
>
> Modified: trunk/ewl/src/lib/ewl_dnd.c
> ===================================================================
> --- trunk/ewl/src/lib/ewl_dnd.c 2008-12-03 00:36:31 UTC (rev 37910)
> +++ trunk/ewl/src/lib/ewl_dnd.c 2008-12-03 01:03:16 UTC (rev 37911)
> @@ -5,6 +5,9 @@
> #include "ewl_debug.h"
>
> #define EWL_DND_WINDOW_ROOT 0
> +#define EWL_DRAGGING_NONE 0
> +#define EWL_DRAGGING_INTERNAL 1
> +#define EWL_DRAGGING_EXTERNAL 2
>
> unsigned int EWL_CALLBACK_DND_POSITION; /**< A DND position event **/
> unsigned int EWL_CALLBACK_DND_ENTER; /**< On enter of a widget **/
> @@ -17,6 +20,9 @@
> static int ewl_dragging_current;
> static int ewl_dnd_status;
>
> +static void *ewl_dnd_req_data;
> +static int ewl_dnd_req_data_len;
> +
> static Ewl_Widget *ewl_dnd_widget;
> static Ewl_Widget *ewl_dnd_default_cursor;
>
> @@ -60,7 +66,7 @@
> ecore_hash_free_value_cb_set(ewl_dnd_accepted_hash, free);
> ewl_dnd_widget = NULL;
> ewl_dnd_default_cursor = NULL;
> - ewl_dragging_current = 0;
> + ewl_dragging_current = EWL_DRAGGING_NONE;
> ewl_dnd_status = 1;
>
> DRETURN_INT(TRUE, DLEVEL_STABLE);
> @@ -256,42 +262,27 @@
> /**
> * @param w: The widget to start dragging
> * @return Returns no value
> - * @brief Tells the widget to start dragging
> + * @brief Creates the proper condition for internal dragging
> */
> void
> -ewl_dnd_drag_start(Ewl_Widget *w)
> +ewl_dnd_internal_drag_start(Ewl_Widget *w)
> {
> - unsigned int i;
> - char **types;
> Ewl_Embed *emb;
>
> DENTER_FUNCTION(DLEVEL_STABLE);
> DCHECK_PARAM_PTR(w);
> DCHECK_TYPE(w, EWL_WIDGET_TYPE);
>
> - if (!ewl_dnd_status || ewl_dragging_current)
> + if (!ewl_dnd_status)
> DRETURN(DLEVEL_STABLE);
>
> emb = ewl_embed_widget_find(w);
> if (!emb) DRETURN(DLEVEL_STABLE);
>
> - ewl_dragging_current = 1;
> + ewl_dragging_current = EWL_DRAGGING_INTERNAL;
> ewl_dnd_widget = w;
>
> - types = ewl_dnd_provided_types_get(w);
> /*
> - * Count the number of mime types set on the widget.
> - */
> - for (i = 0; types && types[i]; i++)
> - ;
> -
> - /*
> - * Flag the provided DND types on the embed and begin the DND
> process.
> - */
> - ewl_engine_embed_dnd_drag_types_set(emb, types, i);
> - ewl_engine_embed_dnd_drag_start(emb);
> -
> - /*
> * Create a fallback cursor to display during DND operations.
> */
> if (!ewl_dnd_default_cursor) {
> @@ -317,9 +308,50 @@
> /**
> * @param w: The widget to start dragging
> * @return Returns no value
> - * @brief Tells the widget to start dragging
> + * @brief Creates the proper condition for external dragging
> */
> void
> +ewl_dnd_external_drag_start(Ewl_Widget *w)
> +{
> + unsigned int i;
> + char ** types;
> + Ewl_Embed *emb;
> +
> + DENTER_FUNCTION(DLEVEL_STABLE);
> + DCHECK_PARAM_PTR(w);
> + DCHECK_TYPE(w, EWL_WIDGET_TYPE);
> +
> + if ((!ewl_dnd_status) || (ewl_dragging_current !=
> + EWL_DRAGGING_INTERNAL))
> + DRETURN(DLEVEL_STABLE);
> +
> + emb = ewl_embed_widget_find(w);
> + if (!emb) DRETURN(DLEVEL_STABLE);
> +
> + ewl_dragging_current = EWL_DRAGGING_EXTERNAL;
> +
> + types = ewl_dnd_provided_types_get(w);
> + /*
> + * Count the number of mime types set on the widget
> + */
> + for (i = 0; types && types[i]; i++)
> + ;
> +
> + /*
> + * Flag the provided DND types on the embed and begin the DND process
> + */
> + ewl_engine_embed_dnd_drag_types_set(emb, types, i);
> + ewl_engine_embed_dnd_drag_start(emb);
> +
> + DLEAVE_FUNCTION(DLEVEL_STABLE);
> +}
> +
> +/**
> + * @param w: The widget to stop dragging
> + * @return Returns no value
> + * @brief Tells the widget to drop its data
> + */
> +void
> ewl_dnd_drag_drop(Ewl_Widget *w)
> {
> Ewl_Embed *emb;
> @@ -328,7 +360,6 @@
> DCHECK_PARAM_PTR(w);
> DCHECK_TYPE(w, EWL_WIDGET_TYPE);
>
> - ewl_dragging_current = 0;
> ewl_dnd_widget = NULL;
>
> emb = ewl_embed_widget_find(w);
> @@ -338,12 +369,79 @@
> ewl_attach_list_del(EWL_WIDGET(emb)->attach,
> EWL_ATTACH_TYPE_MOUSE_ARGB_CURSOR);
> ewl_embed_mouse_cursor_set(EWL_WIDGET(emb));
> - ewl_engine_embed_dnd_drag_drop(emb);
>
> + if (ewl_dragging_current == EWL_DRAGGING_EXTERNAL)
> + {
> + ewl_engine_embed_dnd_drag_drop(emb);
> + }
> + else if (ewl_dragging_current == EWL_DRAGGING_INTERNAL)
> + {
> + Ewl_Event_Dnd_Data_Request req_ev;
> + Ewl_Widget *drop, *drag;
> + char ** types;
> + int i;
> +
> + drop = emb->last.drop_widget;
> + drag = emb->last.drag_widget;
> + if (!drop || !drag) DRETURN(DLEVEL_STABLE);
> +
> + types = ewl_dnd_provided_types_get(drag);
> + for (i = 0; types && types[i]; i++)
> + {
> + if (ewl_dnd_accepted_types_contains(drop, types[i]))
> + {
> + req_ev.type = types[i];
> + ewl_callback_call_with_event_data
> + (emb->last.drag_widget,
> + EWL_CALLBACK_DND_DATA_REQUEST,
> &req_ev);
> + break;
> + }
> + }
> +
> + if (!ewl_dnd_req_data || !ewl_dnd_req_data_len)
> + {
> + DWARNING("No data received for internal drop!\n");
> + DRETURN(DLEVEL_STABLE);
> + }
> +
> + /* FIXME What is the format parameter supposed to be?! */
> + ewl_embed_dnd_data_received_feed(emb, req_ev.type,
> + ewl_dnd_req_data, ewl_dnd_req_data_len, 0);
> + }
> +
> + ewl_dragging_current = EWL_DRAGGING_NONE;
> + ewl_dnd_req_data = NULL;
> + ewl_dnd_req_data_len = 0;
> +
> DLEAVE_FUNCTION(DLEVEL_STABLE);
> }
>
> /**
> + * @param emb: Embed to send to
> + * @param handle: Handle to the window
> + * @param data: Data to send
> + * @param len: The size of the data
> + */
> +void
> +ewl_dnd_drag_data_send(Ewl_Embed *emb, void *handle, void *data, int len)
> +{
> + DENTER_FUNCTION(DLEVEL_STABLE);
> + DCHECK_PARAM_PTR(emb);
> +
> + if (ewl_dragging_current == EWL_DRAGGING_INTERNAL)
> + {
> + ewl_dnd_req_data = data;
> + ewl_dnd_req_data_len = len;
> + }
> + else
> + {
> + ewl_engine_embed_dnd_drag_data_send(emb, handle, data, len);
> + }
> +
> + DRETURN(DLEVEL_STABLE);
> +}
> +
> +/**
> * @return Returns no value
> * @brief Disables DND
> */
>
> Modified: trunk/ewl/src/lib/ewl_dnd.h
> ===================================================================
> --- trunk/ewl/src/lib/ewl_dnd.h 2008-12-03 00:36:31 UTC (rev 37910)
> +++ trunk/ewl/src/lib/ewl_dnd.h 2008-12-03 01:03:16 UTC (rev 37911)
> @@ -19,8 +19,11 @@
> int ewl_dnd_init(void);
> void ewl_dnd_shutdown(void);
>
> -void ewl_dnd_drag_start(Ewl_Widget *w);
> +void ewl_dnd_internal_drag_start(Ewl_Widget *w);
> +void ewl_dnd_external_drag_start(Ewl_Widget *w);
> void ewl_dnd_drag_drop(Ewl_Widget *w);
> +void ewl_dnd_drag_data_send(Ewl_Embed *emb, void *handle,
> + void *data, int len);
> void ewl_dnd_drag_widget_clear(void);
> Ewl_Widget *ewl_dnd_drag_widget_get(void);
>
>
> Modified: trunk/ewl/src/lib/ewl_embed.c
> ===================================================================
> --- trunk/ewl/src/lib/ewl_embed.c 2008-12-03 00:36:31 UTC (rev 37910)
> +++ trunk/ewl/src/lib/ewl_embed.c 2008-12-03 01:03:16 UTC (rev 37911)
> @@ -840,7 +840,7 @@
> * @brief Sends the event for a DND drop into an embed.
> */
> const char *
> -ewl_embed_dnd_drop_feed(Ewl_Embed *embed, int x, int y, int internal
> __UNUSED__)
> +ewl_embed_dnd_drop_feed(Ewl_Embed *embed, int x, int y)
> {
> Ewl_Widget *widget = NULL, *parent = NULL;
> const char *result = NULL;
> @@ -1018,6 +1018,10 @@
> embed->last.mouse_in = embed->last.mouse_in->parent;
> }
>
> + if ((embed->last.drag_widget) && (ewl_widget_state_has
> + (embed->last.drag_widget,
> EWL_FLAG_STATE_DND)))
> + ewl_dnd_external_drag_start(embed->last.drag_widget);
> +
> DLEAVE_FUNCTION(DLEVEL_STABLE);
> }
>
>
> Modified: trunk/ewl/src/lib/ewl_embed.h
> ===================================================================
> --- trunk/ewl/src/lib/ewl_embed.h 2008-12-03 00:36:31 UTC (rev 37910)
> +++ trunk/ewl/src/lib/ewl_embed.h 2008-12-03 01:03:16 UTC (rev 37911)
> @@ -129,8 +129,7 @@
>
> const char *ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y,
> int *, int *, int *, int *);
> -const char *ewl_embed_dnd_drop_feed(Ewl_Embed* embed, int x, int y,
> - int internal);
> +const char *ewl_embed_dnd_drop_feed(Ewl_Embed* embed, int x, int y);
> void ewl_embed_dnd_data_received_feed(Ewl_Embed* embed, char
> *type,
> void *data, unsigned int len,
> unsigned int format);
>
> Modified: trunk/ewl/src/lib/ewl_filelist_view.c
> ===================================================================
> --- trunk/ewl/src/lib/ewl_filelist_view.c 2008-12-03 00:36:31 UTC (rev
> 37910)
> +++ trunk/ewl/src/lib/ewl_filelist_view.c 2008-12-03 01:03:16 UTC (rev
> 37911)
> @@ -82,8 +82,7 @@
> len = strlen(buf);
> }
>
> - ewl_engine_embed_dnd_drag_data_send(emb, ev->handle,
> - (void *)uri, len);
> + ewl_dnd_drag_data_send(emb, ev->handle, (void *)uri, len);
>
> DLEAVE_FUNCTION(DLEVEL_STABLE);
> }
>
> Modified: trunk/ewl/src/lib/ewl_widget.c
> ===================================================================
> --- trunk/ewl/src/lib/ewl_widget.c 2008-12-03 00:36:31 UTC (rev 37910)
> +++ trunk/ewl/src/lib/ewl_widget.c 2008-12-03 01:03:16 UTC (rev 37911)
> @@ -3181,7 +3181,7 @@
> if (!ewl_widget_state_has(w, EWL_FLAG_STATE_DND)) {
> ewl_widget_state_add(w, EWL_FLAG_STATE_DND);
> embed->last.drag_widget = w;
> - ewl_dnd_drag_start(w);
> + ewl_dnd_internal_drag_start(w);
> }
>
> if (ev && (ev->x > CURRENT_X(embed) &&
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> enlightenment-svn mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel