Enlightenment CVS committal

Author  : sebastid
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_dnd.c e_dnd.h 


Log Message:
Framework for accepting Xdnd drop on the background.

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_dnd.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- e_dnd.c     27 Apr 2005 08:42:36 -0000      1.9
+++ e_dnd.c     29 Apr 2005 15:04:45 -0000      1.10
@@ -15,14 +15,13 @@
 static char *drag_type;
 static void *drag_data;
 
-#if 0
-static int  drag;
-static void (*drag_cb)(void *data, void *event);
-static void *drag_cb_data;
-#endif
-
 static int  _e_dnd_cb_mouse_up(void *data, int type, void *event);
 static int  _e_dnd_cb_mouse_move(void *data, int type, void *event);
+static int  _e_dnd_cb_event_dnd_enter(void *data, int type, void *event);
+static int  _e_dnd_cb_event_dnd_leave(void *data, int type, void *event);
+static int  _e_dnd_cb_event_dnd_position(void *data, int type, void *event);
+static int  _e_dnd_cb_event_dnd_drop(void *data, int type, void *event);
+static int  _e_dnd_cb_event_dnd_selection(void *data, int type, void *event);
 
 int
 e_dnd_init(void)
@@ -42,13 +41,27 @@
          {
             con = l2->data;
 
-#if 0
-            e_hints_window_visible_set(con->bg_win);
             ecore_x_dnd_aware_set(con->bg_win, 1);
-            ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, 
_e_dnd_cb_event_dnd_drop , eb);
-            ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, 
_e_dnd_cb_event_dnd_position, eb);
-            ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, 
_e_dnd_cb_event_dnd_selection, eb);
-#endif
+            event_handlers = evas_list_append(event_handlers,
+                                              
ecore_event_handler_add(ECORE_X_EVENT_XDND_ENTER,
+                                                                      
_e_dnd_cb_event_dnd_enter,
+                                                                      con));
+            event_handlers = evas_list_append(event_handlers,
+                                              
ecore_event_handler_add(ECORE_X_EVENT_XDND_LEAVE,
+                                                                      
_e_dnd_cb_event_dnd_leave,
+                                                                      con));
+            event_handlers = evas_list_append(event_handlers,
+                                              
ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION,
+                                                                      
_e_dnd_cb_event_dnd_position,
+                                                                      con));
+            event_handlers = evas_list_append(event_handlers,
+                                              
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP,
+                                                                      
_e_dnd_cb_event_dnd_drop,
+                                                                      con));
+            event_handlers = evas_list_append(event_handlers,
+                                              
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
+                                                                      
_e_dnd_cb_event_dnd_selection,
+                                                                      con));
          }
      }
    return 1;
@@ -197,15 +210,6 @@
    drag_data = NULL;
 }
 
-#if 0
-void
-e_drag_callback_set(void *data, void (*func)(void *data, void *event))
-{
-   drag_cb = func;
-   drag_cb_data = data;
-} 
-#endif
-
 E_Drop_Handler *
 e_drop_handler_add(void *data, void (*func)(void *data, const char *type, void 
*drop), const char *type, int x, int y, int w, int h)
 {
@@ -244,20 +248,69 @@
 
    e_drag_end(ev->x, ev->y);
 
+   return 1;
+}
+
+static int
+_e_dnd_cb_mouse_move(void *data, int type, void *event)
+{
+   Ecore_X_Event_Mouse_Move *ev;
+
+   ev = event;
+   if (ev->win != drag_win) return 1;
+
+   e_drag_update(ev->x, ev->y);
+   return 1;
+}
+
+static int
+_e_dnd_cb_event_dnd_enter(void *data, int type, void *event)
+{
+   Ecore_X_Event_Xdnd_Enter *ev;
+   E_Container *con;
+
+   ev = event;
+   con = data;
+   if (con->bg_win != ev->win) return 1;
+   printf("Xdnd enter\n");
+   return 1;
+}
+
+static int
+_e_dnd_cb_event_dnd_leave(void *data, int type, void *event)
+{
+   Ecore_X_Event_Xdnd_Leave *ev;
+   E_Container *con;
+
+   ev = event;
+   con = data;
+   if (con->bg_win != ev->win) return 1;
+   printf("Xdnd leave\n");
+   return 1;
+}
+
+static int
+_e_dnd_cb_event_dnd_position(void *data, int type, void *event)
+{
+   Ecore_X_Event_Xdnd_Position *ev;
+   E_Container *con;
+
+   ev = event;
+   con = data;
+   if (con->bg_win != ev->win) return 1;
+   printf("Xdnd pos\n");
+
 #if 0
-   if (drag_cb)
+   for (l = drop_handlers; l; l = l->next)
      {
-       E_Drag_Event *e;
+       E_Drop_Handler *h;
+
+       h = l->data;
        
-       e = E_NEW(E_Drag_Event, 1);
-       if (e)
+       if ((x >= h->x) && (x < h->x + h->w) && (y >= h->y) && (y < h->y + h->h)
+           && (!strcmp(h->type, drag_type)))
          {
-            e->drag = drag;
-            e->x = ev->x;
-            e->y = ev->y;
-            (*drag_cb)(drag_cb_data, e);
-            drag_cb = NULL;
-            free(e);
+            h->func(h->data, drag_type, ev);
          }
      }
 #endif
@@ -266,14 +319,27 @@
 }
 
 static int
-_e_dnd_cb_mouse_move(void *data, int type, void *event)
+_e_dnd_cb_event_dnd_drop(void *data, int type, void *event)
 {
-   Ecore_X_Event_Mouse_Move *ev;
+   Ecore_X_Event_Xdnd_Drop *ev;
+   E_Container *con;
 
    ev = event;
-   if (ev->win != drag_win) return 1;
-
-   e_drag_update(ev->x, ev->y);
+   con = data;
+   if (con->bg_win != ev->win) return 1;
+   printf("Xdnd drop\n");
    return 1;
 }
 
+static int
+_e_dnd_cb_event_dnd_selection(void *data, int type, void *event)
+{
+   Ecore_X_Event_Selection_Notify *ev;
+   E_Container *con;
+
+   ev = event;
+   con = data;
+   if (con->bg_win != ev->win) return 1;
+   printf("Xdnd selection\n");
+   return 1;
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_dnd.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- e_dnd.h     26 Apr 2005 09:36:18 -0000      1.5
+++ e_dnd.h     29 Apr 2005 15:04:45 -0000      1.6
@@ -6,9 +6,6 @@
 
 typedef struct _E_Drop_Handler E_Drop_Handler;
 typedef struct _E_Drop_Event   E_Drop_Event;
-#if 0
-typedef struct _E_Drag_Event   E_Drag_Event;
-#endif
 
 #else
 #ifndef E_DND_H
@@ -28,14 +25,6 @@
    int x, y;
 };
 
-#if 0
-struct _E_Drag_Event
-{
-   int drag;
-   int x, y;
-};
-#endif
-
 EAPI int  e_dnd_init(void);
 EAPI int  e_dnd_shutdown(void);
 
@@ -45,9 +34,6 @@
                       const char *icon_path, const char *icon);
 EAPI void e_drag_update(int x, int y);
 EAPI void e_drag_end(int x, int y);
-#if 0
-EAPI void e_drag_callback_set(void *data, void (*func)(void *data, void 
*event));
-#endif
 
 EAPI E_Drop_Handler *e_drop_handler_add(void *data,
                                        void (*func)(void *data, const char 
*type, void *event_info),




-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to