giant comp rejiggering commit #4

* dnd canvas removed, dnd objects now drawn directly on compositor canvas

* dnd now correctly picks the top-most dnd-receiver location as its drop target instead of just using the first one in the list

* various other small changes to go along with this
This commit is contained in:
Mike Blumenkrantz 2013-02-21 12:55:22 +00:00
parent 9eda384ea8
commit 70d68a30e0
10 changed files with 253 additions and 320 deletions

View File

@ -6,6 +6,7 @@
* E_FN_DEL macro renamed to E_FREE_FUNC with param order swapped for consistency * E_FN_DEL macro renamed to E_FREE_FUNC with param order swapped for consistency
* added e_gadcon_repopulate * added e_gadcon_repopulate
* EFM toolbar now has its own gadcon location * EFM toolbar now has its own gadcon location
* DND canvas merged to compositor
2013-02-20 Mike Blumenkrantz 2013-02-20 Mike Blumenkrantz

1
NEWS
View File

@ -118,6 +118,7 @@ Improvements:
* e_util_size_debug_set now displays delete events * e_util_size_debug_set now displays delete events
* compositor now allows user changing/remembering of object opacity * compositor now allows user changing/remembering of object opacity
* EFM toolbar now has its own gadcon location * EFM toolbar now has its own gadcon location
* DND canvas merged to compositor
Fixes: Fixes:
* IBar menu didn't allow to configure different icon sources, show contents menu even on empty IBar. * IBar menu didn't allow to configure different icon sources, show contents menu even on empty IBar.

View File

@ -4843,6 +4843,9 @@ e_comp_get(void *o)
E_Container *con = NULL; E_Container *con = NULL;
E_Manager *man = NULL; E_Manager *man = NULL;
E_Gadcon_Popup *gp; E_Gadcon_Popup *gp;
E_Gadcon *gc;
E_Gadcon_Client *gcc;
E_Drag *drag;
if (!o) obj = (E_Object*)e_manager_current_get(); if (!o) obj = (E_Object*)e_manager_current_get();
/* try to get to zone type first */ /* try to get to zone type first */
@ -4868,6 +4871,20 @@ e_comp_get(void *o)
obj = (void*)gp->win->zone; obj = (void*)gp->win->zone;
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
break; break;
case E_DRAG_TYPE:
drag = (E_Drag*)obj;
obj = (void*)drag->container;
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
break;
case E_GADCON_CLIENT_TYPE:
gcc = (E_Gadcon_Client*)obj;
obj = (void*)gcc->gadcon;
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
case E_GADCON_TYPE:
gc = (E_Gadcon*)obj;
obj = (void*)e_gadcon_zone_get(gc);
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
break;
default: default:
break; break;
} }

View File

@ -124,6 +124,12 @@ e_comp_cfdata_config_new(void)
mat->no_shadow = 1; mat->no_shadow = 1;
mat->focus = 1; mat->focus = 1;
mat = E_NEW(E_Comp_Match, 1);
cfg->match.popups = eina_list_append(cfg->match.popups, mat);
mat->name = eina_stringshare_add("E Drag");
mat->shadow_style = eina_stringshare_add("still");
mat->no_shadow = 1;
mat = E_NEW(E_Comp_Match, 1); mat = E_NEW(E_Comp_Match, 1);
cfg->match.popups = eina_list_append(cfg->match.popups, mat); cfg->match.popups = eina_list_append(cfg->match.popups, mat);
mat->shadow_style = eina_stringshare_add("popup"); mat->shadow_style = eina_stringshare_add("popup");

View File

@ -12,8 +12,6 @@
/* local subsystem functions */ /* local subsystem functions */
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_move(E_Drag *drag, int x, int y);
static void _e_drag_coords_update(const E_Drop_Handler *h, int *dx, int *dy); static void _e_drag_coords_update(const E_Drop_Handler *h, int *dx, int *dy);
static Ecore_X_Window _e_drag_win_get(const E_Drop_Handler *h, int xdnd); static Ecore_X_Window _e_drag_win_get(const E_Drop_Handler *h, int xdnd);
@ -21,12 +19,10 @@ static int _e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win,
static void _e_drag_win_show(E_Drop_Handler *h); static void _e_drag_win_show(E_Drop_Handler *h);
static void _e_drag_win_hide(E_Drop_Handler *h); static void _e_drag_win_hide(E_Drop_Handler *h);
static int _e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action); static int _e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action);
static void _e_drag_end(Ecore_X_Window root, int x, int y); static void _e_drag_end(int x, int y);
static void _e_drag_xdnd_end(Ecore_X_Window root, int x, int y); static void _e_drag_xdnd_end(Ecore_X_Window root, int x, int y);
static void _e_drag_free(E_Drag *drag); static void _e_drag_free(E_Drag *drag);
static Eina_Bool _e_dnd_cb_window_shape(void *data, int type, void *event);
static Eina_Bool _e_dnd_cb_key_down(void *data, int type, void *event); static Eina_Bool _e_dnd_cb_key_down(void *data, int type, void *event);
static Eina_Bool _e_dnd_cb_key_up(void *data, int type, void *event); static Eina_Bool _e_dnd_cb_key_up(void *data, int type, void *event);
static Eina_Bool _e_dnd_cb_mouse_up(void *data, int type, void *event); static Eina_Bool _e_dnd_cb_mouse_up(void *data, int type, void *event);
@ -89,7 +85,6 @@ e_dnd_init(void)
E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_BUTTON_UP, _e_dnd_cb_mouse_up, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_BUTTON_UP, _e_dnd_cb_mouse_up, NULL);
E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_MOVE, _e_dnd_cb_mouse_move, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_MOVE, _e_dnd_cb_mouse_move, NULL);
E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_WINDOW_SHAPE, _e_dnd_cb_window_shape, NULL);
E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_ENTER, _e_dnd_cb_event_dnd_enter, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_ENTER, _e_dnd_cb_event_dnd_enter, NULL);
E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_LEAVE, _e_dnd_cb_event_dnd_leave, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_LEAVE, _e_dnd_cb_event_dnd_leave, NULL);
E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_POSITION, _e_dnd_cb_event_dnd_position, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_POSITION, _e_dnd_cb_event_dnd_position, NULL);
@ -153,38 +148,16 @@ e_drag_new(E_Container *container, int x, int y,
drag->layer = E_LAYER_DRAG; drag->layer = E_LAYER_DRAG;
drag->container = container; drag->container = container;
e_object_ref(E_OBJECT(drag->container)); e_object_ref(E_OBJECT(drag->container));
drag->ecore_evas = e_canvas_new(drag->container->win,
drag->x, drag->y, drag->w, drag->h, 1, 1,
&(drag->evas_win));
if (!e_config->use_shaped_win)
ecore_evas_alpha_set(drag->ecore_evas, 1);
else
{
/* avoid excess exposes when shaped - set damage avoid to 1 */
ecore_evas_avoid_damage_set(drag->ecore_evas, 1);
ecore_evas_shaped_set(drag->ecore_evas, 1);
ecore_x_window_shape_events_select(drag->evas_win, 1);
}
e_canvas_add(drag->ecore_evas); drag->evas = e_comp_get(drag)->evas;
drag->shape = e_container_shape_add(drag->container); drag->pop = e_popup_new(e_zone_current_get(container), x, y, drag->w, drag->h);
e_container_shape_move(drag->shape, drag->x, drag->y);
e_container_shape_resize(drag->shape, drag->w, drag->h);
drag->evas = ecore_evas_get(drag->ecore_evas); e_popup_name_set(drag->pop, "E Drag");
e_container_window_raise(drag->container, drag->evas_win, drag->layer); e_popup_layer_set(drag->pop, E_COMP_CANVAS_LAYER_POPUP, 0);
e_popup_ignore_events_set(drag->pop, 1);
ecore_evas_name_class_set(drag->ecore_evas, "E", "_e_drag_window");
ecore_evas_title_set(drag->ecore_evas, "E Drag");
ecore_evas_ignore_events_set(drag->ecore_evas, 1);
drag->object = evas_object_rectangle_add(drag->evas); drag->object = evas_object_rectangle_add(drag->evas);
evas_object_color_set(drag->object, 255, 0, 0, 255); evas_object_color_set(drag->object, 255, 0, 0, 255);
evas_object_show(drag->object);
evas_object_move(drag->object, 0, 0);
evas_object_resize(drag->object, drag->w, drag->h);
ecore_evas_resize(drag->ecore_evas, drag->w, drag->h);
drag->type = E_DRAG_NONE; drag->type = E_DRAG_NONE;
@ -219,7 +192,9 @@ e_drag_object_set(E_Drag *drag, Evas_Object *object)
{ {
if (drag->object) evas_object_del(drag->object); if (drag->object) evas_object_del(drag->object);
drag->object = object; drag->object = object;
evas_object_resize(drag->object, drag->w, drag->h); drag->pop->content = NULL;
if (_drag_current == drag)
e_popup_content_set(drag->pop, object);
} }
EAPI void EAPI void
@ -228,7 +203,8 @@ e_drag_move(E_Drag *drag, int x, int y)
if ((drag->x == x) && (drag->y == y)) return; if ((drag->x == x) && (drag->y == y)) return;
drag->x = x; drag->x = x;
drag->y = y; drag->y = y;
drag->xy_update = 1; if (_drag_current == drag)
e_popup_move(drag->pop, x, y);
} }
EAPI void EAPI void
@ -237,9 +213,8 @@ e_drag_resize(E_Drag *drag, int w, int h)
if ((drag->w == w) && (drag->h == h)) return; if ((drag->w == w) && (drag->h == h)) return;
drag->h = h; drag->h = h;
drag->w = w; drag->w = w;
evas_object_resize(drag->object, drag->w, drag->h); if (_drag_current == drag)
ecore_evas_resize(drag->ecore_evas, drag->w, drag->h); e_popup_resize(drag->pop, w, h);
e_container_shape_resize(drag->shape, drag->w, drag->h);
} }
EAPI int EAPI int
@ -265,7 +240,9 @@ e_drag_start(E_Drag *drag, int x, int y)
ecore_x_window_free(_drag_win); ecore_x_window_free(_drag_win);
return 0; return 0;
} }
e_popup_move_resize(drag->pop, drag->x, drag->y, drag->w, drag->h);
e_popup_content_set(drag->pop, drag->object);
drag->visible = 1;
drag->type = E_DRAG_INTERNAL; drag->type = E_DRAG_INTERNAL;
drag->dx = x - drag->x; drag->dx = x - drag->x;
@ -320,7 +297,9 @@ e_drag_xdnd_start(E_Drag *drag, int x, int y)
ecore_x_window_free(_drag_win); ecore_x_window_free(_drag_win);
return 0; return 0;
} }
e_popup_move_resize(drag->pop, drag->x, drag->y, drag->w, drag->h);
e_popup_content_set(drag->pop, drag->object);
drag->visible = 1;
drag->type = E_DRAG_XDND; drag->type = E_DRAG_XDND;
drag->dx = x - drag->x; drag->dx = x - drag->x;
@ -489,74 +468,6 @@ e_drop_xdnd_register_set(Ecore_X_Window win, int reg)
return 1; return 1;
} }
EAPI void
e_drag_idler_before(void)
{
const Eina_List *l;
E_Drag *drag;
EINA_LIST_FOREACH(_drag_list, l, drag)
{
if (drag->need_shape_export)
{
Ecore_X_Rectangle *rects, *orects;
int num;
rects = ecore_x_window_shape_rectangles_get(drag->evas_win, &num);
if (rects)
{
int changed;
changed = 1;
if ((num == drag->shape_rects_num) && (drag->shape_rects))
{
int i;
orects = drag->shape_rects;
for (i = 0; i < num; i++)
{
if ((orects[i].x != rects[i].x) ||
(orects[i].y != rects[i].y) ||
(orects[i].width != rects[i].width) ||
(orects[i].height != rects[i].height))
{
changed = 1;
break;
}
}
// TODO: This is meaningless
changed = 0;
}
if (changed)
{
E_FREE(drag->shape_rects);
drag->shape_rects = rects;
drag->shape_rects_num = num;
e_container_shape_rects_set(drag->shape, rects, num);
}
else
free(rects);
}
else
{
E_FREE(drag->shape_rects);
drag->shape_rects = NULL;
drag->shape_rects_num = 0;
e_container_shape_rects_set(drag->shape, NULL, 0);
}
drag->need_shape_export = 0;
if (drag->visible)
e_container_shape_show(drag->shape);
}
if (drag->xy_update)
{
ecore_evas_move(drag->ecore_evas, drag->x, drag->y);
e_container_shape_move(drag->shape, drag->x, drag->y);
drag->xy_update = 0;
}
}
}
EAPI void EAPI void
e_drop_handler_responsive_set(E_Drop_Handler *handler) e_drop_handler_responsive_set(E_Drop_Handler *handler)
{ {
@ -650,26 +561,6 @@ e_dnd_util_text_uri_list_convert(char *data, int size)
/* local subsystem functions */ /* local subsystem functions */
static void
_e_drag_show(E_Drag *drag)
{
if (drag->visible) return;
drag->visible = 1;
evas_object_show(drag->object);
ecore_evas_show(drag->ecore_evas);
e_container_shape_show(drag->shape);
}
static void
_e_drag_hide(E_Drag *drag)
{
if (!drag->visible) return;
drag->visible = 0;
evas_object_hide(drag->object);
ecore_evas_hide(drag->ecore_evas);
e_container_shape_hide(drag->shape);
}
static void static void
_e_drag_move(E_Drag *drag, int x, int y) _e_drag_move(E_Drag *drag, int x, int y)
{ {
@ -682,7 +573,7 @@ _e_drag_move(E_Drag *drag, int x, int y)
drag->x = x - drag->dx; drag->x = x - drag->dx;
drag->y = y - drag->dy; drag->y = y - drag->dy;
drag->xy_update = 1; e_popup_move(drag->pop, drag->x, drag->y);
} }
static void static void
@ -700,10 +591,9 @@ _e_drag_coords_update(const E_Drop_Handler *h, int *dx, int *dy)
case E_GADCON_TYPE: case E_GADCON_TYPE:
gc = (E_Gadcon *)h->obj; gc = (E_Gadcon *)h->obj;
e_gadcon_canvas_zone_geometry_get(gc, &px, &py, NULL, NULL); if (!gc->toolbar) return;
if (!gc->toolbar) break; px = gc->toolbar->fwin->x;
px += gc->toolbar->fwin->x; py = gc->toolbar->fwin->y;
py += gc->toolbar->fwin->y;
break; break;
case E_GADCON_CLIENT_TYPE: case E_GADCON_CLIENT_TYPE:
@ -754,14 +644,28 @@ _e_drag_win_get(const E_Drop_Handler *h, int xdnd)
{ {
switch (h->obj->type) switch (h->obj->type)
{ {
E_Gadcon *gc;
case E_GADCON_TYPE: case E_GADCON_TYPE:
if (xdnd) hwin = e_gadcon_xdnd_window_get((E_Gadcon *)(h->obj)); gc = (E_Gadcon *)h->obj;
else hwin = e_gadcon_dnd_window_get((E_Gadcon *)(h->obj));
if (gc->toolbar) hwin = gc->toolbar->fwin->border->win; //double check for xdnd...
else
{
if (xdnd) hwin = e_gadcon_xdnd_window_get(gc);
else hwin = e_gadcon_dnd_window_get(gc);
}
break; break;
case E_GADCON_CLIENT_TYPE: case E_GADCON_CLIENT_TYPE:
if (xdnd) hwin = e_gadcon_xdnd_window_get(((E_Gadcon_Client *)(h->obj))->gadcon); gc = ((E_Gadcon_Client *)(h->obj))->gadcon;
else hwin = e_gadcon_dnd_window_get(((E_Gadcon_Client *)(h->obj))->gadcon);
if (gc->toolbar) hwin = gc->toolbar->fwin->border->win; //double check for xdnd...
else
{
if (xdnd) hwin = e_gadcon_xdnd_window_get(gc);
else hwin = e_gadcon_dnd_window_get(gc);
}
break; break;
case E_WIN_TYPE: case E_WIN_TYPE:
@ -847,13 +751,32 @@ _e_drag_win_hide(E_Drop_Handler *h)
} }
} }
static unsigned int
_e_dnd_object_layer_get(E_Object *obj)
{
unsigned int adjust = 0;
if (!obj) return 0;
switch (obj->type)
{
case E_GADCON_CLIENT_TYPE:
/* add 1 to ensure we're above a potential receiving gadcon */
adjust = 1;
default:
adjust += e_comp_e_object_layer_get(obj);
}
return adjust;
}
static int static int
_e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action) _e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action)
{ {
const Eina_List *l; const Eina_List *l;
Eina_List *entered = NULL;
E_Event_Dnd_Enter enter_ev; E_Event_Dnd_Enter enter_ev;
E_Event_Dnd_Move move_ev; E_Event_Dnd_Move move_ev;
E_Event_Dnd_Leave leave_ev; E_Event_Dnd_Leave leave_ev;
E_Drop_Handler *h, *top = NULL;
unsigned int top_layer = 0;
int dx, dy; int dx, dy;
Ecore_X_Window win; Ecore_X_Window win;
int responsive = 0; int responsive = 0;
@ -861,26 +784,64 @@ _e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action)
// double t1 = ecore_time_get(); //// // double t1 = ecore_time_get(); ////
if (_drag_current && !_xdnd) if (_drag_current && !_xdnd)
{ {
win = ecore_evas_window_get(_drag_current->ecore_evas); Ecore_X_Window ignore[1];
win = e_comp_top_window_at_xy_get(e_comp_get(e_manager_find_by_root(root)), x, y, &win, 1); ignore[0] = _drag_win;
win = e_comp_top_window_at_xy_get(e_comp_get(_drag_current), x, y, ignore, 1);
} }
else else
win = root; win = root;
if (_drag_current) if (_drag_current)
{ {
_e_drag_show(_drag_current); if (_drag_current->visible) e_popup_show(_drag_current->pop);
else e_popup_hide(_drag_current->pop);
_e_drag_move(_drag_current, x, y); _e_drag_move(_drag_current, x, y);
} }
EINA_LIST_FOREACH(_drop_handlers, l, h)
if (_drag_current)
{ {
E_Drop_Handler *h; if (!h->active) continue;
_e_drag_coords_update(h, &dx, &dy);
enter_ev.x = x - dx;
enter_ev.y = y - dy;
enter_ev.data = NULL;
enter_ev.action = action;
move_ev.x = x - dx;
move_ev.y = y - dy;
move_ev.action = action;
leave_ev.x = x - dx;
leave_ev.y = y - dy;
EINA_LIST_FOREACH(_drop_handlers, l, h) if (E_INSIDE(enter_ev.x, enter_ev.y, h->x, h->y, h->w, h->h) &&
((!_drag_current) || _e_drag_win_matches(h, win, 0)))
entered = eina_list_append(entered, h);
else
{ {
if (!h->active) continue; if (h->entered)
_e_drag_coords_update(h, &dx, &dy); {
if (h->cb.leave)
h->cb.leave(h->cb.data, h->active_type, &leave_ev);
if (_drag_current)
_e_drag_win_hide(h);
h->entered = 0;
}
}
}
if (!entered) return 0;
EINA_LIST_FREE(entered, h)
{
unsigned int layer;
E_Drop_Handler *h2;
_e_drag_coords_update(h, &dx, &dy);
leave_ev.x = x - dx;
leave_ev.y = y - dy;
layer = _e_dnd_object_layer_get(h->obj);
if (!top)
{
top = h;
top_layer = layer;
enter_ev.x = x - dx; enter_ev.x = x - dx;
enter_ev.y = y - dy; enter_ev.y = y - dy;
enter_ev.data = NULL; enter_ev.data = NULL;
@ -888,93 +849,58 @@ _e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action)
move_ev.x = x - dx; move_ev.x = x - dx;
move_ev.y = y - dy; move_ev.y = y - dy;
move_ev.action = action; move_ev.action = action;
leave_ev.x = x - dx; continue;
leave_ev.y = y - dy;
if (E_INSIDE(enter_ev.x, enter_ev.y, h->x, h->y, h->w, h->h) &&
_e_drag_win_matches(h, win, 0))
{
if (e_drop_handler_responsive_get(h)) responsive = 1;
if (!h->entered)
{
_e_drag_win_show(h);
if (h->cb.enter)
{
if (_drag_current->cb.convert)
{
enter_ev.data = _drag_current->cb.convert(_drag_current,
h->active_type);
}
else
enter_ev.data = _drag_current->data;
h->cb.enter(h->cb.data, h->active_type, &enter_ev);
}
h->entered = 1;
}
if (h->cb.move)
h->cb.move(h->cb.data, h->active_type, &move_ev);
}
else
{
if (h->entered)
{
if (h->cb.leave)
h->cb.leave(h->cb.data, h->active_type, &leave_ev);
_e_drag_win_hide(h);
h->entered = 0;
}
}
} }
} if (layer > top_layer)
else if (_xdnd)
{
E_Drop_Handler *h;
EINA_LIST_FOREACH(_drop_handlers, l, h)
{ {
if (!h->active) continue; h2 = top, top = h, h = h2;
_e_drag_coords_update(h, &dx, &dy);
enter_ev.x = x - dx; enter_ev.x = x - dx;
enter_ev.y = y - dy; enter_ev.y = y - dy;
enter_ev.data = NULL;
enter_ev.action = action; enter_ev.action = action;
move_ev.x = x - dx; move_ev.x = x - dx;
move_ev.y = y - dy; move_ev.y = y - dy;
move_ev.action = action; move_ev.action = action;
leave_ev.x = x - dx; }
leave_ev.y = y - dy; if (h == top) continue;
if (E_INSIDE(enter_ev.x, enter_ev.y, h->x, h->y, h->w, h->h) && _e_drag_win_matches(h, win, 1)) if (h->entered)
{ {
if (e_drop_handler_responsive_get(h)) responsive = 1; if (h->cb.leave)
h->cb.leave(h->cb.data, h->active_type, &leave_ev);
if (!h->entered) if (_drag_current)
{ _e_drag_win_hide(h);
if (h->cb.enter) h->entered = 0;
h->cb.enter(h->cb.data, h->active_type, &enter_ev);
h->entered = 1;
}
if (h->cb.move)
h->cb.move(h->cb.data, h->active_type, &move_ev);
}
else
{
if (h->entered)
{
if (h->cb.leave)
h->cb.leave(h->cb.data, h->active_type, &leave_ev);
h->entered = 0;
}
}
} }
} }
responsive = !!e_drop_handler_responsive_get(top);
if (!top->entered)
{
_e_drag_win_show(top);
if (top->cb.enter)
{
if (_drag_current)
{
if (_drag_current->cb.convert)
{
enter_ev.data = _drag_current->cb.convert(_drag_current,
top->active_type);
}
else
enter_ev.data = _drag_current->data;
}
top->cb.enter(top->cb.data, top->active_type, &enter_ev);
}
top->entered = 1;
}
if (top->cb.move)
top->cb.move(top->cb.data, top->active_type, &move_ev);
return responsive; return responsive;
// double t2 = ecore_time_get() - t1; //// // double t2 = ecore_time_get() - t1; ////
// printf("DND UPDATE %3.7f\n", t2); //// // printf("DND UPDATE %3.7f\n", t2); ////
} }
static void static void
_e_drag_end(Ecore_X_Window root, int x, int y) _e_drag_end(int x, int y)
{ {
E_Zone *zone; E_Zone *zone;
const Eina_List *l; const Eina_List *l;
@ -982,21 +908,22 @@ _e_drag_end(Ecore_X_Window root, int x, int y)
int dx, dy; int dx, dy;
Ecore_X_Window win; Ecore_X_Window win;
E_Drag *tmp; E_Drag *tmp;
E_Drop_Handler *h;
int dropped;
Ecore_X_Window ignore[1];
if (!_drag_current) return; if (!_drag_current) return;
win = ecore_evas_window_get(_drag_current->ecore_evas); ignore[0] = _drag_win;
win = e_comp_top_window_at_xy_get(e_comp_get(e_manager_find_by_root(root)), x, y, &win, 1); win = e_comp_top_window_at_xy_get(e_comp_get(_drag_current), x, y, ignore, 1);
zone = e_container_zone_at_point_get(_drag_current->container, x, y); 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. */ /* Pass -1, -1, so that it is possible to drop at the edge. */
if (zone) e_zone_flip_coords_handle(zone, -1, -1); if (zone) e_zone_flip_coords_handle(zone, -1, -1);
_e_drag_hide(_drag_current); e_popup_hide(_drag_current->pop);
e_grabinput_release(_drag_win, _drag_win); e_grabinput_release(_drag_win, _drag_win);
while (_drag_current->type == E_DRAG_XDND) while (_drag_current->type == E_DRAG_XDND)
{ {
int dropped;
if (!(dropped = ecore_x_dnd_drop())) if (!(dropped = ecore_x_dnd_drop()))
{ {
if (win == e_comp_get(NULL)->ee_win) break; if (win == e_comp_get(NULL)->ee_win) break;
@ -1019,61 +946,12 @@ _e_drag_end(Ecore_X_Window root, int x, int y)
ecore_x_window_free(_drag_win); ecore_x_window_free(_drag_win);
_drag_win = 0; _drag_win = 0;
dropped = 0;
if (_drag_current->data) if (!_drag_current->data)
{
E_Drop_Handler *h;
int dropped = 0;
EINA_LIST_FOREACH(_drop_handlers, l, h)
{
if (!h->active) continue;
_e_drag_coords_update(h, &dx, &dy);
ev.x = x - dx;
ev.y = y - dy;
if ((_e_drag_win_matches(h, win, 0)) &&
((h->cb.drop) && (E_INSIDE(ev.x, ev.y, h->x, h->y, h->w, h->h))))
{
Eina_Bool need_free = EINA_FALSE;
if (_drag_current->cb.convert)
{
ev.data = _drag_current->cb.convert(_drag_current,
h->active_type);
}
else
{
unsigned int i;
for (i = 0; i < _drag_current->num_types; i++)
if (_drag_current->types[i] == _type_text_uri_list)
{
ev.data = e_dnd_util_text_uri_list_convert(_drag_current->data, _drag_current->data_size);
need_free = EINA_TRUE;
break;
}
if (!need_free)
ev.data = _drag_current->data;
}
h->cb.drop(h->cb.data, h->active_type, &ev);
if (need_free) E_FREE_LIST(ev.data, free);
dropped = 1;
}
h->entered = 0;
if (dropped) break;
}
if (_drag_current->cb.finished)
_drag_current->cb.finished(_drag_current, dropped);
tmp = _drag_current;
_drag_current = NULL;
e_object_del(E_OBJECT(tmp));
}
else
{ {
/* Just leave */ /* Just leave */
E_Event_Dnd_Leave leave_ev; E_Event_Dnd_Leave leave_ev;
E_Drop_Handler *h;
/* FIXME: We don't need x and y in leave */ /* FIXME: We don't need x and y in leave */
leave_ev.x = 0; leave_ev.x = 0;
@ -1091,6 +969,50 @@ _e_drag_end(Ecore_X_Window root, int x, int y)
} }
} }
} }
EINA_LIST_FOREACH(_drop_handlers, l, h)
{
if (!h->active) continue;
_e_drag_coords_update(h, &dx, &dy);
ev.x = x - dx;
ev.y = y - dy;
if ((_e_drag_win_matches(h, win, 0)) &&
((h->cb.drop) && (E_INSIDE(ev.x, ev.y, h->x, h->y, h->w, h->h))))
{
Eina_Bool need_free = EINA_FALSE;
if (_drag_current->cb.convert)
{
ev.data = _drag_current->cb.convert(_drag_current,
h->active_type);
}
else
{
unsigned int i;
for (i = 0; i < _drag_current->num_types; i++)
if (_drag_current->types[i] == _type_text_uri_list)
{
ev.data = e_dnd_util_text_uri_list_convert(_drag_current->data, _drag_current->data_size);
need_free = EINA_TRUE;
break;
}
if (!need_free)
ev.data = _drag_current->data;
}
h->cb.drop(h->cb.data, h->active_type, &ev);
if (need_free) E_FREE_LIST(ev.data, free);
dropped = 1;
}
h->entered = 0;
if (dropped) break;
}
if (_drag_current->cb.finished)
_drag_current->cb.finished(_drag_current, dropped);
tmp = _drag_current;
_drag_current = NULL;
e_object_del(E_OBJECT(tmp));
} }
static void static void
@ -1180,35 +1102,14 @@ _e_drag_free(E_Drag *drag)
_drag_list = eina_list_remove(_drag_list, drag); _drag_list = eina_list_remove(_drag_list, drag);
E_FREE(drag->shape_rects);
drag->shape_rects_num = 0;
e_object_unref(E_OBJECT(drag->container)); e_object_unref(E_OBJECT(drag->container));
e_container_shape_hide(drag->shape); E_FREE_FUNC(drag->pop, e_object_del);
e_object_del(E_OBJECT(drag->shape));
evas_object_del(drag->object);
e_canvas_del(drag->ecore_evas);
ecore_evas_free(drag->ecore_evas);
for (i = 0; i < drag->num_types; i++) for (i = 0; i < drag->num_types; i++)
eina_stringshare_del(drag->types[i]); eina_stringshare_del(drag->types[i]);
free(drag); free(drag);
ecore_x_window_shadow_tree_flush(); ecore_x_window_shadow_tree_flush();
} }
static Eina_Bool
_e_dnd_cb_window_shape(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
{
Ecore_X_Event_Window_Shape *e = ev;
const Eina_List *l;
E_Drag *drag;
EINA_LIST_FOREACH(_drag_list, l, drag)
{
if (drag->evas_win == e->win)
drag->need_shape_export = 1;
}
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool static Eina_Bool
_e_dnd_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) _e_dnd_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{ {
@ -1249,7 +1150,7 @@ _e_dnd_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event)
ev = event; ev = event;
if (ev->window != _drag_win) return ECORE_CALLBACK_PASS_ON; if (ev->window != _drag_win) return ECORE_CALLBACK_PASS_ON;
_e_drag_end(_drag_win_root, ev->x, ev->y); _e_drag_end(ev->x, ev->y);
return ECORE_CALLBACK_PASS_ON; return ECORE_CALLBACK_PASS_ON;
} }

View File

@ -38,22 +38,15 @@ struct _E_Drag
} cb; } cb;
E_Container *container; E_Container *container;
Ecore_Evas *ecore_evas;
Evas *evas; Evas *evas;
Ecore_X_Window evas_win; E_Popup *pop;
E_Container_Shape *shape;
Evas_Object *object; Evas_Object *object;
int x, y, w, h; int x, y, w, h;
int dx, dy; int dx, dy;
int shape_rects_num;
Ecore_X_Rectangle *shape_rects;
E_Layer layer; E_Layer layer;
unsigned char visible : 1; unsigned char visible : 1;
unsigned char need_shape_export : 1;
unsigned char xy_update : 1;
unsigned int num_types; unsigned int num_types;
const char *types[]; const char *types[];
@ -72,6 +65,7 @@ struct _E_Drop_Handler
} cb; } cb;
E_Object *obj; E_Object *obj;
Evas_Object *base;
int x, y, w, h; int x, y, w, h;
unsigned char active : 1; unsigned char active : 1;
@ -120,7 +114,6 @@ EAPI Evas *e_drag_evas_get(const E_Drag *drag);
EAPI void e_drag_object_set(E_Drag *drag, Evas_Object *object); EAPI void e_drag_object_set(E_Drag *drag, Evas_Object *object);
EAPI void e_drag_move(E_Drag *drag, int x, int y); EAPI void e_drag_move(E_Drag *drag, int x, int y);
EAPI void e_drag_resize(E_Drag *drag, int w, int h); EAPI void e_drag_resize(E_Drag *drag, int w, int h);
EAPI void e_drag_idler_before(void);
EAPI void e_drag_key_down_cb_set(E_Drag *drag, void (*func)(E_Drag *drag, Ecore_Event_Key *e)); EAPI void e_drag_key_down_cb_set(E_Drag *drag, void (*func)(E_Drag *drag, Ecore_Event_Key *e));
EAPI void e_drag_key_up_cb_set(E_Drag *drag, void (*func)(E_Drag *drag, Ecore_Event_Key *e)); EAPI void e_drag_key_up_cb_set(E_Drag *drag, void (*func)(E_Drag *drag, Ecore_Event_Key *e));
@ -146,11 +139,20 @@ EAPI void e_drop_handler_responsive_set(E_Drop_Handler *handler);
EAPI int e_drop_handler_responsive_get(const E_Drop_Handler *handler); EAPI int e_drop_handler_responsive_get(const E_Drop_Handler *handler);
EAPI void e_drop_handler_action_set(Ecore_X_Atom action); EAPI void e_drop_handler_action_set(Ecore_X_Atom action);
EAPI Ecore_X_Atom e_drop_handler_action_get(void); EAPI Ecore_X_Atom e_drop_handler_action_get(void);
EAPI Eina_List *e_dnd_util_text_uri_list_convert(char *data, int size); EAPI Eina_List *e_dnd_util_text_uri_list_convert(char *data, int size);
#endif
#endif
#ifndef MIN
# define MIN(x, y) (((x) > (y)) ? (y) : (x)) static inline void
e_drag_show(E_Drag *drag)
{
drag->visible = 1;
}
static inline void
e_drag_hide(E_Drag *drag)
{
drag->visible = 0;
}
#endif
#endif #endif

View File

@ -7583,6 +7583,7 @@ _e_fm2_cb_icon_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNU
edje_object_signal_emit(o, "e,state,selected", "e"); edje_object_signal_emit(o, "e,state,selected", "e");
edje_object_signal_emit(o2, "e,state,selected", "e"); edje_object_signal_emit(o2, "e,state,selected", "e");
e_drag_object_set(d, o); e_drag_object_set(d, o);
e_popup_object_add(d->pop, o2);
edje_object_signal_emit(o, "e,state,move", "e"); edje_object_signal_emit(o, "e,state,move", "e");
e_drag_resize(d, w, h); e_drag_resize(d, w, h);
evas_object_smart_callback_call(ic->sd->obj, "dnd_begin", &ic->info); evas_object_smart_callback_call(ic->sd->obj, "dnd_begin", &ic->info);

View File

@ -2309,6 +2309,7 @@ _e_gadcon_client_drag_begin(E_Gadcon_Client *gcc, int x, int y)
e_drag_object_set(drag, o); e_drag_object_set(drag, o);
e_drag_resize(drag, w, h); e_drag_resize(drag, w, h);
e_drag_start(drag, x + w / 2, y + h / 2); e_drag_start(drag, x + w / 2, y + h / 2);
e_drag_hide(drag);
} }
static void static void
@ -2523,7 +2524,7 @@ _e_gadcon_client_move_start(E_Gadcon_Client *gcc)
evas_pointer_canvas_xy_get(gcc->gadcon->evas, &gcc->dx, &gcc->dy); evas_pointer_canvas_xy_get(gcc->gadcon->evas, &gcc->dx, &gcc->dy);
else else
{ {
ecore_x_pointer_xy_get(gcc->gadcon->zone->container->win, &gcc->dx, &gcc->dy); ecore_x_pointer_xy_get(e_comp_get(gcc)->ee_win, &gcc->dx, &gcc->dy);
e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &gcx, &gcy, NULL, NULL); e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &gcx, &gcy, NULL, NULL);
evas_object_geometry_get(gcc->gadcon->o_container, &gx, &gy, NULL, NULL); evas_object_geometry_get(gcc->gadcon->o_container, &gx, &gy, NULL, NULL);
gcc->dx -= (gcx + gx); gcc->dx -= (gcx + gx);
@ -2595,7 +2596,8 @@ _e_gadcon_client_move_go(E_Gadcon_Client *gcc)
if (e_gadcon_layout_orientation_get(gcc->gadcon->o_container)) if (e_gadcon_layout_orientation_get(gcc->gadcon->o_container))
{ {
if (cy + e_config->drag_resist < 0 || cy - e_config->drag_resist >= gh) if ((cy + e_config->drag_resist < 0 || cy - e_config->drag_resist >= gh) ||
(cx + e_config->drag_resist < 0 || cx - e_config->drag_resist > gw))
{ {
_e_gadcon_client_drag_begin(gcc, cx, cy); _e_gadcon_client_drag_begin(gcc, cx, cy);
return; return;
@ -2610,7 +2612,7 @@ _e_gadcon_client_move_go(E_Gadcon_Client *gcc)
changes = 1; changes = 1;
} }
/* DRAG LEFT */ /* DRAG LEFT */
else if (x < 0 && (gcc->drag.x - cx < gcc->config.pos)) else if (x < 0 && (cx + gcc->drag.x < gcc->config.pos))
{ {
if (gcc->state_info.state != E_LAYOUT_ITEM_STATE_POS_DEC) if (gcc->state_info.state != E_LAYOUT_ITEM_STATE_POS_DEC)
gcc->state_info.resist = 0; gcc->state_info.resist = 0;
@ -2632,12 +2634,14 @@ _e_gadcon_client_move_go(E_Gadcon_Client *gcc)
} }
else else
{ {
if (cx + e_config->drag_resist < 0 || cx - e_config->drag_resist > gw) if ((cy + e_config->drag_resist < 0 || cy - e_config->drag_resist >= gh) ||
(cx + e_config->drag_resist < 0 || cx - e_config->drag_resist > gw))
{ {
_e_gadcon_client_drag_begin(gcc, cx, cy); _e_gadcon_client_drag_begin(gcc, cx, cy);
return; return;
} }
/* DRAG DOWN */
if (y > 0 && (cy + gcc->drag.y > gcc->config.pos)) if (y > 0 && (cy + gcc->drag.y > gcc->config.pos))
{ {
if (gcc->state_info.state != E_LAYOUT_ITEM_STATE_POS_INC) if (gcc->state_info.state != E_LAYOUT_ITEM_STATE_POS_INC)
@ -2645,6 +2649,7 @@ _e_gadcon_client_move_go(E_Gadcon_Client *gcc)
gcc->state_info.state = E_LAYOUT_ITEM_STATE_POS_INC; gcc->state_info.state = E_LAYOUT_ITEM_STATE_POS_INC;
changes = 1; changes = 1;
} }
/* DRAG UP */
else if (y < 0 && (cy + gcc->drag.y < gcc->config.pos)) else if (y < 0 && (cy + gcc->drag.y < gcc->config.pos))
{ {
if (gcc->state_info.state != E_LAYOUT_ITEM_STATE_POS_DEC) if (gcc->state_info.state != E_LAYOUT_ITEM_STATE_POS_DEC)
@ -2865,7 +2870,7 @@ _e_gadcon_cb_dnd_enter(void *data, const char *type __UNUSED__, void *event)
if ((!gcc->hidden) && (gcc->gadcon == gc)) if ((!gcc->hidden) && (gcc->gadcon == gc))
{ {
if (gc->dnd_enter_cb) gc->dnd_enter_cb(gc, gc->drag_gcc); if (gc->dnd_enter_cb) gc->dnd_enter_cb(gc, gc->drag_gcc);
evas_object_hide(gc->drag_gcc->drag.drag->object); e_drag_hide(gc->drag_gcc->drag.drag);
return; return;
} }
if (gcc->gadcon != gc) if (gcc->gadcon != gc)
@ -2873,7 +2878,7 @@ _e_gadcon_cb_dnd_enter(void *data, const char *type __UNUSED__, void *event)
else if (e_gadcon_site_is_desktop(gcc->gadcon->location->site)) else if (e_gadcon_site_is_desktop(gcc->gadcon->location->site))
{ {
e_gadcon_client_show(gc->drag_gcc); e_gadcon_client_show(gc->drag_gcc);
evas_object_hide(gc->drag_gcc->drag.drag->object); e_drag_hide(gc->drag_gcc->drag.drag);
if (gc->dnd_enter_cb) gc->dnd_enter_cb(gc, gc->drag_gcc); if (gc->dnd_enter_cb) gc->dnd_enter_cb(gc, gc->drag_gcc);
return; return;
} }
@ -2957,7 +2962,7 @@ _e_gadcon_cb_dnd_enter(void *data, const char *type __UNUSED__, void *event)
} }
} }
evas_object_hide(gc->drag_gcc->drag.drag->object); e_drag_hide(gc->drag_gcc->drag.drag);
e_gadcon_client_edit_begin(gc->new_gcc); e_gadcon_client_edit_begin(gc->new_gcc);
e_gadcon_client_autoscroll_set(gc->new_gcc, gcc->autoscroll); e_gadcon_client_autoscroll_set(gc->new_gcc, gcc->autoscroll);
/* e_gadcon_client_resizable_set(gc->new_gcc, gcc->resizable);*/ /* e_gadcon_client_resizable_set(gc->new_gcc, gcc->resizable);*/
@ -3040,7 +3045,7 @@ _e_gadcon_cb_dnd_leave(void *data, const char *type __UNUSED__, void *event __UN
//INF("DELETING new_gcc"); //INF("DELETING new_gcc");
e_object_del(E_OBJECT(gc->new_gcc)); e_object_del(E_OBJECT(gc->new_gcc));
gc->new_gcc = NULL; gc->new_gcc = NULL;
evas_object_show(gc->drag_gcc->drag.drag->object); e_drag_show(gc->drag_gcc->drag.drag);
if (gc->dnd_leave_cb) gc->dnd_leave_cb(gc, gc->drag_gcc); if (gc->dnd_leave_cb) gc->dnd_leave_cb(gc, gc->drag_gcc);
} }

View File

@ -1900,7 +1900,6 @@ _e_main_cb_idle_before(void *data __UNUSED__)
e_menu_idler_before(); e_menu_idler_before();
e_focus_idler_before(); e_focus_idler_before();
e_border_idler_before(); e_border_idler_before();
e_drag_idler_before();
e_pointer_idler_before(); e_pointer_idler_before();
EINA_LIST_FOREACH(_idle_before_list, l, eb) EINA_LIST_FOREACH(_idle_before_list, l, eb)
{ {

View File

@ -1473,8 +1473,8 @@ on_move(void *data, Evas_Object *o __UNUSED__, const char *em __UNUSED__, const
e_drag_object_set(drag, o); e_drag_object_set(drag, o);
e_drag_resize(drag, ow, oh); e_drag_resize(drag, ow, oh);
evas_object_hide(o);
e_drag_start(drag, mx, my); e_drag_start(drag, mx, my);
e_drag_hide(drag);
} }
static void static void