Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_dnd.c ewl_dnd.h ewl_embed.c ewl_embed.h ewl_enums.h 
        ewl_events.c ewl_events.h ewl_iconbox.c ewl_iconbox.h 
        ewl_misc.c ewl_tree.c ewl_widget.c ewl_widget.h ewl_window.c 


Log Message:
* EWL Drag and Drop - Stage 2 (Drag Support).  Stage 3 will include accepting 
drops from remote (non-local-app) sources.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_dnd.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_dnd.c   29 Nov 2005 02:11:50 -0000      1.3
+++ ewl_dnd.c   22 Dec 2005 04:29:44 -0000      1.4
@@ -2,6 +2,44 @@
 #include "ewl_debug.h"
 #include "ewl_macros.h"
 #include "ewl_private.h"
+#include <Ecore_Evas.h>
+#include <Ecore_X.h>
+
+#define WINDOW_ROOT 0
+static int ewl_dragging_current = 0;
+static int ewl_dnd_move_count = 0;
+static Ecore_Evas* _ewl_dnd_drag_canvas;
+static Evas* _ewl_dnd_drag_evas;
+static Evas_Object* _ewl_dnd_evas_object;
+static Evas_Object* _ewl_dnd_drag_image;
+static Ecore_X_Window _ewl_dnd_evas_win;
+static Ecore_X_Window _ewl_dnd_drag_win = 0;
+
+static Ewl_Widget* _ewl_dnd_widget = NULL;
+
+static Ecore_Hash* ewl_dnd_position_hash;
+static int _ewl_dnd_status=0;
+
+Ecore_Event_Handler* _ewl_dnd_mouse_up_handler;
+Ecore_Event_Handler* _ewl_dnd_mouse_move_handler;
+
+
+char *drop_types[] = { "text/uri-list" };
+char *data[] = { "file:///home/chaos/wlan-key2" };
+
+
+void ewl_dnd_init() {
+       ewl_dnd_position_hash = ecore_hash_new(ecore_direct_hash, 
ecore_direct_compare);
+       ewl_dragging_current = 0;
+       _ewl_dnd_status = 1;
+}
+
+
+void ewl_dnd_position_windows_set(Ewl_Widget* w) {
+       ecore_hash_set(ewl_dnd_position_hash, w, (void*)1);
+}
+
+
 
 Ewl_Dnd_Types *
 ewl_dnd_types_for_widget_get(Ewl_Widget *widget)
@@ -27,3 +65,162 @@
        DRETURN_PTR(NULL, DLEVEL_STABLE);
 }
 
+
+
+static int
+_ewl_dnd_event_dnd_move(void *data, int type, void *event)
+{
+       Ecore_X_Event_Mouse_Move *ev;
+       ev = event;
+
+       if (!_ewl_dnd_status) return 1;
+
+       //printf("%d:%d\n", ev->x, ev->y);
+       ewl_dnd_move_count++;
+
+       if (ewl_dnd_move_count == 1) {
+               ecore_evas_show(_ewl_dnd_drag_canvas);
+       }
+
+       if (_ewl_dnd_drag_canvas) ecore_evas_move(_ewl_dnd_drag_canvas, ev->x - 
15, ev->y - 15);
+
+
+       return 1;
+}
+
+
+static int
+_ewl_dnd_event_mouse_up(void *data, int type, void *event)
+{
+       printf("mouse up..\n");
+
+       if (_ewl_dnd_drag_canvas && ewl_dragging_current) {
+               Ecore_List* pos;
+               void* val;
+
+               ecore_x_pointer_ungrab();
+               ecore_x_keyboard_ungrab();
+
+               ecore_event_handler_del(_ewl_dnd_mouse_up_handler);
+               ecore_event_handler_del(_ewl_dnd_mouse_move_handler);
+       
+               //evas_object_del(_ewl_dnd_drag_image);
+               ecore_evas_free(_ewl_dnd_drag_canvas);
+               //ecore_evas_hide(_ewl_dnd_drag_canvas);
+               _ewl_dnd_drag_canvas = NULL;
+
+
+               ecore_x_window_del(_ewl_dnd_drag_win);
+               
+       
+               //ecore_x_window_del(_ewl_dnd_evas_win);
+               ecore_x_dnd_drop();
+
+               /* Kill all last position references so they don't get
+                * carried over to the next drag */
+               pos = ecore_hash_keys(ewl_dnd_position_hash);
+               ecore_list_goto_first(pos);
+               while ( (val = ecore_list_remove_first(pos)) ) {
+                       EWL_WINDOW(val)->dnd_last_position = NULL;
+                       ecore_hash_remove(ewl_dnd_position_hash, val);
+               }
+               ecore_list_destroy(pos);
+
+               ewl_dragging_current = 0;
+               ewl_widget_dnd_reset();
+       }
+
+       return 1;
+       
+}
+
+
+void ewl_drag_start(Ewl_Widget* w) {
+       int width,height;
+
+       if (!_ewl_dnd_status) return;
+
+       if (ewl_dragging_current) {
+               printf("ERR: ewl already dragging\n");
+               return;
+       }
+
+       ewl_dragging_current = 1;
+       _ewl_dnd_widget = w;
+       ewl_dnd_move_count = 0;
+
+       
+       _ewl_dnd_mouse_up_handler = 
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_UP,_ewl_dnd_event_mouse_up, 
NULL);
+       _ewl_dnd_mouse_move_handler = 
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_MOVE, _ewl_dnd_event_dnd_move, 
NULL);
+
+       _ewl_dnd_drag_canvas = ecore_evas_software_x11_new(NULL, WINDOW_ROOT, 
64,64,64,64); 
+       _ewl_dnd_drag_evas = ecore_evas_get(_ewl_dnd_drag_canvas);
+
+       ecore_evas_shaped_set(_ewl_dnd_drag_canvas, 1);
+       ecore_evas_software_x11_direct_resize_set(_ewl_dnd_drag_canvas,1);
+
+       _ewl_dnd_evas_win = 
ecore_evas_software_x11_window_get(_ewl_dnd_drag_canvas);
+       ecore_x_window_resize(_ewl_dnd_evas_win, 64,64);
+       ecore_evas_override_set(_ewl_dnd_drag_canvas, 1);
+
+       
+       //ecore_evas_software_x11_direct_resize_set(_ewl_dnd_drag_evas,1);
+       ecore_evas_ignore_events_set(_ewl_dnd_drag_canvas, 1);
+
+
+
+       /*Setup a cursor*/
+       _ewl_dnd_drag_image = evas_object_image_add(_ewl_dnd_drag_evas);
+       evas_object_image_file_set(_ewl_dnd_drag_image, PACKAGE_DATA_DIR 
"/images/World.png",0);        
+       evas_object_image_fill_set(_ewl_dnd_drag_image, 0,0,50,50);
+       evas_object_resize(_ewl_dnd_drag_image, 50,50);
+       evas_object_show(_ewl_dnd_drag_image);
+       
+
+
+
+       /*Setup the dnd event capture window*/
+       ecore_x_window_geometry_get(WINDOW_ROOT, NULL, NULL, &width,  &height);
+       _ewl_dnd_drag_win = ecore_x_window_input_new(WINDOW_ROOT, 
+               0, 0,
+               width,height);
+
+       /*Finally show the drag window*/
+       ecore_x_window_show(_ewl_dnd_drag_win);
+
+
+       /*Confine the pointer to our event windows*/    
+       ecore_x_pointer_confine_grab(_ewl_dnd_drag_win);
+       ecore_x_keyboard_grab(_ewl_dnd_drag_win);
+
+       ecore_x_dnd_aware_set(_ewl_dnd_drag_win, 1);
+       ecore_x_dnd_aware_set(_ewl_dnd_evas_win, 1);
+       ecore_x_mwm_borderless_set(_ewl_dnd_evas_win, 1);
+       
+       /*Start the drag operation*/
+       ecore_x_dnd_types_set(_ewl_dnd_drag_win, drop_types, 1);
+       ecore_x_dnd_begin(_ewl_dnd_drag_win, NULL, 0);
+
+
+}
+
+
+void ewl_dnd_disable() {
+       _ewl_dnd_status=0;
+}
+
+void ewl_dnd_enable() {
+       _ewl_dnd_status=1;
+}
+
+int ewl_dnd_status_get() {
+       return _ewl_dnd_status;
+}
+
+Ewl_Widget* ewl_dnd_drag_widget_get() {
+       return _ewl_dnd_widget;
+}
+
+void ewl_dnd_drag_widget_clear() {
+       _ewl_dnd_widget = NULL;
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_dnd.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_dnd.h   29 Nov 2005 02:11:50 -0000      1.3
+++ ewl_dnd.h   22 Dec 2005 04:29:44 -0000      1.4
@@ -2,6 +2,10 @@
 #define __EWL_DND_H__
 
 Ewl_Dnd_Types *ewl_dnd_types_for_widget_get(Ewl_Widget *widget);
+void ewl_drag_start(Ewl_Widget* w);
+void ewl_dnd_position_windows_set(Ewl_Widget* w);
+void ewl_dnd_init();
+Ewl_Widget* ewl_dnd_drag_widget_get();
 
 #endif
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ewl_embed.c 15 Dec 2005 01:59:54 -0000      1.31
+++ ewl_embed.c 22 Dec 2005 04:29:44 -0000      1.32
@@ -683,6 +683,66 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+
+
+/**
+ * @param embed: the embed where the DND drop event is to occur
+ * @param x: the x coordinate of the mouse drop
+ * @param y: the y coordinate of the mouse drop
+ * @return Returns no value.
+ * @brief Sends the event for a DND drop into an embed.
+ */
+void
+ewl_embed_dnd_drop_feed(Ewl_Embed *embed, int x, int y, int internal)
+{
+       Ewl_Widget *widget = NULL;
+       Ewl_Event_Dnd_Drop ev;
+       void* drop_data = NULL;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("embed", embed);
+       DCHECK_TYPE("embed", embed, "embed");
+
+       ewl_embed_active_set(embed, TRUE);
+
+       ev.x = x;
+       ev.y = y;
+
+       widget = ewl_container_child_at_recursive_get(EWL_CONTAINER(embed), x, 
y);
+       if (widget) {
+               Ewl_Widget *parent;
+               
+               
+               if (internal) {
+                       void* (*cb)();
+                       
+                       /*Retrieve the callback for this widget's data*/
+                       cb = ewl_widget_data_get(widget, "DROP_CB");
+                       if (cb) { 
+                               drop_data = (*cb)();
+                               ev.data = drop_data;
+                       }
+               } else {
+                       /*Handle external drops*/
+                       ev.data = NULL;
+               }
+               
+               parent = widget;
+               while (parent) {
+                       ewl_callback_call_with_event_data(parent,
+                               EWL_CALLBACK_DND_DROP, &ev);
+                       parent = parent->parent;
+               }
+
+               ewl_dnd_drag_widget_clear();
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+
+
+
 /**
  * @param embed: the embed where the DND position event is to occur
  * @param x: the x coordinate of the mouse move
@@ -691,7 +751,7 @@
  * @brief Sends the event for a DND position into an embed.
  */
 void
-ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y)
+ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y, int* px, int* py, 
int* pw, int* ph)
 {
        Ewl_Widget *widget = NULL;
        Ewl_Event_Mouse_Move ev;
@@ -738,13 +798,20 @@
                 * 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_dnd_position_windows_set(window);
                window->dnd_last_position = widget;
+
+               *px = CURRENT_X(widget);
+               *py = CURRENT_Y(widget);
+               *pw = CURRENT_W(widget);
+               *ph = CURRENT_H(widget);
        } else {
                DWARNING("Could not find widget for dnd position event");
        }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_embed.h 27 Nov 2005 09:44:14 -0000      1.9
+++ ewl_embed.h 22 Dec 2005 04:29:44 -0000      1.10
@@ -94,8 +94,9 @@
 void            ewl_embed_mouse_move_feed(Ewl_Embed *embed, int x, int y,
                                          unsigned int modifiers);
 
-void           ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int y);
+void           ewl_embed_dnd_position_feed(Ewl_Embed *embed, int x, int 
y,int*,int*,int*,int*);
 void           ewl_embed_dnd_enter_feed(Ewl_Embed *embed, int x, int y, void* 
dnd_event);
+void           ewl_embed_dnd_drop_feed(Ewl_Embed* , int x, int y, int 
internal);
 
 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_enums.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- ewl_enums.h 2 Dec 2005 21:07:39 -0000       1.29
+++ ewl_enums.h 22 Dec 2005 04:29:44 -0000      1.30
@@ -47,6 +47,7 @@
        EWL_CALLBACK_DND_POSITION, /** A DND position event **/
        EWL_CALLBACK_DND_ENTER, /** On enter of a widget **/
        EWL_CALLBACK_DND_LEAVE, /** On exit of a widget **/
+       EWL_CALLBACK_DND_DROP, /** Drop event **/
        
        EWL_CALLBACK_MAX /**< Flag to indicate last value */
 };
@@ -153,7 +154,10 @@
        EWL_FLAG_STATE_DND = 0x4000000,
        EWL_FLAG_STATE_DISABLED = 0x8000000,
 
-       EWL_FLAG_PROPERTY_DND_AWARE     = 0x10000000
+       EWL_FLAG_PROPERTY_DND_AWARE     = 0x10000000,
+       EWL_FLAG_PROPERTY_DRAGGABLE     = 0x20000000,
+       EWL_FLAG_STATE_DND_WAIT         = 0x40000000,
+       
 };
 
 #define EWL_FLAG_FILL_NORMAL (EWL_FLAG_FILL_FILL)
@@ -171,7 +175,8 @@
 
 #define EWL_FLAGS_PROPERTY_MASK (EWL_FLAG_PROPERTY_RECURSIVE | \
                EWL_FLAG_PROPERTY_TOPLEVEL | EWL_FLAG_PROPERTY_INTERNAL | \
-               EWL_FLAG_PROPERTY_BLOCK_TAB_FOCUS | EWL_FLAG_PROPERTY_FOCUSABLE)
+               EWL_FLAG_PROPERTY_BLOCK_TAB_FOCUS | EWL_FLAG_PROPERTY_FOCUSABLE 
| \
+               EWL_FLAG_PROPERTY_DND_AWARE | EWL_FLAG_PROPERTY_DRAGGABLE )
 
 #define EWL_FLAGS_QUEUED_MASK (EWL_FLAG_QUEUED_CSCHEDULED | \
                EWL_FLAG_QUEUED_RSCHEDULED | EWL_FLAG_QUEUED_DSCHEDULED | \
@@ -181,7 +186,7 @@
 #define EWL_FLAGS_STATE_MASK (EWL_FLAG_STATE_NORMAL | \
                EWL_FLAG_STATE_MOUSE_IN | EWL_FLAG_STATE_PRESSED | \
                EWL_FLAG_STATE_FOCUSED | EWL_FLAG_STATE_DND | \
-               EWL_FLAG_STATE_DISABLED)
+               EWL_FLAG_STATE_DISABLED | EWL_FLAG_STATE_DND_WAIT)
 
 /**
  * @enum Ewl_Position
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_events.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ewl_events.c        17 Dec 2005 21:55:55 -0000      1.14
+++ ewl_events.c        22 Dec 2005 04:29:44 -0000      1.15
@@ -216,14 +216,17 @@
         */
        if ((ev->x != window->x)) {
                window->x = ev->x;
-               ewl_widget_configure(EWL_WIDGET(window));
        }
 
        if ((ev->y != window->y)) {
                window->y = ev->y;
-               ewl_widget_configure(EWL_WIDGET(window));
+               
+
+
        }
 
+       ewl_widget_configure(EWL_WIDGET(window));
+
        /*
         * Configure events really only need to occur on resize.
         */
@@ -541,6 +544,7 @@
        Ewl_Window *window;
        Ecore_X_Event_Xdnd_Position *ev;
        int x, y, wx, wy;
+       int px,py,pw,ph;
        Ecore_X_Rectangle rect;
        
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -562,13 +566,25 @@
                embed = ewl_embed_evas_window_find((void *)ev->win);
                if (embed) {
                        /* First see if we need to send an 'enter' to the 
widget */
-                       ewl_embed_dnd_position_feed(embed, x, y);
+                       ewl_embed_dnd_position_feed(embed, x, y, 
&px,&py,&pw,&ph);
+                       
+                       /*rect.x = px;
+                       rect.y = py;
+                       rect.width = pw;
+                       rect.height = ph;*/
+
+                       rect.x = 0;
+                       rect.y = 0;
+                       rect.width = 0;
+                       rect.height = 0;                                
+
+                       //printf("No more position until %d:%d:%d:%d\n", 
px,py,pw,ph);
+               } else {
+                       rect.x = 0;
+                       rect.y = 0;
+                       rect.width = 0;
+                       rect.height = 0;        
                }
-               
-               rect.x = 0;
-               rect.y = 0;
-               rect.width = 0;
-               rect.height = 0;        
                ecore_x_dnd_send_status(1, 0, rect, ECORE_X_DND_ACTION_PRIVATE);
        }
 
@@ -637,6 +653,8 @@
 
                        FREE(window->dnd_types.types);
                        window->dnd_types.types = NULL;
+                       window->dnd_types.num_types = 0;
+                       
                }
        }
        DRETURN_INT(TRUE, DLEVEL_STABLE);
@@ -657,6 +675,7 @@
 {
        Ewl_Window *window;
        Ecore_X_Event_Xdnd_Drop *ev;
+       int internal = 0;
        
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("e", e, FALSE);
@@ -665,6 +684,12 @@
 
        window = ewl_window_window_find((void *)ev->win);
        if (window) {
+               int x,y,wx,wy;
+               Ewl_Embed *embed= ewl_embed_evas_window_find((void *)ev->win);
+               ewl_window_position_get(EWL_WINDOW(window), &wx, &wy);
+
+               printf("Wx/y: %d:%d\n", wx,wy);
+               
                /*printf("EWL got a DND drop event..\n");*/
 
                /* Request a DND data request */
@@ -672,6 +697,24 @@
                if (window->dnd_types.num_types > 0)
                        ecore_x_selection_xdnd_request(ev->win, 
                                window->dnd_types.types[0]);
+
+
+               printf("Drop!\n");
+
+
+               if (ev->win == (Ecore_X_Window)window->window) {
+                       printf("Source is dest! - Retrieving local data\n");
+                       internal = 1;
+               } else {
+                       printf("Source is not dest\n");
+                       //printf("%d:%d:%d\n", ev->source, ev->win,x_window);
+                       //ecore_x_selection_xdnd_request(ev->win, 
"text/uri-list");
+               }
+
+               x = ev->position.x - wx;
+               y = ev->position.y - wy;
+               
+               ewl_embed_dnd_drop_feed(embed, x, y, internal);
        }
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_events.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_events.h        4 Dec 2005 16:56:30 -0000       1.7
+++ ewl_events.h        22 Dec 2005 04:29:44 -0000      1.8
@@ -168,6 +168,20 @@
        
 };
 
+/**
+ * @struct Ewl_Event_Dnd_Drop
+ * Provides information about dnd drops movement
+ */
+struct Ewl_Event_Dnd_Drop
+{
+        int x; /**< X coordinate the mouse moved to */
+        int y; /**< Y coordinate the mouse moved to */
+       void* data; /**< Data from drop source      */
+};
+typedef struct Ewl_Event_Dnd_Drop Ewl_Event_Dnd_Drop;
+
+
+
 typedef struct Ewl_Dialog_Event Ewl_Dialog_Event;
 
 /**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -3 -r1.95 -r1.96
--- ewl_iconbox.c       11 Dec 2005 21:56:17 -0000      1.95
+++ ewl_iconbox.c       22 Dec 2005 04:29:44 -0000      1.96
@@ -11,6 +11,10 @@
 #define ICONBOX_REPEAT 10000
 
 
+void* ewl_iconbox_drag_data_get() {
+       printf("Request for drag data!\n");
+       return NULL;
+}
 
 
 int
@@ -19,8 +23,10 @@
        int height=0;
        int ww,hh;
 
-       
evas_object_textblock_size_native_get(EWL_TEXT(icon->w_label)->textblock, &ww, 
&hh);
-       height = CURRENT_H(icon->image) + hh;
+       if (EWL_TEXT(icon->w_label)->textblock) {
+               
evas_object_textblock_size_native_get(EWL_TEXT(icon->w_label)->textblock, &ww, 
&hh);
+               height = CURRENT_H(icon->image) + hh;
+       }
 
        
 
@@ -72,8 +78,8 @@
 ewl_iconbox_icon_floater_resize(Ewl_Widget *w __UNUSED__, void *ev_data, void* 
user_data)
 {
        Ewl_IconBox_Icon* icon = EWL_ICONBOX_ICON(user_data);
-       int height = ewl_iconbox_icon_label_height_calculate(icon);
-       int width = CURRENT_W(icon->image);
+       int height = ewl_iconbox_icon_label_height_calculate(icon) + 10;
+       int width = CURRENT_W(icon->image) + 10;
 
        ewl_callback_del(w, EWL_CALLBACK_CONFIGURE, 
ewl_iconbox_icon_floater_resize);
 
@@ -390,11 +396,9 @@
        ewl_callback_append(ib->ewl_iconbox_pane_inner, 
EWL_CALLBACK_MOUSE_DOWN, ewl_iconbox_pane_mouse_down_cb, ib);
        ewl_callback_append(ib->ewl_iconbox_pane_inner, EWL_CALLBACK_MOUSE_UP, 
ewl_iconbox_mouse_up, ib);
        ewl_callback_append(ib->ewl_iconbox_pane_inner, 
EWL_CALLBACK_DND_POSITION, ewl_iconbox_dnd_position_cb, ib);
-       
+       ewl_callback_append(ib->ewl_iconbox_pane_inner, EWL_CALLBACK_DND_DROP, 
ewl_iconbox_dnd_drop_cb, ib);
        ewl_container_callback_notify(EWL_CONTAINER(ib), EWL_CALLBACK_KEY_DOWN);
        ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_KEY_DOWN, 
ewl_iconbox_key_press_cb, ib);
-
-       
        ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_CONFIGURE, 
ewl_iconbox_configure_cb, NULL);
        ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_DESTROY, 
ewl_iconbox_destroy_cb, NULL);
 
@@ -568,6 +572,12 @@
        int wrap = 0;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
+
+       
+       //if (REALIZED(EWL_WIDGET(icon))) { 
+       //      printf("Icon '%s' realized, setting up label..\n", text);
+               ewl_callback_append(EWL_WIDGET(icon->w_label), 
EWL_CALLBACK_CONFIGURE, ewl_iconbox_icon_floater_resize, icon);
+       //}
        
        if (text) {
                
@@ -588,7 +598,7 @@
        /* Overestimate the label height to begin with, to give the text room 
to expand */
        if (REALIZED(EWL_WIDGET(icon))) {
                ewl_object_custom_h_set( EWL_OBJECT(icon), 
CURRENT_H(icon->image) + ICON_LABEL_INITIAL);        
-               ewl_callback_append(EWL_WIDGET(icon->w_label), 
EWL_CALLBACK_CONFIGURE, ewl_iconbox_icon_floater_resize, icon);
+               
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -915,13 +925,8 @@
 
        /*FIXME - at the moment, it appears we can't calculate the height 
                yet - hard set for now*/
-       ewl_object_custom_h_set(EWL_OBJECT(ib), 80);
-       ewl_object_custom_size_set(EWL_OBJECT(ib), 60, 90);
-
-
-
-
-       
+       //ewl_object_custom_h_set(EWL_OBJECT(ib), 80);
+       ewl_object_custom_size_set(EWL_OBJECT(ib), 60, 60);
 
        /* Add the callbacks for mouse */
        ewl_callback_prepend(EWL_ICONBOX_ICON(ib)->image, 
EWL_CALLBACK_MOUSE_DOWN, ewl_iconbox_icon_mouse_down, ib);
@@ -938,7 +943,7 @@
 
 
        ewl_widget_layer_set(EWL_WIDGET(ib), ICONBOX_ICON_LAYER);
-       //ewl_widget_draggable_set(EWL_WIDGET(ib), 1);
+       ewl_widget_draggable_set(EWL_WIDGET(ib), 1, ewl_iconbox_drag_data_get);
 
        return EWL_ICONBOX_ICON(ib);
 }
@@ -980,6 +985,24 @@
 
 
 /*Callbacks*/
+void ewl_iconbox_dnd_drop_cb(Ewl_Widget *item, void *ev_data, void *user_data) 
{
+       int ibx,iby,px,py,fw,fh;
+       Ewl_IconBox* ib = EWL_ICONBOX(user_data);
+       Ewl_IconBox_Icon* list_item = ib->select_icon;
+       Ewl_Event_Dnd_Drop *ev = ev_data;
+
+       ibx = ewl_object_current_x_get(EWL_OBJECT(ib));
+       iby = ewl_object_current_y_get(EWL_OBJECT(ib));
+
+       px = ewl_object_current_x_get(EWL_OBJECT(ib->ewl_iconbox_pane_inner));
+       py = ewl_object_current_y_get(EWL_OBJECT(ib->ewl_iconbox_pane_inner));
+
+       fw= ewl_object_preferred_w_get(EWL_OBJECT(list_item->image));
+       fh= ewl_object_preferred_h_get(EWL_OBJECT(list_item->image));
+
+       ewl_object_position_request(EWL_OBJECT(list_item),  ev->x - (fw/2), 
ev->y - (fh/2));
+
+}
 
 void ewl_iconbox_dnd_position_cb(Ewl_Widget *item, void *ev_data, void 
*user_data) {
        int ibx,iby,px,py,fw,fh;
@@ -988,24 +1011,25 @@
        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));
 
        px = ewl_object_current_x_get(EWL_OBJECT(ib->ewl_iconbox_pane_inner));
        py = ewl_object_current_y_get(EWL_OBJECT(ib->ewl_iconbox_pane_inner));
 
-       
        fw= ewl_object_preferred_w_get(EWL_OBJECT(list_item->image));
        fh= ewl_object_preferred_h_get(EWL_OBJECT(list_item->image));
-       ewl_object_position_request(EWL_OBJECT(list_item), (ev->x - ibx) + 
abs(px-ibx) - (fw/2),
-                                 (ev->y - iby) + abs(py-iby) - (fh/2));
+       
+       //ewl_object_position_request(EWL_OBJECT(list_item), (ev->x - ibx) + 
abs(px) - (fw/2),
+       //                        (ev->y - iby) + abs(py) - (fh/2));
 
        /*Get types*/
        if ( (types = ewl_dnd_types_for_widget_get(EWL_WIDGET(ib)))) {
-               printf("We have %d types!\n", types->num_types);
+               /*printf("We have %d types!\n", types->num_types);
                if (types->num_types > 0) {
                        printf("First type is '%s'\n", types->types[0]);
-               }
+               }*/
        }
        
 
@@ -1070,7 +1094,6 @@
        /*Handle selection box*/
        if (ib->drag_box) {
 
-
                if (ib->dx == -1) {
                        /*  Assume this is the drag start point */
                        ib->dx =  
ewl_object_current_x_get(EWL_OBJECT(ib->select_floater));
@@ -1137,6 +1160,8 @@
        
        
        if (list_item != NULL) {                        
+                       return;
+               
                        /*Ewl_Widget* icon_box = (Ewl_Widget*)list_item->box;*/
                        int fw,fh;
 
@@ -1177,12 +1202,7 @@
        iby = ewl_object_current_y_get(EWL_OBJECT(ib));
        
        if (ev->button == 3 /* Confirm that this is not an icon event */ && 
(ib->xdown != ev->x && ib->ydown != ev->y)) {
-               /*printf ("Context menu: %d,%d\n", ev->x, ev->y);*/
-
                
ewl_floater_position_set(EWL_FLOATER(ib->ewl_iconbox_menu_floater), ev->x-ibx + 
abs(px-ibx), ev->y-iby +abs(py-iby));
-               //ewl_widget_show(ib->ewl_iconbox_view_menu);
-               //ewl_widget_show(ib->ewl_iconbox_context_menu);
-               
//ewl_menu_popup_move_cb(EWL_MENU(ib->ewl_iconbox_context_menu)->base.popup, 
NULL, ib->ewl_iconbox_context_menu);
                ewl_callback_call(EWL_WIDGET(ib->ewl_iconbox_context_menu), 
EWL_CALLBACK_FOCUS_IN);
        } else if (ev->button == 1 /* Confirm that this is not an icon event */ 
&& (ib->xdown != ev->x && ib->ydown != ev->y)) {
                ewl_object_custom_size_set(EWL_OBJECT(ib->select), 1, 1);
@@ -1193,6 +1213,7 @@
                
                ewl_widget_show(EWL_WIDGET(ib->select_floater));
                ib->drag_box = 1;
+               ewl_dnd_disable();
        }
        
 }
@@ -1208,12 +1229,7 @@
        ib->icon_box_parent->xdown = ev->x;
        ib->icon_box_parent->ydown = ev->y;
 
-       /* Set this to selected */
-       if (ev->modifiers == EWL_KEY_MODIFIER_CTRL) {
-               ewl_iconbox_icon_select(ib,0,0);
-       } else {
-               ewl_iconbox_icon_select(ib,0,1);        
-       }
+
 
        ib->icon_box_parent->select_icon = ib; /*We rely on this being the 
first callback - so
                                                 client*/
@@ -1229,19 +1245,10 @@
 
        if (ev->button == 3) {
                
ewl_floater_position_set(EWL_FLOATER(ib->icon_box_parent->icon_menu_floater), 
ev->x-ibx + abs(sx-ibx), ev->y-iby +abs(sy-iby));
-               
//ewl_floater_follow_set(EWL_FLOATER(ib->icon_box_parent->icon_menu_floater), 
ib);
-               //ewl_widget_show(ib->icon_box_parent->icon_menu_floater);
-               //ewl_widget_show(ib->icon_box_parent->icon_menu);
                ewl_callback_call(EWL_WIDGET(ib->icon_box_parent->icon_menu), 
EWL_CALLBACK_FOCUS_IN);   
        } else {
+               return;
                /*Select/drag start*/
-
-               /*ewl_widget_hide(ib->icon_box_parent->icon_menu);*/
-               //ewl_widget_hide(ib->icon_box_parent->icon_menu_floater);
-
-
-       
-               /*printf ("Button down on icon: %s\n", 
ewl_border_text_get(EWL_BORDER(ib)));*/
                ib->drag = 1;
                ib->icon_box_parent->drag_icon = ib;
        }
@@ -1249,11 +1256,18 @@
        /*ewl_callback_call_with_event_data(EWL_WIDGET(ib), 
EWL_CALLBACK_MOUSE_DOWN, ev_data);*/
 }
 
-void ewl_iconbox_icon_mouse_up(Ewl_Widget *w __UNUSED__, void *ev_data 
__UNUSED__, void *user_data)
+void ewl_iconbox_icon_mouse_up(Ewl_Widget *w , void *ev_data , void *user_data)
 {
-       /*Ewl_Event_Mouse_Down *ev = ev_data;*/
-
+       Ewl_Event_Mouse_Down *ev = ev_data;
        Ewl_IconBox_Icon* ib = user_data;
+
+       /* Set this to selected */
+       if (ev->modifiers == EWL_KEY_MODIFIER_CTRL) {
+               ewl_iconbox_icon_select(ib,0,0);
+       } else {
+               ewl_iconbox_icon_select(ib,0,1);        
+       }
+
        ib->drag = 0;
        ib->icon_box_parent->drag_icon = NULL;
        /*printf ("Button up on icon: %s\n", 
ewl_border_text_get(EWL_BORDER(ib)) );*/
@@ -1269,6 +1283,8 @@
                ib->drag_box = 0;
                ib->dx = -1;
                ib->dy = -1;
+
+               ewl_dnd_enable();
        }
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- ewl_iconbox.h       11 Dec 2005 21:56:17 -0000      1.26
+++ ewl_iconbox.h       22 Dec 2005 04:29:44 -0000      1.27
@@ -142,6 +142,7 @@
 
 
 /* Internal callbacks */
+void ewl_iconbox_dnd_drop_cb(Ewl_Widget *item, void *ev_data, void *user_data);
 void ewl_iconbox_dnd_position_cb(Ewl_Widget *item, void *ev_data, void 
*user_data);
 void ewl_iconbox_arrange_cb(Ewl_Widget *w, void *ev_data, void *user_data);
 void ewl_iconbox_expansion_cb(Ewl_Widget *w, void *ev_data, void *user_data);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_misc.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- ewl_misc.c  17 Dec 2005 21:55:55 -0000      1.33
+++ ewl_misc.c  22 Dec 2005 04:29:44 -0000      1.34
@@ -187,6 +187,9 @@
                DRETURN_INT(_ewl_init_count, DLEVEL_STABLE);
        }
 
+       ewl_dnd_init();
+
+
 #ifdef ENABLE_EWL_SOFTWARE_X11
        if (use_engine == EWL_ENGINE_SOFTWARE_X11) {
                IF_FREE(ewl_config.evas.render_method);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_tree.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_tree.c  2 Dec 2005 06:19:04 -0000       1.18
+++ ewl_tree.c  22 Dec 2005 04:29:44 -0000      1.19
@@ -245,6 +245,7 @@
        }
 
        ewl_row_header_set(EWL_ROW(row), EWL_ROW(tree->header));
+
        ewl_widget_show(row);
 
        EWL_TREE_NODE(node)->tree = tree;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- ewl_widget.c        17 Dec 2005 21:55:55 -0000      1.51
+++ ewl_widget.c        22 Dec 2005 04:29:44 -0000      1.52
@@ -12,6 +12,22 @@
 static void ewl_widget_appearance_part_text_apply(Ewl_Widget * w,
                                                  const char *part, char *text);
 
+static void
+ewl_widget_drag_move_cb (Ewl_Widget * w, void *ev_data __UNUSED__,
+                               void *user_data __UNUSED__);
+
+static void
+ewl_widget_drag_up_cb (Ewl_Widget * w, void *ev_data __UNUSED__,
+                               void *user_data __UNUSED__);
+
+static void
+ewl_widget_drag_down_cb (Ewl_Widget * w, void *ev_data ,
+                               void *user_data __UNUSED__);
+
+static int drag_move_count = 0;
+static int ewl_drag_down = 0;
+static Ewl_Widget* ewl_drag_widget= NULL;
+
 /* static int edjes = 0; */
 
 /**
@@ -388,6 +404,9 @@
        if (ewl_object_queued_has(EWL_OBJECT(w), EWL_FLAG_QUEUED_DSCHEDULED))
                DRETURN(DLEVEL_STABLE);
 
+       if (w == ewl_widget_drag_candidate_get())
+               ewl_widget_dnd_reset();
+
        ewl_widget_hide(w);
        if (w->parent)
                ewl_container_child_remove(EWL_CONTAINER(w->parent), w);
@@ -672,7 +691,7 @@
                if (ewl_config.theme.print_signals)
                        printf("Emitting: %s\n", state);
                edje_object_signal_emit(w->theme_object, state, "EWL");
-       }
+       } 
 
        ewl_callback_call(w, EWL_CALLBACK_STATE_CHANGED);
 
@@ -1626,6 +1645,10 @@
        DCHECK_PARAM_PTR("w", w);
        DCHECK_TYPE("w", w, "widget");
 
+       ewl_callback_del(w, EWL_CALLBACK_MOUSE_DOWN, ewl_widget_drag_down_cb);
+       ewl_callback_del(w, EWL_CALLBACK_MOUSE_MOVE, ewl_widget_drag_move_cb);
+       ewl_callback_del(w, EWL_CALLBACK_MOUSE_MOVE, ewl_widget_drag_up_cb);
+
        /*
         * First remove the parents reference to this widget to avoid bad
         * references.
@@ -2417,3 +2440,113 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+
+
+void
+ewl_widget_drag_down_cb (Ewl_Widget * w, void *ev_data ,
+                               void *user_data __UNUSED__) {
+       Ewl_Event_Mouse_Down* ev = ev_data;
+
+       if (!ewl_dnd_status_get()) return;
+
+       if (ev->button == 1 && !ewl_object_flags_has(EWL_OBJECT(w), 
EWL_FLAG_STATE_DND_WAIT, EWL_FLAGS_STATE_MASK)) {
+               ewl_object_flags_add(EWL_OBJECT(w), EWL_FLAG_STATE_DND_WAIT, 
EWL_FLAGS_STATE_MASK);
+               //printf("Drag down starting down on %p..\n",w);
+               drag_move_count=0;              
+               ewl_drag_widget = w;
+       } else {
+               //printf("button wasn't 1, or had drag wait state\n");
+       }
+}
+
+void
+ewl_widget_drag_move_cb (Ewl_Widget * w, void *ev_data __UNUSED__,
+                               void *user_data __UNUSED__) {
+
+       if (!ewl_dnd_status_get()) return;
+       
+       if (ewl_drag_widget && 
ewl_object_flags_has(EWL_OBJECT(ewl_drag_widget), EWL_FLAG_STATE_DND_WAIT, 
EWL_FLAGS_STATE_MASK)) {
+               drag_move_count++;
+               
+               if (drag_move_count > 2) {
+                       ewl_object_flags_remove(EWL_OBJECT(ewl_drag_widget), 
EWL_FLAG_STATE_DND_WAIT, EWL_FLAGS_STATE_MASK);
+                       ewl_object_flags_add(EWL_OBJECT(ewl_drag_widget), 
EWL_FLAG_STATE_DND, EWL_FLAGS_STATE_MASK);
+               
+                       //printf("**** Start drag for %p..\n",ewl_drag_widget);
+                       ewl_drag_start(ewl_drag_widget);        
+               } else {
+                       //printf("Drag move count is %d\n", drag_move_count);
+               }
+       } else {
+               //printf("%p didn't have dnd wait\n");
+       }
+}
+
+void
+ewl_widget_drag_up_cb (Ewl_Widget * w, void *ev_data __UNUSED__,
+                               void *user_data __UNUSED__) {
+
+       if (ewl_object_flags_has(EWL_OBJECT(ewl_drag_widget), 
EWL_FLAG_STATE_DND_WAIT, EWL_FLAGS_STATE_MASK)) {
+               ewl_object_flags_remove(EWL_OBJECT(ewl_drag_widget), 
EWL_FLAG_STATE_DND_WAIT, EWL_FLAGS_STATE_MASK);
+               
+       }
+       drag_move_count=0;
+       ewl_drag_widget = NULL;
+}
+
+
+/**
+ * @param w: the widget to set draggable state
+ * @param val: the true/false state of draggable
+ * @return Returns no value.
+ * @brief Set the draggable state, and setup any callbacks
+ *
+ */
+void
+ewl_widget_draggable_set(Ewl_Widget *w, unsigned int val, void* (*cb) )
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+       DCHECK_TYPE("w", w, "widget");
+
+       if (val) { 
+               if (!ewl_object_flags_has(EWL_OBJECT(w), 
EWL_FLAG_PROPERTY_DRAGGABLE, EWL_FLAGS_PROPERTY_MASK)) {
+                       ewl_object_flags_add(EWL_OBJECT(w), 
EWL_FLAG_PROPERTY_DRAGGABLE, EWL_FLAGS_PROPERTY_MASK );
+
+                       ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN, 
ewl_widget_drag_down_cb, NULL);
+                       ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, 
ewl_widget_drag_move_cb, NULL);
+                       ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP, 
ewl_widget_drag_up_cb, NULL);
+
+                       
+                       /*if (ewl_widget_type_is(w, "container")) 
+                               ewl_container_callback_notify(EWL_CONTAINER(w), 
EWL_CALLBACK_MOUSE_DOWN);*/
+
+                       if (cb) {
+                               ewl_widget_data_set(w, "DROP_CB", cb);
+                       }
+               }
+       } else {
+               if (ewl_object_flags_has(EWL_OBJECT(w), 
EWL_FLAG_PROPERTY_DRAGGABLE,  EWL_FLAGS_PROPERTY_MASK)) {
+                       ewl_callback_del(w, EWL_CALLBACK_MOUSE_DOWN, 
ewl_widget_drag_down_cb);
+                       ewl_callback_del(w, EWL_CALLBACK_MOUSE_MOVE, 
ewl_widget_drag_move_cb);
+                       ewl_callback_del(w, EWL_CALLBACK_MOUSE_MOVE, 
ewl_widget_drag_up_cb);
+
+                       ewl_object_flags_remove(EWL_OBJECT(w), 
EWL_FLAG_PROPERTY_DRAGGABLE,  EWL_FLAGS_PROPERTY_MASK);
+
+                       /*ewl_container_callback_nointercept(EWL_CONTAINER(w), 
EWL_CALLBACK_MOUSE_DOWN);*/
+               }
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+Ewl_Widget* ewl_widget_drag_candidate_get() {
+       return ewl_drag_widget;
+}
+
+void ewl_widget_dnd_reset() {
+       drag_move_count=0;
+       ewl_drag_widget = NULL;
+       printf("Drag reset..\n");
+       
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- ewl_widget.h        15 Dec 2005 01:59:54 -0000      1.27
+++ ewl_widget.h        22 Dec 2005 04:29:44 -0000      1.28
@@ -171,6 +171,10 @@
 void            ewl_widget_color_set(Ewl_Widget *w, int r, int g, int b, int 
a);
 void            ewl_widget_color_get(Ewl_Widget *w, int *r, int *g, int *b, 
int *a);
 
+
+void           ewl_widget_draggable_set(Ewl_Widget* w, unsigned int val, void* 
(*cb) );
+Ewl_Widget*    ewl_widget_drag_candidate_get();
+
 /**
  * @def LAYER(w)
  * Used to retrieve the layer of a widget.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_window.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- ewl_window.c        29 Nov 2005 02:11:50 -0000      1.24
+++ ewl_window.c        22 Dec 2005 04:29:44 -0000      1.25
@@ -335,8 +335,24 @@
        DCHECK_TYPE("win", win, "window");
 
        if (REALIZED(win)) {
-               *x = win->x;
-               *y = win->y;
+               int fx=0,fy=0,cx,cy;
+               Ecore_X_Window_Attributes att;
+               Ecore_X_Window window = (Ecore_X_Window)win->window;
+               
+               while (ecore_x_window_parent_get(window) > 0) {
+                       ecore_x_window_geometry_get(window, &cx, &cy, NULL, 
NULL);
+                       fx += cx; fy += cy;
+                       
+                       //printf ("(%d:%d:%d:%d) Scanning to parent of %d\n", 
h, window);
+                       window = ecore_x_window_parent_get(window);
+                       
+               }
+
+               *x = fx;
+               *y = fy;
+
+               /**x = win->x;
+               *y = win->y;*/
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);




-------------------------------------------------------
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

Reply via email to