efl.canvas.scene: clean up pointer_position property
authorWonki Kim <wonki_.kim@samsung.com>
Thu, 7 Mar 2019 23:45:05 +0000 (08:45 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:35 +0000 (20:49 +0900)
this needed to take a seat param (to handle multiseat) and also have a
bool return to indicate whether a pointer device exists for the specified
seat

ref T7584

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7957

Change-Id: Iecaf379a60aeff9c07cee876dd900ac283955e8d

src/lib/efl/interfaces/efl_canvas_scene.eo
src/lib/elementary/efl_ui_win.c
src/lib/evas/canvas/evas_canvas.eo
src/lib/evas/canvas/evas_device.c
src/tests/elementary/elm_test_win.c

index 77818f0..f1d8d87 100644 (file)
@@ -213,8 +213,11 @@ interface @beta Efl.Canvas.Scene
               This function returns the current position of the main input
               pointer (mouse, pen, etc...).
             ]]
+            return: bool; [[$true if a pointer exists for the given seat, otherwise $false.]]
+         }
+         keys {
+            seat: Efl.Input.Device; [[The seat, or $null to use the default.]]
          }
-         /* FIXME: missing keys { seat } */
          values {
             pos: Eina.Position2D; [[The pointer position in pixels.]]
          }
index dd3779d..e05945b 100644 (file)
@@ -2938,12 +2938,10 @@ _efl_ui_win_efl_gfx_entity_visible_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool v
    else _efl_ui_win_hide(obj, sd);
 }
 
-EOLIAN static Eina_Position2D
-_efl_ui_win_efl_canvas_scene_pointer_position_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
+EOLIAN static Eina_Bool
+_efl_ui_win_efl_canvas_scene_pointer_position_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eo *dev, Eina_Position2D *pos)
 {
-   Eina_Position2D pos;
-   evas_pointer_canvas_xy_get(sd->evas, &pos.x, &pos.y);
-   return pos;
+   return efl_canvas_scene_pointer_position_get(sd->evas, dev, pos);
 }
 
 EOLIAN static Eina_Bool
index 2ce9c47..2e00988 100644 (file)
@@ -966,6 +966,7 @@ class Evas.Canvas extends Efl.Loop_Consumer implements Efl.Canvas.Scene, Efl.Ani
       Efl.Canvas.Scene.device { get; }
       Efl.Canvas.Scene.seat { get; }
       Efl.Canvas.Scene.seat_default { get; }
+      Efl.Canvas.Scene.pointer_position { get; }
       Efl.Canvas.Scene.image_max_size { get; }
       Efl.Canvas.Scene.objects_at_xy_get;
       Efl.Canvas.Scene.object_top_at_xy_get;
index 19a88f6..a3cb063 100644 (file)
@@ -532,6 +532,31 @@ _evas_device_top_get(const Evas *eo_e)
    return eina_array_data_get(e->cur_device, num - 1);
 }
 
+EOLIAN Eina_Bool
+_evas_canvas_efl_canvas_scene_pointer_position_get(const Eo *eo_e, Evas_Public_Data *e, Efl_Input_Device *seat, Eina_Position2D *pos)
+{
+   Eina_Iterator *it;
+   Eo *child;
+
+   if (pos) *pos = EINA_POSITION2D(0, 0);
+   if (!e->default_seat) return EINA_FALSE;
+   if (!seat)
+     {
+        evas_pointer_canvas_xy_get(eo_e, &pos->x, &pos->y);
+        return EINA_TRUE;
+     }
+   it = efl_input_device_children_iterate(seat);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(it, EINA_FALSE);
+
+   EINA_ITERATOR_FOREACH(it, child)
+     if (_is_pointer(efl_input_device_type_get(child)))
+       break;
+   if (child)
+     *pos = efl_input_pointer_position_get(child);
+   eina_iterator_free(it);
+   return !!child;
+}
+
 //TIZEN_ONLY(20171220): send a hw device for pointer events
 EAPI Evas_Device *
 evas_device_top_get(const Evas *eo_e)
@@ -540,6 +565,7 @@ evas_device_top_get(const Evas *eo_e)
 }
 //
 
+//TIZEN_ONLY
 EAPI Evas_Device *
 evas_device_default_get(const Evas *eo_e, Evas_Device_Class clas)
 {
@@ -565,3 +591,5 @@ evas_device_default_get(const Evas *eo_e, Evas_Device_Class clas)
 
    return NULL;
 }
+//
+
index 1b67eab..e08e0d3 100644 (file)
@@ -409,7 +409,7 @@ _inputs_timer3_cb(void *data)
    fail_if(cnt != 2); // 2 moves (in the list), 2 ups (gone)
 
    fail_if(!efl_canvas_pointer_inside_get(win, NULL));
-   pos = efl_canvas_scene_pointer_position_get(win);
+   efl_canvas_scene_pointer_position_get(win, NULL, &pos);
    ck_assert_int_eq(pos.x, points[1][0].x);
    ck_assert_int_eq(pos.y, points[1][0].y);