Ecore Wl2: Add ecore_wl2_window_pointer_device_xy_get() API.

This commit adds a Wayland specific function to fetch a mouse
position.
This commit is contained in:
Guilherme Iscaro 2016-11-21 15:57:05 -02:00 committed by Bruno Dilly
parent 64986bccac
commit 133b4fa65b
6 changed files with 70 additions and 10 deletions

View File

@ -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
*

View File

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

View File

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

View File

@ -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)
{

View File

@ -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)
{

View File

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