Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_dnd.c e_dnd.h Log Message: fix up dnd to handle stacked windows and move the burden of window offset handling etc. to dnd not the objects that create dnd zones. they onyl need to now worry about the dnd zone withint heir canvas/window/whatever =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_dnd.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -3 -r1.48 -r1.49 --- e_dnd.c 10 Aug 2006 18:02:33 -0000 1.48 +++ e_dnd.c 17 Sep 2006 06:12:48 -0000 1.49 @@ -18,6 +18,8 @@ static void _e_drag_show(E_Drag *drag); static void _e_drag_hide(E_Drag *drag); static void _e_drag_move(E_Drag *drag, int x, int y); +static void _e_drag_coords_update(E_Drop_Handler *h, int *dx, int *dy, int *dw, int *dh); +static int _e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win); static void _e_drag_update(int x, int y); static void _e_drag_end(int x, int y); static void _e_drag_xdnd_end(int x, int y); @@ -299,7 +301,8 @@ } EAPI E_Drop_Handler * -e_drop_handler_add(void *data, +e_drop_handler_add(E_Object *obj, + void *data, void (*enter_cb)(void *data, const char *type, void *event), void (*move_cb)(void *data, const char *type, void *event), void (*leave_cb)(void *data, const char *type, void *event), @@ -329,6 +332,8 @@ handler->w = w; handler->h = h; + handler->obj = obj; + _drop_handlers = evas_list_append(_drop_handlers, handler); return handler; @@ -486,15 +491,110 @@ } static void +_e_drag_coords_update(E_Drop_Handler *h, int *dx, int *dy, int *dw, int *dh) +{ + int px = 0, py = 0; + + *dx = h->x; + *dy = h->y; + *dw = h->w; + *dh = h->h; + if (h->obj) + { + switch (h->obj->type) + { + case E_GADCON_TYPE: + e_gadcon_canvas_zone_geometry_get((E_Gadcon *)(h->obj), &px, &py, NULL, NULL); + break; + case E_WIN_TYPE: + px = ((E_Win *)(h->obj))->x; + py = ((E_Win *)(h->obj))->y; + if ((((E_Win *)(h->obj))->border) && + (((E_Win *)(h->obj))->border->zone)) + { + px -= ((E_Win *)(h->obj))->border->zone->x; + py -= ((E_Win *)(h->obj))->border->zone->y; + } + break; + case E_BORDER_TYPE: + px = ((E_Border *)(h->obj))->x + ((E_Border *)(h->obj))->fx.x; + py = ((E_Border *)(h->obj))->y + ((E_Border *)(h->obj))->fx.y; + if (((E_Border *)(h->obj))->zone) + { + px -= ((E_Border *)(h->obj))->zone->x; + py -= ((E_Border *)(h->obj))->zone->y; + } + break; + case E_POPUP_TYPE: + px = ((E_Popup *)(h->obj))->x; + py = ((E_Popup *)(h->obj))->y; + if (((E_Popup *)(h->obj))->zone) + { + px -= ((E_Popup *)(h->obj))->zone->x; + py -= ((E_Popup *)(h->obj))->zone->y; + } + break; + /* FIXME: add mroe types as needed */ + default: + break; + } + } + *dx += px; + *dy += py; +} + +static int +_e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win) +{ + Ecore_X_Window hwin = 0; + + if (h->obj) + { + switch (h->obj->type) + { + case E_GADCON_TYPE: + hwin = ecore_evas_software_x11_window_get(((E_Gadcon *)(h->obj))->ecore_evas); + break; + case E_WIN_TYPE: + hwin = ((E_Win *)(h->obj))->evas_win; + break; + case E_BORDER_TYPE: + hwin = ((E_Border *)(h->obj))->event_win; + break; + case E_POPUP_TYPE: + hwin = ((E_Popup *)(h->obj))->evas_win; + break; + /* FIXME: add mroe types as needed */ + default: + break; + } + } + if (win == hwin) return 1; + return 0; +} + +static void _e_drag_update(int x, int y) { Evas_List *l; E_Event_Dnd_Enter *enter_ev; E_Event_Dnd_Move *move_ev; E_Event_Dnd_Leave *leave_ev; + int dx, dy, dw, dh; + Ecore_X_Window win, ignore_win[2]; if (_drag_current) { + ignore_win[0] = _drag_current->evas_win; + ignore_win[1] = _drag_win; + /* this is nasty - but necessary to get the window stacking */ + win = ecore_x_window_at_xy_with_skip_get(x, y, &ignore_win, 2); + } + else + win = ecore_x_window_at_xy_with_skip_get(x, y, NULL, 0); + + if (_drag_current) + { _e_drag_show(_drag_current); _e_drag_move(_drag_current, x, y); } @@ -518,11 +618,10 @@ E_Drop_Handler *h; h = l->data; - - if (!h->active) - continue; - - if (E_INSIDE(x, y, h->x, h->y, h->w, h->h)) + if (!h->active) continue; + _e_drag_coords_update(h, &dx, &dy, &dw, &dh); + if ((_e_drag_win_matches(h, win)) && + (E_INSIDE(x, y, dx, dy, dw, dh))) { if (!h->entered) { @@ -551,11 +650,10 @@ E_Drop_Handler *h; h = l->data; - - if (!h->active) - continue; - - if (E_INSIDE(x, y, h->x, h->y, h->w, h->h)) + if (!h->active) continue; + _e_drag_coords_update(h, &dx, &dy, &dw, &dh); + if ((_e_drag_win_matches(h, win)) && + (E_INSIDE(x, y, dx, dy, dw, dh))) { if (!h->entered) { @@ -589,8 +687,14 @@ Evas_List *l; E_Event_Dnd_Drop *ev; const char *type = NULL; + int dx, dy, dw, dh; + Ecore_X_Window win, ignore_win[2]; if (!_drag_current) return; + ignore_win[0] = _drag_current->evas_win; + ignore_win[1] = _drag_win; + /* this is nasty - but necessary to get the window stacking */ + win = ecore_x_window_at_xy_with_skip_get(x, y, &ignore_win, 2); zone = e_container_zone_at_point_get(_drag_current->container, x, y); /* Pass -1, -1, so that it is possible to drop at the edge. */ if (zone) e_zone_flip_coords_handle(zone, -1, -1); @@ -627,14 +731,13 @@ for (l = _drop_handlers; l; l = l->next) { E_Drop_Handler *h; - + h = l->data; - - if (!h->active) - continue; - - if ((h->cb.drop) && - E_INSIDE(x, y, h->x, h->y, h->w, h->h)) + if (!h->active) continue; + _e_drag_coords_update(h, &dx, &dy, &dw, &dh); + if ((_e_drag_win_matches(h, win)) && + ((h->cb.drop) && + (E_INSIDE(x, y, dx, dy, dw, dh)))) { h->cb.drop(h->cb.data, type, ev); dropped = 1; @@ -682,8 +785,19 @@ Evas_List *l; E_Event_Dnd_Drop *ev; const char *type = NULL; + int dx, dy, dw, dh; + Ecore_X_Window win, ignore_win[2]; if (!_xdnd) return; + if (_drag_current) + { + ignore_win[0] = _drag_current->evas_win; + ignore_win[1] = _drag_win; + /* this is nasty - but necessary to get the window stacking */ + win = ecore_x_window_at_xy_with_skip_get(x, y, &ignore_win, 2); + } + else + win = ecore_x_window_at_xy_with_skip_get(x, y, NULL, 0); ev = E_NEW(E_Event_Dnd_Drop, 1); ev->data = _xdnd->data; @@ -699,14 +813,13 @@ for (l = _drop_handlers; l; l = l->next) { E_Drop_Handler *h; - + h = l->data; - - if (!h->active) - continue; - - if ((h->cb.drop) && - E_INSIDE(x, y, h->x, h->y, h->w, h->h)) + if (!h->active) continue; + _e_drag_coords_update(h, &dx, &dy, &dw, &dh); + if ((_e_drag_win_matches(h, win)) && + ((h->cb.drop) && + (E_INSIDE(x, y, dx, dy, dw, dh)))) { h->cb.drop(h->cb.data, type, ev); dropped = 1; =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_dnd.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- e_dnd.h 10 Aug 2006 17:48:17 -0000 1.25 +++ e_dnd.h 17 Sep 2006 06:12:48 -0000 1.26 @@ -4,7 +4,12 @@ #ifdef E_TYPEDEFS -typedef enum _E_Drag_Type E_Drag_Type; +typedef enum _E_Drag_Type +{ + E_DRAG_NONE, + E_DRAG_INTERNAL, + E_DRAG_XDND +} E_Drag_Type; typedef struct _E_Drag E_Drag; typedef struct _E_Drop_Handler E_Drop_Handler; @@ -19,13 +24,6 @@ #define E_DRAG_TYPE 0xE0b0100f -enum _E_Drag_Type -{ - E_DRAG_NONE, - E_DRAG_INTERNAL, - E_DRAG_XDND -}; - struct _E_Drag { E_Object e_obj_inherit; @@ -69,6 +67,7 @@ void *data; } cb; + E_Object *obj; char **types; unsigned int num_types; @@ -117,7 +116,8 @@ EAPI int e_drag_start(E_Drag *drag, int x, int y); EAPI int e_drag_xdnd_start(E_Drag *drag, int x, int y); -EAPI E_Drop_Handler *e_drop_handler_add(void *data, +EAPI E_Drop_Handler *e_drop_handler_add(E_Object *obj, + void *data, void (*enter_cb)(void *data, const char *type, void *event), void (*move_cb)(void *data, const char *type, void *event), void (*leave_cb)(void *data, const char *type, void *event), ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs