diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 37a0ed1924..b499e46cf3 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -837,10 +837,23 @@ 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 * diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 4e24d1ffbb..91ed39890c 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -18,15 +18,6 @@ #include #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 316c79e22c..a783b0ca75 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 944324ab2a..253d5984f9 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -941,6 +941,38 @@ ecore_wl2_window_pointer_xy_get(Ecore_Wl2_Window *window, int *x, int *y) if (y) *y = input->pointer.sy; } +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) { 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 565ff8187f..6bd452854b 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" @@ -1133,6 +1133,19 @@ _ecore_evas_wl_common_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_C ecore_wl2_window_pointer_xy_get(wdata->win, x, 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_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) { 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 cb02409437..075bd6d7f3 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;