summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorWooHyun Jung <wh0705.jung@samsung.com>2019-08-01 09:19:51 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-01 11:33:03 +0200
commitd02a3ecb663a2691e13f8ea861d3f64b46d4b92e (patch)
tree417aba4ceff6f3cd914946d997ab80cbf29277a1 /src/lib
parentd2f7bacc2c9d481e68e48d2c6c245814c82b2dd6 (diff)
efl_input_clickable: add longpress_abort
Now, a specific class which uses efl_input_clickable_util is able to cancel ongoing longpress event by calling longpress_abort. This commit shows how efl_ui_text uses longpress_abort to satisfy its own longpress use case ref T7847 Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9455
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_text.c52
-rw-r--r--src/lib/evas/canvas/efl_input_clickable.c15
-rw-r--r--src/lib/evas/canvas/efl_input_clickable.eo9
3 files changed, 39 insertions, 37 deletions
diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c
index f9a575f87a..7a90a63827 100644
--- a/src/lib/elementary/efl_ui_text.c
+++ b/src/lib/elementary/efl_ui_text.c
@@ -47,7 +47,6 @@ struct _Efl_Ui_Text_Data
47 Evas_Object *start_handler; 47 Evas_Object *start_handler;
48 Evas_Object *end_handler; 48 Evas_Object *end_handler;
49 Ecore_Job *deferred_decoration_job; 49 Ecore_Job *deferred_decoration_job;
50 Ecore_Timer *longpress_timer;
51 Ecore_Timer *delay_write; 50 Ecore_Timer *delay_write;
52 /* for deferred appending */ 51 /* for deferred appending */
53 Ecore_Idler *append_text_idler; 52 Ecore_Idler *append_text_idler;
@@ -1427,8 +1426,6 @@ _long_press_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1427 _menu_call(data); 1426 _menu_call(data);
1428 1427
1429 sd->long_pressed = EINA_TRUE; 1428 sd->long_pressed = EINA_TRUE;
1430
1431 sd->longpress_timer = NULL;
1432} 1429}
1433 1430
1434static void 1431static void
@@ -1522,7 +1519,8 @@ _mouse_up_cb(void *data,
1522 if (sd->disabled) return; 1519 if (sd->disabled) return;
1523 if (ev->button == 1) 1520 if (ev->button == 1)
1524 { 1521 {
1525 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1522 efl_input_clickable_longpress_abort(data, 1);
1523
1526 /* Since context menu disabled flag was checked at long press start while mouse 1524 /* Since context menu disabled flag was checked at long press start while mouse
1527 * down, hence the same should be checked at mouse up from a long press 1525 * down, hence the same should be checked at mouse up from a long press
1528 * as well */ 1526 * as well */
@@ -1563,6 +1561,7 @@ _mouse_move_cb(void *data,
1563 void *event_info) 1561 void *event_info)
1564{ 1562{
1565 Evas_Event_Mouse_Move *ev = event_info; 1563 Evas_Event_Mouse_Move *ev = event_info;
1564 Evas_Coord dx, dy;
1566 1565
1567 EFL_UI_TEXT_DATA_GET(data, sd); 1566 EFL_UI_TEXT_DATA_GET(data, sd);
1568 1567
@@ -1592,38 +1591,18 @@ _mouse_move_cb(void *data,
1592 { 1591 {
1593 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) 1592 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1594 { 1593 {
1595 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1594 efl_input_clickable_longpress_abort(data, 1);
1596 }
1597 else if (sd->longpress_timer)
1598 {
1599 Evas_Coord dx, dy;
1600
1601 dx = sd->downx - ev->cur.canvas.x;
1602 dx *= dx;
1603 dy = sd->downy - ev->cur.canvas.y;
1604 dy *= dy;
1605 if ((dx + dy) >
1606 ((_elm_config->finger_size / 2) *
1607 (_elm_config->finger_size / 2)))
1608 {
1609 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
1610 }
1611 } 1595 }
1612 } 1596 }
1613 else if (sd->longpress_timer) 1597
1598 dx = sd->downx - ev->cur.canvas.x;
1599 dx *= dx;
1600 dy = sd->downy - ev->cur.canvas.y;
1601 dy *= dy;
1602 if ((dx + dy) > ((_elm_config->finger_size / 2) *
1603 (_elm_config->finger_size / 2)))
1614 { 1604 {
1615 Evas_Coord dx, dy; 1605 efl_input_clickable_longpress_abort(data, 1);
1616
1617 dx = sd->downx - ev->cur.canvas.x;
1618 dx *= dx;
1619 dy = sd->downy - ev->cur.canvas.y;
1620 dy *= dy;
1621 if ((dx + dy) >
1622 ((_elm_config->finger_size / 2) *
1623 (_elm_config->finger_size / 2)))
1624 {
1625 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
1626 }
1627 } 1606 }
1628} 1607}
1629 1608
@@ -1716,7 +1695,7 @@ _selection_handlers_offset_calc(Evas_Object *obj, Evas_Object *handler)
1716 sd->oy = pos.y + cy + (ch / 2); 1695 sd->oy = pos.y + cy + (ch / 2);
1717 } 1696 }
1718 1697
1719 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1698 efl_input_clickable_longpress_abort(obj, 1);
1720 sd->long_pressed = EINA_FALSE; 1699 sd->long_pressed = EINA_FALSE;
1721} 1700}
1722 1701
@@ -1799,7 +1778,7 @@ _start_handler_mouse_move_cb(void *data,
1799 efl_text_cursor_position_set(sd->text_obj, 1778 efl_text_cursor_position_set(sd->text_obj,
1800 efl_text_cursor_get(sd->text_obj, EFL_TEXT_CURSOR_GET_TYPE_MAIN), pos); 1779 efl_text_cursor_get(sd->text_obj, EFL_TEXT_CURSOR_GET_TYPE_MAIN), pos);
1801 1780
1802 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1781 efl_input_clickable_longpress_abort(data, 1);
1803 sd->long_pressed = EINA_FALSE; 1782 sd->long_pressed = EINA_FALSE;
1804} 1783}
1805 1784
@@ -1879,7 +1858,7 @@ _end_handler_mouse_move_cb(void *data,
1879 pos = efl_text_cursor_position_get(sd->text_obj, sd->sel_handler_cursor); 1858 pos = efl_text_cursor_position_get(sd->text_obj, sd->sel_handler_cursor);
1880 /* Set the main cursor. */ 1859 /* Set the main cursor. */
1881 efl_text_cursor_position_set(sd->text_obj, efl_text_cursor_get(data, EFL_TEXT_CURSOR_GET_TYPE_MAIN), pos); 1860 efl_text_cursor_position_set(sd->text_obj, efl_text_cursor_get(data, EFL_TEXT_CURSOR_GET_TYPE_MAIN), pos);
1882 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1861 efl_input_clickable_longpress_abort(data, 1);
1883 sd->long_pressed = EINA_FALSE; 1862 sd->long_pressed = EINA_FALSE;
1884} 1863}
1885 1864
@@ -2266,7 +2245,6 @@ _efl_ui_text_efl_object_destructor(Eo *obj, Efl_Ui_Text_Data *sd)
2266 ELM_SAFE_FREE(sd->append_text_left, free); 2245 ELM_SAFE_FREE(sd->append_text_left, free);
2267 sd->append_text_idler = NULL; 2246 sd->append_text_idler = NULL;
2268 } 2247 }
2269 ecore_timer_del(sd->longpress_timer);
2270 EINA_LIST_FREE(sd->items, it) 2248 EINA_LIST_FREE(sd->items, it)
2271 { 2249 {
2272 eina_stringshare_del(it->label); 2250 eina_stringshare_del(it->label);
diff --git a/src/lib/evas/canvas/efl_input_clickable.c b/src/lib/evas/canvas/efl_input_clickable.c
index fb6c3fe457..cc248184bd 100644
--- a/src/lib/evas/canvas/efl_input_clickable.c
+++ b/src/lib/evas/canvas/efl_input_clickable.c
@@ -118,4 +118,19 @@ _efl_input_clickable_button_state_reset(Eo *obj EINA_UNUSED, Efl_Input_Clickable
118 state->pressed = EINA_FALSE; 118 state->pressed = EINA_FALSE;
119} 119}
120 120
121EOLIAN static void
122_efl_input_clickable_longpress_abort(Eo *obj EINA_UNUSED, Efl_Input_Clickable_Data *pd, unsigned int button)
123{
124 Button_State *state;
125 EINA_SAFETY_ON_FALSE_RETURN(button < 3);
126
127 state = &pd->state[button];
128 EINA_SAFETY_ON_NULL_RETURN(state);
129
130 INF("Widget %s,%p - longpress is aborted(%d)", efl_class_name_get(obj), obj, button);
131
132 if (state->timer)
133 efl_del(state->timer);
134 state->timer = NULL;
135}
121#include "efl_input_clickable.eo.c" 136#include "efl_input_clickable.eo.c"
diff --git a/src/lib/evas/canvas/efl_input_clickable.eo b/src/lib/evas/canvas/efl_input_clickable.eo
index 14ca084d37..7a7f05bfb3 100644
--- a/src/lib/evas/canvas/efl_input_clickable.eo
+++ b/src/lib/evas/canvas/efl_input_clickable.eo
@@ -36,6 +36,15 @@ mixin @beta Efl.Input.Clickable
36 button : uint; 36 button : uint;
37 } 37 }
38 } 38 }
39 longpress_abort @protected {
40 [[This aborts ongoing longpress event.
41
42 That is, this will stop the timer for longpress.
43 ]]
44 params {
45 button : uint;
46 }
47 }
39 } 48 }
40 events { 49 events {
41 clicked: Efl.Input.Clickable_Clicked; [[Called when object is in sequence pressed and unpressed, by the primary button]] 50 clicked: Efl.Input.Clickable_Clicked; [[Called when object is in sequence pressed and unpressed, by the primary button]]