Enlightenment CVS committal Author : lordchaos Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: Ewl.h.in Makefile.am ewl_embed.c ewl_embed.h ewl_events.c ewl_events.h ewl_iconbox.c ewl_misc.c ewl_window.h Added Files: ewl_dnd.c ewl_dnd.h Log Message: * Added file for dnd helper functions =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/Ewl.h.in,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- Ewl.h.in 25 Oct 2005 16:03:51 -0000 1.24 +++ Ewl.h.in 27 Nov 2005 09:44:14 -0000 1.25 @@ -326,6 +326,7 @@ #include <ewl_paned.h> #include <ewl_scrollpane.h> #include <ewl_statusbar.h> +#include <ewl_dnd.h> #include <ewl_tree.h> =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/Makefile.am,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- Makefile.am 25 Oct 2005 16:03:51 -0000 1.15 +++ Makefile.am 27 Nov 2005 09:44:14 -0000 1.16 @@ -29,6 +29,7 @@ ewl_datepicker.h \ ewl_debug.h \ ewl_dialog.h \ + ewl_dnd.h \ ewl_embed.h \ ewl_entry.h \ ewl_enums.h \ @@ -92,6 +93,7 @@ ewl_container.c \ ewl_datepicker.c \ ewl_dialog.c \ + ewl_dnd.c \ ewl_embed.c \ ewl_entry.c \ ewl_events.c \ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- ewl_embed.c 21 Nov 2005 04:13:41 -0000 1.23 +++ ewl_embed.c 27 Nov 2005 09:44:14 -0000 1.24 @@ -698,22 +698,51 @@ widget = ewl_container_child_at_recursive_get(EWL_CONTAINER(embed), x, y); if (widget) { - Ewl_Widget* parent = widget; + Ewl_Widget* parent; Ewl_Window* window; + + + /*First see if we need to send an 'enter' to this widget*/ + window = ewl_window_window_find(embed->evas_window); + + /*If the last position event was over a different widget, + * feed the leaving widget a 'null'*/ + if (window->dnd_last_position != widget) { + + if (window->dnd_last_position) { + parent = window->dnd_last_position; + while (parent) { + ewl_callback_call_with_event_data(parent, + EWL_CALLBACK_DND_LEAVE, &ev); + parent = parent->parent; + } + } -// printf("Found widget %p\n", widget); + /*ewl_callback_call_with_event_data(widget, + EWL_CALLBACK_DND_ENTER, &ev);*/ + parent = widget; + while (parent) { + ewl_callback_call_with_event_data(parent, + EWL_CALLBACK_DND_ENTER, &ev); + parent = parent->parent; + } + + } + /* - * Pass the event up the chain + * Pass the position event up the chain */ + parent = widget; while (parent) { ewl_callback_call_with_event_data(parent, EWL_CALLBACK_DND_POSITION, &ev); - parent = parent->parent; } - ewl_callback_call_with_event_data(widget, - EWL_CALLBACK_DND_POSITION, &ev); + /*ewl_callback_call_with_event_data(widget, + EWL_CALLBACK_DND_POSITION, &ev);*/ + + window->dnd_last_position = widget; } else { DWARNING("Could not find widget for dnd position event"); } @@ -721,6 +750,12 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } + + + + + + /** * @param embed: the embed where the mouse event is to occur * @param x: the x coordinate of the mouse out =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ewl_embed.h 20 Nov 2005 03:03:34 -0000 1.8 +++ ewl_embed.h 27 Nov 2005 09:44:14 -0000 1.9 @@ -95,6 +95,7 @@ unsigned int modifiers); void ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y); +void ewl_embed_dnd_enter_feed(Ewl_Embed *embed, int x, int y, void* dnd_event); void ewl_embed_mouse_out_feed(Ewl_Embed *embed, int x, int y, unsigned int modifiers); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_events.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_events.c 21 Nov 2005 04:13:41 -0000 1.10 +++ ewl_events.c 27 Nov 2005 09:44:14 -0000 1.11 @@ -21,6 +21,10 @@ int ewl_ev_x_paste(void *data, int type, void *_ev); int ewl_ev_dnd_position(void *data, int type, void *_ev); +int ewl_ev_dnd_enter(void *data, int type, void *_ev); +int ewl_ev_dnd_leave(void *data, int type, void *_ev); +int ewl_ev_dnd_drop(void *data, int type, void *_ev); +int ewl_ev_dnd_selection_notify(void *data, int type, void *_ev); #endif #ifdef ENABLE_EWL_FB @@ -69,6 +73,14 @@ */ ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, ewl_ev_dnd_position, NULL); + ecore_event_handler_add(ECORE_X_EVENT_XDND_ENTER, + ewl_ev_dnd_enter, NULL); + ecore_event_handler_add(ECORE_X_EVENT_XDND_LEAVE, + ewl_ev_dnd_leave, NULL); + ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, + ewl_ev_dnd_drop, NULL); + ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, + ewl_ev_dnd_selection_notify, NULL); /* * Finally, register dispatching functions for mouse events. @@ -498,11 +510,15 @@ * Dispatches the mouse out event to the appropriate ewl window. */ int -ewl_ev_x_paste(void *data __UNUSED__, int type __UNUSED__, void *e __UNUSED__) +ewl_ev_x_paste(void *data __UNUSED__, int type __UNUSED__, void *e) { + Ecore_X_Event_Selection_Notify *ev = e; + DENTER_FUNCTION(DLEVEL_STABLE); - printf("Paste event received\n"); + /*Handle everything *except* XDND selection*/ + if (ev->selection != ECORE_X_SELECTION_XDND) + printf("Paste event received\n"); DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -536,17 +552,16 @@ ewl_window_position_get(EWL_WINDOW(window), &wx, &wy); x = ev->position.x - wx; y = ev->position.y - wy; - //printf("Received event at window pos (%d:%d), %d:%d\n",CURRENT_X(window), CURRENT_Y(window), x,y); /* * Look for the child here */ embed = ewl_embed_evas_window_find((void *)ev->win); if (embed) { - //printf("Found embed, feeding..\n"); + + /*First see if we need to send an 'enter' to the widget*/ ewl_embed_dnd_position_feed(embed, x, y); } else { - //printf("Could not find embed for window..\n"); } rect.x = 0; @@ -558,6 +573,156 @@ DRETURN_INT(TRUE, DLEVEL_STABLE); } +/** + * @param data: user specified data passed to the function + * @param type: the type of event triggering the function call + * @param e: the dnd 'enter' information + * @return Returns TRUE on success or FALSE on failure. + * @brief Handles the data for an XDND position event + * + * Tells an XDND source if we can accept DND at this window location + */ +int +ewl_ev_dnd_enter(void *data __UNUSED__, int type __UNUSED__, void *e) +{ + Ewl_Window *window; + Ecore_X_Event_Xdnd_Enter *ev; + Ecore_X_Rectangle rect; + int i=0; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("e", e, FALSE); + + ev = e; + + window = ewl_window_window_find((void *)ev->win); + if (window) { + /*printf("Assigned enter types to window - '%s'\n", ev->types[0]);*/ + window->dnd_types.num_types = ev->num_types; + window->dnd_types.types = malloc(sizeof(char*) * ev->num_types); + + for (i=0;i<ev->num_types;i++) + window->dnd_types.types[i] = strdup(ev->types[i]); + } + DRETURN_INT(TRUE, DLEVEL_STABLE); +} + +/** + * @param data: user specified data passed to the function + * @param type: the type of event triggering the function call + * @param e: the dnd 'leave' information + * @return Returns TRUE on success or FALSE on failure. + * @brief Handles the data for an XDND position event + * + * Tells an XDND source if we can accept DND at this window location + */ +int +ewl_ev_dnd_leave(void *data __UNUSED__, int type __UNUSED__, void *e) +{ + Ewl_Window *window; + Ecore_X_Event_Xdnd_Leave *ev; + int i; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("e", e, FALSE); + + ev = e; + + window = ewl_window_window_find((void *)ev->win); + if (window) { + if (window->dnd_types.num_types > 0) { + for (i=0;i<window->dnd_types.num_types;i++) + free(window->dnd_types.types[i]); + + free(window->dnd_types.types); + window->dnd_types.types = NULL; + } + } + DRETURN_INT(TRUE, DLEVEL_STABLE); +} + + +/** + * @param data: user specified data passed to the function + * @param type: the type of event triggering the function call + * @param e: the dnd 'drop' information + * @return Returns TRUE on success or FALSE on failure. + * @brief Handles the data for an XDND position event + * + * A notification from a DND source that we have accepted a drop + */ +int +ewl_ev_dnd_drop(void *data __UNUSED__, int type __UNUSED__, void *e) +{ + Ewl_Window *window; + Ecore_X_Event_Xdnd_Drop *ev; + int i; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("e", e, FALSE); + + ev = e; + + window = ewl_window_window_find((void *)ev->win); + if (window) { + /*printf("EWL got a DND drop event..\n");*/ + + /*Request a DND data request*/ + /*TODO this only supports retrieval of the first type in the request*/ + if (window->dnd_types.num_types > 0) + ecore_x_selection_xdnd_request(ev->win, + window->dnd_types.types[0]); + + } + + DRETURN_INT(TRUE, DLEVEL_STABLE); +} + + +/** + * @param data: user specified data passed to the function + * @param type: the type of event triggering the function call + * @param e: the dnd 'selection' information + * @return Returns TRUE on success or FALSE on failure. + * @brief Handles the data for an XDND selection notify event + * + * A notification from a DND source that the selection data is ready + */ +int +ewl_ev_dnd_selection_notify(void *data __UNUSED__, int type __UNUSED__, void *e) +{ + Ewl_Window *window; + Ecore_X_Event_Selection_Notify *ev; + int i; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("e", e, FALSE); + + ev = e; + + if (ev->selection == ECORE_X_SELECTION_XDND) { + /*printf("EWL DND selection notify\n");*/ + + window = ewl_window_window_find((void *)ev->win); + if (window) { + /*printf(" ...Got a winow target for the DND selection event..\n");*/ + + /*printf("Content: %d\n",ev->content); + if (ev->content == ECORE_X_SELECTION_CONTENT_FILES) { + Ecore_X_Selection_Data_Files* files = ev->data; + printf("We've got some files! - '%s'\n", files->files[0]); + } else { + Ecore_X_Selection_Data_Files* files = ev->data; + printf("We've got some files! - '%s'\n", files->files[0]); + }*/ + } + + } + + DRETURN_INT(TRUE, DLEVEL_STABLE); +} + + #endif #ifdef ENABLE_EWL_FB =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_events.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_events.h 19 Aug 2005 18:14:21 -0000 1.4 +++ ewl_events.h 27 Nov 2005 09:44:14 -0000 1.5 @@ -155,6 +155,13 @@ int dir; /**< Direction mouse wheel scrolled */ }; +typedef struct Ewl_Dnd_Types +{ + int num_types; + char** types; + +} Ewl_Dnd_Types; + int ewl_ev_init(void); unsigned int ewl_ev_modifiers_get(); void ewl_ev_modifiers_set(unsigned int modifiers); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v retrieving revision 1.83 retrieving revision 1.84 diff -u -3 -r1.83 -r1.84 --- ewl_iconbox.c 24 Nov 2005 22:12:29 -0000 1.83 +++ ewl_iconbox.c 27 Nov 2005 09:44:14 -0000 1.84 @@ -861,6 +861,7 @@ Ewl_IconBox* ib = EWL_ICONBOX(user_data); Ewl_IconBox_Icon* list_item = ib->select_icon; Ewl_Event_Mouse_Move *ev = ev_data; + Ewl_Dnd_Types* types; ibx = ewl_object_current_x_get(EWL_OBJECT(ib)); iby = ewl_object_current_y_get(EWL_OBJECT(ib)); @@ -873,6 +874,14 @@ fh= ewl_object_preferred_h_get(EWL_OBJECT(list_item->image)); ewl_floater_position_set(EWL_FLOATER(list_item->floater), (ev->x - ibx) + abs(px-ibx) - (fw/2), (ev->y - iby) + abs(py-iby) - (fh/2)); + + /*Get types*/ + if ( (types = ewl_dnd_types_for_widget_get(EWL_WIDGET(ib)))) { + printf("We have %d types!\n", types->num_types); + if (types->num_types > 0) { + printf("First type is '%s'\n", types->types[0]); + } + } @@ -1174,20 +1183,20 @@ if (REALIZED(ib) && VISIBLE(ib)) { - ewl_callback_del(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, ewl_iconbox_configure_cb); + /*ewl_callback_del(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, ewl_iconbox_configure_cb);*/ ewl_iconbox_inner_pane_calculate(EWL_ICONBOX(w)); ewl_iconbox_icon_arrange(ib); if (ib->background) { int w,h; - w = CURRENT_W(ib); - h= CURRENT_H(ib); + w = CURRENT_W(ib->ewl_iconbox_pane_inner); + h= CURRENT_H(ib->ewl_iconbox_pane_inner); ewl_object_position_request(EWL_OBJECT(ib->background),0,0); ewl_object_custom_size_set(EWL_OBJECT(ib->background),w,h); } - ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, ewl_iconbox_configure_cb, NULL); + /*ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, ewl_iconbox_configure_cb, NULL);*/ } } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_misc.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- ewl_misc.c 22 Nov 2005 17:28:15 -0000 1.28 +++ ewl_misc.c 27 Nov 2005 09:44:14 -0000 1.29 @@ -877,7 +877,7 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } -#define EWL_GC_LIMIT 300 +#define EWL_GC_LIMIT 300 /** * @return Returns TRUE if objects remain to be freed, otherwise false. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_window.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_window.h 20 Nov 2005 03:03:34 -0000 1.7 +++ ewl_window.h 27 Nov 2005 09:44:14 -0000 1.8 @@ -49,6 +49,9 @@ int x; /**< Screen relative horizontal position of window */ int y; /**< Screen relative vertical position of window */ char *render; /**< The render engine in use */ + + Ewl_Dnd_Types dnd_types; + Ewl_Widget* dnd_last_position; }; Ewl_Widget *ewl_window_new(void); ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs