From e8b69bed83690cd68616680dfcc14f16b6883815 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 8 Jun 2017 11:49:07 +0900 Subject: [PATCH] efl.canvas: Add "seat" (by id) and "device" (by name) properties See d47197e65b59406e0f25c5a4db56e68da61bec30 @feature --- src/lib/efl/Efl.h | 8 +++--- src/lib/efl/interfaces/efl_canvas.eo | 43 ++++++++++++++++++++++++++++ src/lib/evas/canvas/evas_canvas.eo | 6 +++- src/lib/evas/canvas/evas_device.c | 37 ++++++++++++------------ 4 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 8730bd643a..840f6eae89 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -115,6 +115,10 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #include "interfaces/efl_gfx_filter.eo.h" #include "interfaces/efl_gfx_size_hint.eo.h" +/* Input events */ +#include "interfaces/efl_input_types.eot.h" +#include "interfaces/efl_input_device.eo.h" + /* Canvas & UI */ #include "interfaces/efl_canvas.eo.h" #include "interfaces/efl_ui_view.eo.h" @@ -133,10 +137,6 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #include "interfaces/efl_pack_linear.eo.h" #include "interfaces/efl_pack_grid.eo.h" -/* Input events */ -#include "interfaces/efl_input_types.eot.h" -#include "interfaces/efl_input_device.eo.h" - /* Input and Output */ #include "interfaces/efl_io_closer.eo.h" #include "interfaces/efl_io_reader.eo.h" diff --git a/src/lib/efl/interfaces/efl_canvas.eo b/src/lib/efl/interfaces/efl_canvas.eo index 0e2179f37a..5105d4a037 100644 --- a/src/lib/efl/interfaces/efl_canvas.eo +++ b/src/lib/efl/interfaces/efl_canvas.eo @@ -1,3 +1,5 @@ +import efl_input_device; + interface Efl.Canvas () { [[Common interface for window and some internal classes in EFL.]] @@ -158,6 +160,47 @@ interface Efl.Canvas () ]] } } + seats { + [[Iterate over the input device seats. + + @since 1.20 + ]] + return: own(free(iterator, eina_iterator_free)); + [[An iterator over the attached seats.]] + } + @property device { + [[An input device attached to this canvas, found by name. + + Note: This function is meant to find seats and not individual + input devices. + + See also @.seat to find a seat by id instead of by name. + ]] + get { + [[Get a device by name.]] + } + keys { + name: string; [[The name of the seat to find.]] + } + values { + seat: Efl.Input.Device; [[The device or seat, $null if not found.]] + } + } + @property seat { + [[A seat attached to this canvas, found by id. + + See also @.device to find a seat by name instead of by id. + ]] + get { + [[Get a seat by id.]] + } + keys { + id: int; [[The id of the seat to find.]] + } + values { + seat: Efl.Input.Device; [[The seat or $null if not found.]] + } + } } events { focus,in: Efl.Input.Focus; [[Called when canvas got focus]] diff --git a/src/lib/evas/canvas/evas_canvas.eo b/src/lib/evas/canvas/evas_canvas.eo index 7eb70248f0..139112d300 100644 --- a/src/lib/evas/canvas/evas_canvas.eo +++ b/src/lib/evas/canvas/evas_canvas.eo @@ -1118,7 +1118,8 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface, } @property default_device { [[Return the default device of a given type. - \@note Currently Evas only creates a seat, mouse and keyboard. + + Note: Currently EFL only creates a seat, mouse and keyboard. @since 1.19 ]] get {} @@ -1162,5 +1163,8 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface, Efl.Object.event_freeze; Efl.Object.provider_find; Efl.Loop_User.loop { get; } + //Efl.Canvas.seats; + Efl.Canvas.device { get; } + Efl.Canvas.seat { get; } } } diff --git a/src/lib/evas/canvas/evas_device.c b/src/lib/evas/canvas/evas_device.c index 19cd1feb61..574f6e2ba7 100644 --- a/src/lib/evas/canvas/evas_device.c +++ b/src/lib/evas/canvas/evas_device.c @@ -95,20 +95,14 @@ _del_cb(void *data, const Efl_Event *ev) ev->object); } -EAPI Evas_Device * -evas_device_get(Evas *eo_e, const char *name) +EOLIAN Efl_Input_Device * +_evas_canvas_efl_canvas_device_get(Evas *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *name) { const char *dev_name; - Evas_Public_Data *e; Evas_Device *dev; Eina_List *l; - SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL); - - if (!name) - return NULL; - - e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); + if (!name) return NULL; EINA_LIST_FOREACH(e->devices, l, dev) { @@ -122,28 +116,35 @@ evas_device_get(Evas *eo_e, const char *name) } EAPI Evas_Device * -evas_device_get_by_seat_id(Evas *eo_e, unsigned int id) +evas_device_get(Evas *eo_e, const char *name) +{ + return efl_canvas_device_get(eo_e, name); +} + +EOLIAN Efl_Input_Device * +_evas_canvas_efl_canvas_seat_get(Evas *eo_e EINA_UNUSED, Evas_Public_Data *e, unsigned int id) { - unsigned int seat_id; - Evas_Public_Data *e; Evas_Device *dev; Eina_List *l; - SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL); - - e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); - EINA_LIST_FOREACH(e->devices, l, dev) { - seat_id = efl_input_device_seat_id_get(dev); + if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_TYPE_SEAT) + continue; - if (seat_id == id) + if (efl_input_device_seat_id_get(dev) == id) return dev; } return NULL; } +EAPI Evas_Device * +evas_device_get_by_seat_id(Evas *eo_e, unsigned int id) +{ + return efl_canvas_seat_get(eo_e, id); +} + EAPI Evas_Device * evas_device_add(Evas *eo_e) {