The icon is now correctly positioned relative to the mouse.

SVN revision: 14785
This commit is contained in:
sebastid 2005-05-15 05:20:18 +00:00 committed by sebastid
parent 2244652807
commit 2bbedbf606
4 changed files with 36 additions and 27 deletions

View File

@ -2512,38 +2512,38 @@ _e_border_cb_mouse_move(void *data, int type, void *event)
{
if ((bd->drag.x == -1) && (bd->drag.y == -1))
{
bd->drag.x = ev->x;
bd->drag.y = ev->y;
bd->drag.x = ev->root.x;
bd->drag.y = ev->root.y;
}
else
{
int x, y;
double dist;
x = bd->drag.x - ev->x;
y = bd->drag.y - ev->y;
x = bd->drag.x - ev->root.x;
y = bd->drag.y - ev->root.y;
dist = sqrt(pow(x, 2) + pow(y, 2));
if (dist > 10)
if (dist > 4)
{
/* start drag! */
if (bd->icon_object)
{
E_Drag *drag;
Evas_Object *o;
Evas_Coord w, h;
Evas_Coord x, y, w, h;
const char *file, *part;
drag = e_drag_new(bd->zone->container,
evas_object_geometry_get(bd->icon_object,
&x, &y, &w, &h);
drag = e_drag_new(bd->zone->container, bd->x + x, bd->y + y,
"enlightenment/border", bd, NULL);
o = edje_object_add(drag->evas);
edje_object_file_get(bd->icon_object, &file, &part);
edje_object_file_set(o, file, part);
e_drag_object_set(drag, o);
evas_object_geometry_get(bd->icon_object,
NULL, NULL, &w, &h);
e_drag_resize(drag, w, h);
e_drag_start(drag);
e_drag_start(drag, bd->drag.x, bd->drag.y);
evas_event_feed_mouse_up(bd->bg_evas, 1,
EVAS_BUTTON_NONE, NULL);
}

View File

@ -119,7 +119,7 @@ e_dnd_shutdown(void)
}
E_Drag*
e_drag_new(E_Container *container,
e_drag_new(E_Container *container, int x, int y,
const char *type, void *data,
void (*finished_cb)(E_Drag *drag, int dropped))
{
@ -128,8 +128,8 @@ e_drag_new(E_Container *container,
drag = E_OBJECT_ALLOC(E_Drag, E_DRAG_TYPE, _e_drag_free);
if (!drag) return NULL;
drag->x = 0;
drag->y = 0;
drag->x = x;
drag->y = y;
drag->w = 24;
drag->h = 24;
drag->layer = 250;
@ -221,15 +221,15 @@ e_drag_hide(E_Drag *drag)
void
e_drag_move(E_Drag *drag, int x, int y)
{
if ((drag->x == x) && (drag->y == y)) return;
drag->x = x;
drag->y = y;
if (((drag->x + drag->dx) == x) && ((drag->y + drag->dy) == y)) return;
drag->x = x - drag->dx;
drag->y = y - drag->dy;
ecore_evas_move(drag->ecore_evas,
drag->x - (drag->w / 2),
drag->y - (drag->h / 2));
drag->x,
drag->y);
e_container_shape_move(drag->shape,
drag->x - (drag->w / 2),
drag->y - (drag->h / 2));
drag->x,
drag->y);
}
void
@ -250,7 +250,7 @@ e_dnd_active(void)
}
void
e_drag_start(E_Drag *drag)
e_drag_start(E_Drag *drag, int x, int y)
{
Evas_List *l;
@ -261,6 +261,9 @@ e_drag_start(E_Drag *drag)
ecore_x_pointer_confine_grab(_drag_win);
ecore_x_keyboard_grab(_drag_win);
drag->dx = x - drag->x;
drag->dy = y - drag->y;
for (l = _drop_handlers; l; l = l->next)
{
E_Drop_Handler *h;

View File

@ -34,6 +34,7 @@ struct _E_Drag
Evas_Object *object;
int x, y, w, h;
int dx, dy;
unsigned int layer;
unsigned char visible : 1;
@ -81,7 +82,8 @@ EAPI int e_dnd_shutdown(void);
EAPI int e_dnd_active(void);
EAPI E_Drag* e_drag_new(E_Container *container, const char *type, void *data,
/* x and y are the top left coords of the object that is to be dragged */
EAPI E_Drag* e_drag_new(E_Container *container, int x, int y, const char *type, void *data,
void (*finished_cb)(E_Drag *drag, int dropped));
EAPI Evas *e_drag_evas_get(E_Drag *drag);
EAPI void e_drag_object_set(E_Drag *drag, Evas_Object *object);
@ -91,7 +93,8 @@ 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_idler_before(void);
EAPI void e_drag_start(E_Drag *drag);
/* x and y are the coords where the mouse is when dragging starts */
EAPI void e_drag_start(E_Drag *drag, int x, int y);
EAPI void e_drag_update(int x, int y);
EAPI void e_drag_end(int x, int y);

View File

@ -1240,22 +1240,25 @@ _ibar_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info
double dist;
dist = sqrt(pow((ev->cur.output.x - drag_x), 2) + pow((ev->cur.output.y - drag_y), 2));
if (dist > 10)
if (dist > 4)
{
E_Drag *d;
Evas_Object *o;
Evas_Coord x, y, w, h;
drag = 1;
drag_start = 0;
d = e_drag_new(ic->ibb->con, "enlightenment/eapp",
evas_object_geometry_get(ic->icon_object,
&x, &y, &w, &h);
d = e_drag_new(ic->ibb->con, x, y, "enlightenment/eapp",
ic->app, _ibar_bar_cb_finished);
o = edje_object_add(e_drag_evas_get(d));
edje_object_file_set(o, ic->app->path, "icon");
e_drag_object_set(d, o);
e_drag_resize(d, ic->ibb->ibar->conf->iconsize, ic->ibb->ibar->conf->iconsize);
e_drag_start(d);
e_drag_resize(d, w, h);
e_drag_start(d, drag_x, drag_y);
evas_event_feed_mouse_up(ic->ibb->evas, 1, EVAS_BUTTON_NONE, NULL);
e_app_remove(ic->app);
}