efl.canvas.scene: clean up pointer_position property

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
This commit is contained in:
Mike Blumenkrantz 2019-02-14 15:21:15 -05:00 committed by Marcel Hollerbach
parent 2df6e1103d
commit 99c3d42efd
5 changed files with 34 additions and 7 deletions

View 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.]]
}

View File

@ -2458,12 +2458,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

View 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;

View File

@ -526,3 +526,28 @@ _evas_device_top_get(const Evas *eo_e)
if (num < 1) return NULL;
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;
}

View 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);