Use hold flag for detecting drags.

SVN revision: 52128
This commit is contained in:
Brett Nash 2010-09-10 08:24:25 +00:00
parent 8a74d9c272
commit 506e380a6e
1 changed files with 10 additions and 18 deletions

View File

@ -132,8 +132,6 @@ _mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event)
{ {
Widget_Data *wd = elm_widget_data_get(data); Widget_Data *wd = elm_widget_data_get(data);
Evas_Event_Mouse_Move *move = event; Evas_Event_Mouse_Move *move = event;
int fsize;
int delta;
/* Sanity */ /* Sanity */
if (!wd->longtimer) if (!wd->longtimer)
@ -142,31 +140,25 @@ _mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event)
return; return;
} }
delta = hypot(wd->press.x - move->cur.canvas.x, /* if the event is held, stop waiting */
wd->press.y - move->cur.canvas.y); if (move->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
fsize = elm_finger_size_get() / 2; {
if (fsize < 5) fsize = 5; /* Moved too far: No longpress for you! */
ecore_timer_del(wd->longtimer);
/* Smaller movement: keep waiting for long press */ wd->longtimer = NULL;
if (delta < fsize) return; evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE,
_mouse_move);
/* Moved too far: No longpress for you! */ }
ecore_timer_del(wd->longtimer);
wd->longtimer = NULL;
evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move);
} }
static void static void
_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) _mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{ {
Widget_Data *wd = elm_widget_data_get(data); Widget_Data *wd = elm_widget_data_get(data);
Evas_Event_Mouse_Down *down = event_info;
if (wd->longtimer) ecore_timer_del(wd->longtimer); if (wd->longtimer) ecore_timer_del(wd->longtimer);
wd->press.x = down->canvas.x; /* FIXME: Hard coded timeout */
wd->press.y = down->canvas.y;
/* FIXME: Hard coded */
wd->longtimer = ecore_timer_add(0.7,_longpress, data); wd->longtimer = ecore_timer_add(0.7,_longpress, data);
evas_object_event_callback_add(obj,EVAS_CALLBACK_MOUSE_MOVE, evas_object_event_callback_add(obj,EVAS_CALLBACK_MOUSE_MOVE,
_mouse_move,data); _mouse_move,data);