summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-06-26 10:30:35 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-27 16:51:19 +0200
commite399bdd6ec493d302e3d5c402e5953de8f783880 (patch)
tree4b32057ebdd4d895a254b209a8e57c7f8092a3d4
parent3edf75c319c47df598efd55aa6771d8d58c52bb4 (diff)
evas_events: implement POINTER_CANCEL event
it looks like this was left out during initial writing of eo-based eventing, but based on the description, the intent was to have a separate cancel event which was emitted just prior to the 'up' event using the existing state Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9184
-rw-r--r--src/lib/evas/canvas/evas_events.c92
1 files changed, 62 insertions, 30 deletions
diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c
index 9d40007709..adb53c56f4 100644
--- a/src/lib/evas/canvas/evas_events.c
+++ b/src/lib/evas/canvas/evas_events.c
@@ -814,7 +814,7 @@ static void
814_evas_event_source_mouse_up_events(Evas_Object *eo_obj, Evas *eo_e, 814_evas_event_source_mouse_up_events(Evas_Object *eo_obj, Evas *eo_e,
815 Efl_Input_Pointer *parent_ev, 815 Efl_Input_Pointer *parent_ev,
816 Evas_Pointer_Data *pdata, 816 Evas_Pointer_Data *pdata,
817 int event_id) 817 int event_id, Eina_Bool cancel)
818{ 818{
819 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 819 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
820 Evas_Object *eo_src = _evas_object_image_source_get(eo_obj); 820 Evas_Object *eo_src = _evas_object_image_source_get(eo_obj);
@@ -853,7 +853,7 @@ _evas_event_source_mouse_up_events(Evas_Object *eo_obj, Evas *eo_e,
853 ev->device); 853 ev->device);
854 continue; 854 continue;
855 } 855 }
856 if (((obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_AUTOGRAB) || 856 if ((!cancel) && ((obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_AUTOGRAB) ||
857 (obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN)) && 857 (obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN)) &&
858 (obj_pdata->mouse_grabbed > 0)) 858 (obj_pdata->mouse_grabbed > 0))
859 { 859 {
@@ -864,12 +864,15 @@ _evas_event_source_mouse_up_events(Evas_Object *eo_obj, Evas *eo_e,
864 ev->cur = point; 864 ev->cur = point;
865 pointer_mode = obj_pdata->pointer_mode; 865 pointer_mode = obj_pdata->pointer_mode;
866 _evas_event_havemap_adjust_f(eo_child, child, &ev->cur, obj_pdata->mouse_grabbed); 866 _evas_event_havemap_adjust_f(eo_child, child, &ev->cur, obj_pdata->mouse_grabbed);
867 evas_object_event_callback_call(eo_child, child, EVAS_CALLBACK_MOUSE_UP, evt, 867 if (cancel)
868 event_id, EFL_EVENT_POINTER_UP); 868 efl_event_callback_call(eo_child, EFL_EVENT_POINTER_CANCEL, evt);
869 else
870 evas_object_event_callback_call(eo_child, child, EVAS_CALLBACK_MOUSE_UP, evt,
871 event_id, EFL_EVENT_POINTER_UP);
869 if (e->delete_me) break; 872 if (e->delete_me) break;
870 if (pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN) 873 if (pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN)
871 { 874 {
872 if (pdata->seat->nogrep > 0) pdata->seat->nogrep--; 875 if ((!cancel) && (pdata->seat->nogrep > 0)) pdata->seat->nogrep--;
873 break; 876 break;
874 } 877 }
875 } 878 }
@@ -1755,9 +1758,10 @@ _canvas_event_feed_mouse_up_internal(Evas_Public_Data *e, Efl_Input_Pointer_Data
1755 Efl_Input_Pointer *evt; 1758 Efl_Input_Pointer *evt;
1756 Eina_List *l, *copy; 1759 Eina_List *l, *copy;
1757 Evas_Object *eo_obj; 1760 Evas_Object *eo_obj;
1758 int event_id, b; 1761 int event_id = 0, b;
1759 Evas *eo_e; 1762 Evas *eo_e;
1760 Evas_Pointer_Data *pdata; 1763 Evas_Pointer_Data *pdata;
1764 Eina_Bool cancel;
1761 1765
1762 static const int value_flags = 1766 static const int value_flags =
1763 _efl_input_value_mask(EFL_INPUT_VALUE_TIMESTAMP) | 1767 _efl_input_value_mask(EFL_INPUT_VALUE_TIMESTAMP) |
@@ -1773,20 +1777,29 @@ _canvas_event_feed_mouse_up_internal(Evas_Public_Data *e, Efl_Input_Pointer_Data
1773 if (!pdata) return; 1777 if (!pdata) return;
1774 1778
1775 b = ev->button; 1779 b = ev->button;
1776 DBG("ButtonEvent:up time=%u x=%d y=%d button=%d downs=%d", 1780 cancel = ev->action == EFL_POINTER_ACTION_CANCEL;
1777 ev->timestamp, pdata->seat->x, pdata->seat->y, b, pdata->seat->downs); 1781 if (cancel)
1782 DBG("ButtonEvent:cancel time=%u x=%d y=%d button=%d downs=%d",
1783 ev->timestamp, pdata->seat->x, pdata->seat->y, b, pdata->seat->downs);
1784 else
1785 DBG("ButtonEvent:up time=%u x=%d y=%d button=%d downs=%d",
1786 ev->timestamp, pdata->seat->x, pdata->seat->y, b, pdata->seat->downs);
1778 if ((b < 1) || (b > 32)) return; 1787 if ((b < 1) || (b > 32)) return;
1779 if (pdata->seat->downs <= 0) return; 1788 if (pdata->seat->downs <= 0) return;
1780 1789
1781 pdata->button &= ~(1u << (b - 1)); 1790 if (!cancel)
1782 pdata->seat->downs--; 1791 {
1792 pdata->button &= ~(1u << (b - 1));
1793 pdata->seat->downs--;
1794 }
1783 1795
1784 if (e->is_frozen) return; 1796 if (e->is_frozen) return;
1785 e->last_timestamp = ev->timestamp; 1797 e->last_timestamp = ev->timestamp;
1786 eo_e = e->evas; 1798 eo_e = e->evas;
1787 evt = ev->eo; 1799 evt = ev->eo;
1788 1800
1789 event_id = _evas_object_event_new(); 1801 if (!cancel)
1802 event_id = _evas_object_event_new();
1790 1803
1791 ev->cur.x = pdata->seat->x; 1804 ev->cur.x = pdata->seat->x;
1792 ev->cur.y = pdata->seat->y; 1805 ev->cur.y = pdata->seat->y;
@@ -1798,8 +1811,9 @@ _canvas_event_feed_mouse_up_internal(Evas_Public_Data *e, Efl_Input_Pointer_Data
1798 if (ev->device) efl_ref(ev->device); 1811 if (ev->device) efl_ref(ev->device);
1799 1812
1800 _evas_walk(e); 1813 _evas_walk(e);
1801 /* update released touch point */ 1814 if (!cancel)
1802 _evas_touch_point_update(eo_e, 0, pdata->seat->x, pdata->seat->y, EVAS_TOUCH_POINT_UP); 1815 /* update released touch point */
1816 _evas_touch_point_update(eo_e, 0, pdata->seat->x, pdata->seat->y, EVAS_TOUCH_POINT_UP);
1803 copy = evas_event_list_copy(pdata->seat->object.in); 1817 copy = evas_event_list_copy(pdata->seat->object.in);
1804 EINA_LIST_FOREACH(copy, l, eo_obj) 1818 EINA_LIST_FOREACH(copy, l, eo_obj)
1805 { 1819 {
@@ -1815,7 +1829,7 @@ _canvas_event_feed_mouse_up_internal(Evas_Public_Data *e, Efl_Input_Pointer_Data
1815 ev->device); 1829 ev->device);
1816 continue; 1830 continue;
1817 } 1831 }
1818 if (((obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_AUTOGRAB) || 1832 if ((!cancel) && ((obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_AUTOGRAB) ||
1819 (obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN)) && 1833 (obj_pdata->pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN)) &&
1820 (obj_pdata->mouse_grabbed > 0)) 1834 (obj_pdata->mouse_grabbed > 0))
1821 { 1835 {
@@ -1829,29 +1843,35 @@ _canvas_event_feed_mouse_up_internal(Evas_Public_Data *e, Efl_Input_Pointer_Data
1829 ev->cur.x = pdata->seat->x; 1843 ev->cur.x = pdata->seat->x;
1830 ev->cur.y = pdata->seat->y; 1844 ev->cur.y = pdata->seat->y;
1831 _evas_event_havemap_adjust_f(eo_obj, obj, &ev->cur, obj_pdata->mouse_grabbed); 1845 _evas_event_havemap_adjust_f(eo_obj, obj, &ev->cur, obj_pdata->mouse_grabbed);
1832 evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_UP, evt, 1846 if (cancel)
1833 event_id, EFL_EVENT_POINTER_UP); 1847 efl_event_callback_call(eo_obj, EFL_EVENT_POINTER_CANCEL, evt);
1848 else
1849 evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_MOUSE_UP, evt,
1850 event_id, EFL_EVENT_POINTER_UP);
1834 if ((obj->proxy->is_proxy) && (obj->proxy->src_events)) 1851 if ((obj->proxy->is_proxy) && (obj->proxy->src_events))
1835 _evas_event_source_mouse_up_events(eo_obj, eo_e, evt, pdata, event_id); 1852 _evas_event_source_mouse_up_events(eo_obj, eo_e, evt, pdata, event_id, cancel);
1836 if (e->delete_me) break; 1853 if (e->delete_me) break;
1837 } 1854 }
1838 if (pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN) 1855 if (pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN)
1839 { 1856 {
1840 if (pdata->seat->nogrep > 0) pdata->seat->nogrep--; 1857 if ((!cancel) && (pdata->seat->nogrep > 0)) pdata->seat->nogrep--;
1841 break; 1858 break;
1842 } 1859 }
1843 } 1860 }
1844 eina_list_free(copy); 1861 eina_list_free(copy);
1845 e->last_mouse_up_counter++; 1862 if (!cancel)
1846 _evas_post_event_callback_call(eo_e, e, event_id); 1863 {
1864 e->last_mouse_up_counter++;
1865 _evas_post_event_callback_call(eo_e, e, event_id);
1847 1866
1848 if (pdata->seat->mouse_grabbed == 0) 1867 if (pdata->seat->mouse_grabbed == 0)
1849 _post_up_handle(e, evt, pdata); 1868 _post_up_handle(e, evt, pdata);
1850 1869
1851 if (pdata->seat->mouse_grabbed < 0) 1870 if (pdata->seat->mouse_grabbed < 0)
1852 { 1871 {
1853 ERR("BUG? pdata->seat->mouse_grabbed (=%d) < 0!", 1872 ERR("BUG? pdata->seat->mouse_grabbed (=%d) < 0!",
1854 pdata->seat->mouse_grabbed); 1873 pdata->seat->mouse_grabbed);
1874 }
1855 } 1875 }
1856 /* remove released touch point from the touch point list */ 1876 /* remove released touch point from the touch point list */
1857 _evas_touch_point_remove(eo_e, 0); 1877 _evas_touch_point_remove(eo_e, 0);
@@ -1863,7 +1883,7 @@ _canvas_event_feed_mouse_up_internal(Evas_Public_Data *e, Efl_Input_Pointer_Data
1863static void 1883static void
1864_canvas_event_feed_mouse_updown(Eo *eo_e, int b, Evas_Button_Flags flags, 1884_canvas_event_feed_mouse_updown(Eo *eo_e, int b, Evas_Button_Flags flags,
1865 unsigned int timestamp, const void *data, 1885 unsigned int timestamp, const void *data,
1866 Eina_Bool down, Efl_Input_Device *device) 1886 Eina_Bool down, Efl_Input_Device *device, Eina_Bool cancel)
1867{ 1887{
1868 Efl_Input_Pointer_Data *ev = NULL; 1888 Efl_Input_Pointer_Data *ev = NULL;
1869 Efl_Input_Pointer *evt; 1889 Efl_Input_Pointer *evt;
@@ -1879,7 +1899,10 @@ _canvas_event_feed_mouse_updown(Eo *eo_e, int b, Evas_Button_Flags flags,
1879 ev->data = (void *) data; 1899 ev->data = (void *) data;
1880 ev->timestamp = timestamp; 1900 ev->timestamp = timestamp;
1881 ev->device = efl_ref(device ? device : _evas_event_legacy_device_get(eo_e, EINA_TRUE)); 1901 ev->device = efl_ref(device ? device : _evas_event_legacy_device_get(eo_e, EINA_TRUE));
1882 ev->action = down ? EFL_POINTER_ACTION_DOWN : EFL_POINTER_ACTION_UP; 1902 if (cancel)
1903 ev->action = EFL_POINTER_ACTION_CANCEL;
1904 else
1905 ev->action = down ? EFL_POINTER_ACTION_DOWN : EFL_POINTER_ACTION_UP;
1883 ev->button = b; 1906 ev->button = b;
1884 ev->button_flags = flags; 1907 ev->button_flags = flags;
1885 ev->radius = 1; 1908 ev->radius = 1;
@@ -1890,12 +1913,21 @@ _canvas_event_feed_mouse_updown(Eo *eo_e, int b, Evas_Button_Flags flags,
1890 //ev->window_pos = ?; 1913 //ev->window_pos = ?;
1891 //ev->fake = 1; 1914 //ev->fake = 1;
1892 1915
1916 /* first, send the cancel action through to trigger POINTER_CANCEL on all
1917 * relevant objects.
1918 * this does not change canvas state in any way.
1919 * note that the 'down' branch can only occur if 'cancel' is not true
1920 */
1893 if (down) 1921 if (down)
1894 _canvas_event_feed_mouse_down_internal(e, ev); 1922 _canvas_event_feed_mouse_down_internal(e, ev);
1895 else 1923 else
1896 _canvas_event_feed_mouse_up_internal(e, ev); 1924 _canvas_event_feed_mouse_up_internal(e, ev);
1897 1925
1898 efl_unref(evt); 1926 efl_unref(evt);
1927
1928 /* next, emit actual up event and perform state changes */
1929 if (cancel)
1930 _canvas_event_feed_mouse_updown(eo_e, b, flags, timestamp, data, down, device, EINA_FALSE);
1899} 1931}
1900 1932
1901static void 1933static void
@@ -1903,7 +1935,7 @@ _canvas_event_feed_mouse_updown_legacy(Eo *eo_e, int b, Evas_Button_Flags flags,
1903 unsigned int timestamp, const void *data, 1935 unsigned int timestamp, const void *data,
1904 Eina_Bool down) 1936 Eina_Bool down)
1905{ 1937{
1906 _canvas_event_feed_mouse_updown(eo_e, b, flags, timestamp, data, down, NULL); 1938 _canvas_event_feed_mouse_updown(eo_e, b, flags, timestamp, data, down, NULL, EINA_FALSE);
1907} 1939}
1908 1940
1909EAPI void 1941EAPI void
@@ -1954,7 +1986,7 @@ _canvas_event_feed_mouse_cancel_internal(Evas_Public_Data *e, Efl_Input_Pointer_
1954 for (i = 0; i < 32; i++) 1986 for (i = 0; i < 32; i++)
1955 { 1987 {
1956 if ((pdata->button & (1u << i))) 1988 if ((pdata->button & (1u << i)))
1957 _canvas_event_feed_mouse_updown(eo_e, i + 1, 0, ev->timestamp, ev->data, 0, ev->device); 1989 _canvas_event_feed_mouse_updown(eo_e, i + 1, 0, ev->timestamp, ev->data, 0, ev->device, EINA_TRUE);
1958 } 1990 }
1959 1991
1960 ev->action = EFL_POINTER_ACTION_CANCEL; 1992 ev->action = EFL_POINTER_ACTION_CANCEL;