bdilly pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=133b4fa65bc92baa3775e178e5e19521da0d7f78

commit 133b4fa65bc92baa3775e178e5e19521da0d7f78
Author: Guilherme Iscaro <isc...@profusion.mobi>
Date:   Mon Nov 21 15:57:05 2016 -0200

    Ecore Wl2: Add ecore_wl2_window_pointer_device_xy_get() API.
    
    This commit adds a Wayland specific function to fetch a mouse
    position.
---
 src/lib/ecore_wl2/Ecore_Wl2.h                      | 13 +++++++++
 src/lib/ecore_wl2/ecore_wl2_input.c                |  9 ------
 src/lib/ecore_wl2/ecore_wl2_private.h              |  9 ++++++
 src/lib/ecore_wl2/ecore_wl2_window.c               | 32 ++++++++++++++++++++++
 .../engines/wayland/ecore_evas_wayland_common.c    | 15 +++++++++-
 .../engines/wayland/ecore_evas_wayland_private.h   |  2 ++
 6 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 37a0ed1..b499e46 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -837,11 +837,24 @@ EAPI void ecore_wl2_window_iconified_set(Ecore_Wl2_Window 
*window, Eina_Bool ico
  * @param y where to return the vertical position. May be NULL. Returns 0 on 
error.
  *
  * @ingroup Ecore_Wl2_Window_Group
+ * @see ecore_wl2_window_pointer_device_xy_get
  * @since 1.17
  */
 EAPI void ecore_wl2_window_pointer_xy_get(Ecore_Wl2_Window *window, int *x, 
int *y);
 
 /**
+ * Retrieves the mouse position of the current window.
+ *
+ * @param window The window on which to retrieve the mouse position.
+ * @param pointer The Efl.Input.Pointer device to fetch the position.
+ * @param x where to return the horizontal position. May be NULL. Returns 0 on 
error.
+ * @param y where to return the vertical position. May be NULL. Returns 0 on 
error.
+ * @ingroup Ecore_Wl2_Window_Group
+ * @since 1.19
+ */
+EAPI void ecore_wl2_window_pointer_device_xy_get(Ecore_Wl2_Window *window, 
const Eo *pointer, int *x, int *y);
+
+/**
  * Set a given wl_surface to use as the pointer on a window
  *
  * @param window The window to set this surface as the pointer on
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c 
b/src/lib/ecore_wl2/ecore_wl2_input.c
index 4e24d1f..91ed398 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -18,15 +18,6 @@
 #include <sys/mman.h>
 #include "ecore_wl2_private.h"
 
-typedef struct _Ecore_Wl2_Input_Devices
-{
-   Eo *pointer_dev;
-   Eo *keyboard_dev;
-   Eo *touch_dev;
-   Eo *seat_dev;
-   int window_id;
-} Ecore_Wl2_Input_Devices;
-
 typedef struct _Ecore_Wl2_Mouse_Down_Info
 {
    EINA_INLIST;
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h 
b/src/lib/ecore_wl2/ecore_wl2_private.h
index 316c79e..a783b0c 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -67,6 +67,15 @@ extern Eina_Bool no_session_recovery;
 # endif
 # define CRI(...) EINA_LOG_DOM_CRIT(_ecore_wl2_log_dom, __VA_ARGS__)
 
+typedef struct _Ecore_Wl2_Input_Devices
+{
+   Eo *pointer_dev;
+   Eo *keyboard_dev;
+   Eo *touch_dev;
+   Eo *seat_dev;
+   int window_id;
+} Ecore_Wl2_Input_Devices;
+
 struct _Ecore_Wl2_Display
 {
    int refs;
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c 
b/src/lib/ecore_wl2/ecore_wl2_window.c
index 944324a..253d598 100644
--- a/src/lib/ecore_wl2/ecore_wl2_window.c
+++ b/src/lib/ecore_wl2/ecore_wl2_window.c
@@ -942,6 +942,38 @@ ecore_wl2_window_pointer_xy_get(Ecore_Wl2_Window *window, 
int *x, int *y)
 }
 
 EAPI void
+ecore_wl2_window_pointer_device_xy_get(Ecore_Wl2_Window *window,
+                                       const Eo *pointer,
+                                       int *x, int *y)
+{
+   Ecore_Wl2_Input_Devices *devs;
+   Eina_List *l;
+   Ecore_Wl2_Input *input;
+
+   EINA_SAFETY_ON_NULL_RETURN(window);
+   EINA_SAFETY_ON_NULL_RETURN(pointer);
+
+   if (x) *x = 0;
+   if (y) *y = 0;
+
+   EINA_INLIST_FOREACH(window->display->inputs, input)
+     {
+        if (!input->wl.pointer)
+          continue;
+
+        EINA_LIST_FOREACH(input->devices_list, l, devs)
+          {
+             if ((devs->window_id == window->id) &&
+                 (devs->pointer_dev == pointer))
+               {
+                  if (x) *x = input->pointer.sx;
+                  if (y) *y = input->pointer.sy;
+               }
+          }
+     }
+}
+
+EAPI void
 ecore_wl2_window_pointer_set(Ecore_Wl2_Window *window, struct wl_surface 
*surface, int hot_x, int hot_y)
 {
    Ecore_Wl2_Input *input;
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c 
b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index 565ff81..6bd4528 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -90,7 +90,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    NULL, //fn_callback_focus_device_out_set
    NULL, //fn_callback_device_mouse_in_set
    NULL, //fn_callback_device_mouse_out_set
-   NULL, //fn_pointer_device_xy_get
+   _ecore_evas_wl_common_pointer_device_xy_get,
 };
 
 #define _smart_frame_type "ecore_evas_wl_frame"
@@ -1134,6 +1134,19 @@ _ecore_evas_wl_common_pointer_xy_get(const Ecore_Evas 
*ee, Evas_Coord *x, Evas_C
 }
 
 void
+_ecore_evas_wl_common_pointer_device_xy_get(const Ecore_Evas *ee,
+                                            const Efl_Input_Device *pointer,
+                                            Evas_Coord *x, Evas_Coord *y)
+{
+   Ecore_Evas_Engine_Wl_Data *wdata;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   wdata = ee->engine.data;
+   ecore_wl2_window_pointer_device_xy_get(wdata->win, pointer, x, y);
+}
+
+void
 _ecore_evas_wl_common_raise(Ecore_Evas *ee)
 {
    Ecore_Evas_Engine_Wl_Data *wdata;
diff --git 
a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h 
b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
index cb02409..075bd6d 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h
@@ -103,6 +103,8 @@ void _ecore_evas_wl_common_transparent_set(Ecore_Evas *ee, 
int transparent);
 void _ecore_evas_wl_common_frame_callback_clean(Ecore_Evas *ee);
 void _ecore_evas_wl_common_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, 
Evas_Coord *y);
 
+void _ecore_evas_wl_common_pointer_device_xy_get(const Ecore_Evas *ee, const 
Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y);
+
 Ecore_Evas *_ecore_evas_wl_common_new_internal(const char *disp_name, unsigned 
int parent, int x, int y, int w, int h, Eina_Bool frame, const char 
*engine_name);
 
 extern Eina_List *ee_list;

-- 


Reply via email to