summaryrefslogtreecommitdiff
path: root/src/lib/ecore_evas
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-06-02 18:23:44 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-06-02 18:23:42 -0400
commita7ed5d05403f1bd1a36ae86544504c19311cb577 (patch)
treee3bfcdd2a18176686753d4f6c2685d61ee8efecd /src/lib/ecore_evas
parent2a0b6ddebd3d4ab65d6153ee3503b701cdb9eb6f (diff)
ecore-evas: redo per-device cursor internals to be per-seat
seats have cursors, pointer devices do not. @fix fix T5531
Diffstat (limited to 'src/lib/ecore_evas')
-rw-r--r--src/lib/ecore_evas/ecore_evas.c133
1 files changed, 103 insertions, 30 deletions
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index a752ee864f..d9ad82e59e 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -341,10 +341,17 @@ _ecore_evas_cursor_element_del(Ecore_Evas_Cursor *cursor)
341static void 341static void
342_ecore_evas_cursor_add(Ecore_Evas *ee, Efl_Input_Device *dev) 342_ecore_evas_cursor_add(Ecore_Evas *ee, Efl_Input_Device *dev)
343{ 343{
344 Ecore_Evas_Cursor *cursor = calloc(1, sizeof(Ecore_Evas_Cursor)); 344 Ecore_Evas_Cursor *cursor;
345 Eo *seat;
346
347 seat = dev;
348 if (evas_device_class_get(dev) != EVAS_DEVICE_CLASS_SEAT)
349 seat = evas_device_parent_get(dev);
350 if (eina_hash_find(ee->prop.cursors, &seat)) return;
351 cursor = calloc(1, sizeof(Ecore_Evas_Cursor));
345 EINA_SAFETY_ON_NULL_RETURN(cursor); 352 EINA_SAFETY_ON_NULL_RETURN(cursor);
346 eina_hash_add(ee->prop.cursors, &dev, cursor); 353 eina_hash_add(ee->prop.cursors, &seat, cursor);
347 if (dev != evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE)) return; 354 if (seat != evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT)) return;
348 if (ee->prop.cursor_cache.object) 355 if (ee->prop.cursor_cache.object)
349 { 356 {
350 ecore_evas_object_cursor_device_set(ee, dev, 357 ecore_evas_object_cursor_device_set(ee, dev,
@@ -356,22 +363,43 @@ _ecore_evas_cursor_add(Ecore_Evas *ee, Efl_Input_Device *dev)
356 } 363 }
357} 364}
358 365
366static inline Eina_Bool
367_is_pointer(Eo *dev)
368{
369 Efl_Input_Device_Class c = efl_input_device_type_get(dev);
370 return (c == EFL_INPUT_DEVICE_CLASS_MOUSE) ||
371 (c == EFL_INPUT_DEVICE_CLASS_PEN) ||
372 (c == EFL_INPUT_DEVICE_CLASS_TOUCH) ||
373 (c == EFL_INPUT_DEVICE_CLASS_WAND);
374}
375
359static void 376static void
360_ecore_evas_dev_added_or_removed(void *data, const Efl_Event *event) 377_ecore_evas_dev_added_or_removed(void *data, const Efl_Event *event)
361{ 378{
362 Ecore_Evas *ee = data; 379 Ecore_Evas *ee = data;
363 Efl_Input_Device_Class c = efl_input_device_type_get(event->info);
364
365 if ((c != EFL_INPUT_DEVICE_CLASS_MOUSE) &&
366 (c != EFL_INPUT_DEVICE_CLASS_PEN) &&
367 (c != EFL_INPUT_DEVICE_CLASS_TOUCH) &&
368 (c != EFL_INPUT_DEVICE_CLASS_WAND))
369 return;
370 380
371 if (event->desc == EFL_CANVAS_EVENT_DEVICE_ADDED) 381 if (event->desc == EFL_CANVAS_EVENT_DEVICE_ADDED)
372 _ecore_evas_cursor_add(ee, event->info); 382 {
383 if (_is_pointer(event->info))
384 _ecore_evas_cursor_add(ee, event->info);
385 }
373 else 386 else
374 eina_hash_del_by_key(ee->prop.cursors, &event->info); 387 {
388 Eina_Iterator *it;
389 Eina_Bool found = EINA_FALSE;
390 Eo *dev, *seat = efl_input_device_parent_get(event->info);
391
392 it = efl_input_device_children_iterate(seat);
393 EINA_ITERATOR_FOREACH(it, dev)
394 if ((dev != event->info) && _is_pointer(dev))
395 {
396 found = EINA_TRUE;
397 break;
398 }
399 eina_iterator_free(it);
400 if (!found)
401 eina_hash_del_by_key(ee->prop.cursors, &seat);
402 }
375} 403}
376 404
377EFL_CALLBACKS_ARRAY_DEFINE(_ecore_evas_device_cbs, 405EFL_CALLBACKS_ARRAY_DEFINE(_ecore_evas_device_cbs,
@@ -391,13 +419,8 @@ _ecore_evas_cursors_init(Ecore_Evas *ee)
391 419
392 EINA_LIST_FOREACH(devs, l, dev) 420 EINA_LIST_FOREACH(devs, l, dev)
393 { 421 {
394 Efl_Input_Device_Class c = efl_input_device_type_get(dev); 422 if (_is_pointer(dev))
395 if ((c != EFL_INPUT_DEVICE_CLASS_MOUSE) && 423 _ecore_evas_cursor_add(ee, dev);
396 (c != EFL_INPUT_DEVICE_CLASS_PEN) &&
397 (c != EFL_INPUT_DEVICE_CLASS_TOUCH) &&
398 (c != EFL_INPUT_DEVICE_CLASS_WAND))
399 continue;
400 _ecore_evas_cursor_add(ee, dev);
401 } 424 }
402 425
403 efl_event_callback_array_priority_add(ee->evas, _ecore_evas_device_cbs(), 426 efl_event_callback_array_priority_add(ee->evas, _ecore_evas_device_cbs(),
@@ -1706,7 +1729,7 @@ _ecore_evas_default_cursor_image_get(Ecore_Evas *ee)
1706 Efl_Input_Device *pointer; 1729 Efl_Input_Device *pointer;
1707 Ecore_Evas_Cursor *cursor; 1730 Ecore_Evas_Cursor *cursor;
1708 1731
1709 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); 1732 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT);
1710 cursor = eina_hash_find(ee->prop.cursors, &pointer); 1733 cursor = eina_hash_find(ee->prop.cursors, &pointer);
1711 EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, NULL); 1734 EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, NULL);
1712 return cursor->object; 1735 return cursor->object;
@@ -1718,7 +1741,7 @@ _ecore_evas_default_cursor_hide(Ecore_Evas *ee)
1718 Efl_Input_Device *pointer; 1741 Efl_Input_Device *pointer;
1719 Ecore_Evas_Cursor *cursor; 1742 Ecore_Evas_Cursor *cursor;
1720 1743
1721 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); 1744 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT);
1722 cursor = eina_hash_find(ee->prop.cursors, &pointer); 1745 cursor = eina_hash_find(ee->prop.cursors, &pointer);
1723 EINA_SAFETY_ON_NULL_RETURN(cursor); 1746 EINA_SAFETY_ON_NULL_RETURN(cursor);
1724 if (cursor->object) 1747 if (cursor->object)
@@ -1737,8 +1760,18 @@ _ecore_evas_object_cursor_device_set(Ecore_Evas *ee, Efl_Input_Device *pointer,
1737 1760
1738 ECORE_EVAS_CHECK(ee); 1761 ECORE_EVAS_CHECK(ee);
1739 1762
1740 dpointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); 1763 dpointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT);
1741 if (!pointer) 1764 if (pointer)
1765 {
1766 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
1767 pointer = efl_input_device_parent_get(pointer);
1768 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
1769 {
1770 ERR("Could not find seat");
1771 return;
1772 }
1773 }
1774 else
1742 { 1775 {
1743 pointer = dpointer; 1776 pointer = dpointer;
1744 if (!pointer) 1777 if (!pointer)
@@ -1842,8 +1875,18 @@ ecore_evas_cursor_device_get(const Ecore_Evas *ee, Efl_Input_Device *pointer,
1842 1875
1843 ECORE_EVAS_CHECK_GOTO(ee, err); 1876 ECORE_EVAS_CHECK_GOTO(ee, err);
1844 1877
1845 if (!pointer) 1878 if (pointer)
1846 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); 1879 {
1880 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
1881 pointer = efl_input_device_parent_get(pointer);
1882 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
1883 {
1884 ERR("Could not find seat");
1885 return EINA_FALSE;
1886 }
1887 }
1888 else
1889 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT);
1847 if (pointer) 1890 if (pointer)
1848 { 1891 {
1849 cursor = eina_hash_find(ee->prop.cursors, &pointer); 1892 cursor = eina_hash_find(ee->prop.cursors, &pointer);
@@ -1879,8 +1922,18 @@ ecore_evas_cursor_device_unset(Ecore_Evas *ee, Efl_Input_Device *pointer)
1879 1922
1880 ECORE_EVAS_CHECK(ee, NULL); 1923 ECORE_EVAS_CHECK(ee, NULL);
1881 1924
1882 if (!pointer) 1925 if (pointer)
1883 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); 1926 {
1927 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
1928 pointer = efl_input_device_parent_get(pointer);
1929 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
1930 {
1931 ERR("Could not find seat");
1932 return NULL;
1933 }
1934 }
1935 else
1936 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT);
1884 if (pointer) 1937 if (pointer)
1885 cursor = eina_hash_find(ee->prop.cursors, &pointer); 1938 cursor = eina_hash_find(ee->prop.cursors, &pointer);
1886 EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, NULL); 1939 EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, NULL);
@@ -2706,8 +2759,18 @@ ecore_evas_pointer_device_xy_get(const Ecore_Evas *ee,
2706{ 2759{
2707 ECORE_EVAS_CHECK(ee); 2760 ECORE_EVAS_CHECK(ee);
2708 2761
2762 if (pointer)
2763 {
2764 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
2765 pointer = efl_input_device_parent_get(pointer);
2766 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
2767 {
2768 ERR("Could not find seat");
2769 return;
2770 }
2771 }
2709 if ((!pointer) || 2772 if ((!pointer) ||
2710 (pointer == evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE))) 2773 (pointer == evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT)))
2711 ecore_evas_pointer_xy_get(ee, x, y); 2774 ecore_evas_pointer_xy_get(ee, x, y);
2712 else 2775 else
2713 { 2776 {
@@ -3282,8 +3345,18 @@ _ecore_evas_mouse_move_process_internal(Ecore_Evas *ee,
3282 3345
3283 evas_output_framespace_get(ee->evas, &fx, &fy, &fw, &fh); 3346 evas_output_framespace_get(ee->evas, &fx, &fy, &fw, &fh);
3284 3347
3285 if (!pointer) 3348 if (pointer)
3286 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); 3349 {
3350 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
3351 pointer = efl_input_device_parent_get(pointer);
3352 if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_SEAT)
3353 {
3354 ERR("Could not find seat");
3355 return;
3356 }
3357 }
3358 else
3359 pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_SEAT);
3287 cursor = eina_hash_find(ee->prop.cursors, &pointer); 3360 cursor = eina_hash_find(ee->prop.cursors, &pointer);
3288 if (cursor) 3361 if (cursor)
3289 { 3362 {