From 64986bccac5bdaddaa46dc1b9c411e00191f6590 Mon Sep 17 00:00:00 2001 From: Guilherme Iscaro Date: Mon, 21 Nov 2016 15:11:08 -0200 Subject: [PATCH 1/6] Ecore Evas: Add API to set/get the pointer position per device. Since Ecore Evas now support multiple mouse devices new APIs were added in order to fetch the mouse position. --- src/lib/ecore_evas/Ecore_Evas.h | 14 +++++++++++++- src/lib/ecore_evas/ecore_evas.c | 17 +++++++++++++++++ src/lib/ecore_evas/ecore_evas_buffer.c | 1 + src/lib/ecore_evas/ecore_evas_ews.c | 1 + src/lib/ecore_evas/ecore_evas_private.h | 1 + .../ecore_evas/engines/cocoa/ecore_evas_cocoa.c | 1 + .../ecore_evas/engines/drm/ecore_evas_drm.c | 1 + .../ecore_evas/engines/extn/ecore_evas_extn.c | 1 + .../ecore_evas/engines/fb/ecore_evas_fb.c | 1 + .../engines/psl1ght/ecore_evas_psl1ght.c | 1 + .../ecore_evas/engines/sdl/ecore_evas_sdl.c | 1 + .../engines/wayland/ecore_evas_wayland_common.c | 1 + .../ecore_evas/engines/win32/ecore_evas_win32.c | 1 + src/modules/ecore_evas/engines/x/ecore_evas_x.c | 1 + 14 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h index c2295f8e78..19493f872b 100644 --- a/src/lib/ecore_evas/Ecore_Evas.h +++ b/src/lib/ecore_evas/Ecore_Evas.h @@ -2917,12 +2917,13 @@ EAPI Evas_Object *ecore_evas_extn_plug_new(Ecore_Evas *ee_target); EAPI Eina_Bool ecore_evas_extn_plug_connect(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys); /** - * @brief Retrieve the coordinates of the mouse pointer + * @brief Retrieve the coordinates of the default mouse pointer * * @param ee The Ecore_Evas containing the pointer * @param x Pointer to integer to store horizontal coordinate. May be @c NULL. * @param y Pointer to integer to store vertical coordinate. May be @c NULL. * + * @see ecore_evas_pointer_device_xy_get * @since 1.8 */ EAPI void ecore_evas_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y); @@ -2940,6 +2941,17 @@ EAPI void ecore_evas_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_Co */ EAPI Eina_Bool ecore_evas_pointer_warp(const Ecore_Evas *ee, Evas_Coord x, Evas_Coord y); +/** + * @brief Retrieve the coordinates of the mouse pointer + * + * @param ee The Ecore_Evas containing the pointer + * @param pointer The pointer device, use @c NULL for the default pointer. + * @param x Pointer to integer to store horizontal coordinate. May be @c NULL. + * @param y Pointer to integer to store vertical coordinate. May be @c NULL. + * @since 1.19 + */ +EAPI void ecore_evas_pointer_device_xy_get(const Ecore_Evas *ee, const Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y); + /** * @brief Retrieve the Visual used for pixmap creation * diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index ea4ce4bcff..43ec72a6ad 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -2381,6 +2381,23 @@ ecore_evas_pointer_warp(const Ecore_Evas *ee, Evas_Coord x, Evas_Coord y) return EINA_FALSE; } +EAPI void +ecore_evas_pointer_device_xy_get(const Ecore_Evas *ee, + const Efl_Input_Device *pointer, Evas_Coord *x, + Evas_Coord *y) +{ + if (!pointer || pointer == evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE)) + ecore_evas_pointer_xy_get(ee, x, y); + else + { + if (x) *x = 0; + if (y) *y = 0; + ECORE_EVAS_CHECK(ee); + if (ee->engine.func->fn_pointer_device_xy_get) + ee->engine.func->fn_pointer_device_xy_get(ee, pointer, x, y); + } +} + EAPI void * ecore_evas_pixmap_visual_get(const Ecore_Evas *ee) { diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c b/src/lib/ecore_evas/ecore_evas_buffer.c index 0d1643cdfb..979f92580d 100644 --- a/src/lib/ecore_evas/ecore_evas_buffer.c +++ b/src/lib/ecore_evas/ecore_evas_buffer.c @@ -607,6 +607,7 @@ static Ecore_Evas_Engine_Func _ecore_buffer_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 }; static void * diff --git a/src/lib/ecore_evas/ecore_evas_ews.c b/src/lib/ecore_evas/ecore_evas_ews.c index 693e9db126..719d5ea6df 100644 --- a/src/lib/ecore_evas/ecore_evas_ews.c +++ b/src/lib/ecore_evas/ecore_evas_ews.c @@ -719,6 +719,7 @@ static const Ecore_Evas_Engine_Func _ecore_ews_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 }; void diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h index f9c66fea1d..919d2dac40 100644 --- a/src/lib/ecore_evas/ecore_evas_private.h +++ b/src/lib/ecore_evas/ecore_evas_private.h @@ -165,6 +165,7 @@ struct _Ecore_Evas_Engine_Func void (*fn_callback_device_mouse_in_set) (Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func); void (*fn_callback_device_mouse_out_set) (Ecore_Evas *ee, Ecore_Evas_Mouse_IO_Cb func); + void (*fn_pointer_device_xy_get)(const Ecore_Evas *ee, const Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y); }; struct _Ecore_Evas_Interface diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c index a2afc3db4e..488ed67a0d 100644 --- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c +++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c @@ -675,6 +675,7 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_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 }; static Ecore_Cocoa_Window * diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c index d8d4d6abde..b1ab702a01 100644 --- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c +++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c @@ -796,6 +796,7 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func = NULL, //fn_focus_device_set NULL, //fn_callback_focus_device_in_set NULL, //fn_callback_focus_device_out_set + NULL, //fn_pointer_device_xy_get }; static Ecore_Evas * diff --git a/src/modules/ecore_evas/engines/extn/ecore_evas_extn.c b/src/modules/ecore_evas/engines/extn/ecore_evas_extn.c index 3b364d8a52..24b230b754 100644 --- a/src/modules/ecore_evas/engines/extn/ecore_evas_extn.c +++ b/src/modules/ecore_evas/engines/extn/ecore_evas_extn.c @@ -925,6 +925,7 @@ static const Ecore_Evas_Engine_Func _ecore_extn_plug_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 }; static Eina_Bool diff --git a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c index f5d84bd2fc..2e828624a8 100644 --- a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c +++ b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c @@ -642,6 +642,7 @@ static Ecore_Evas_Engine_Func _ecore_fb_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 }; EAPI Ecore_Evas * diff --git a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c index fc8c6ce801..a65a61a776 100644 --- a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c +++ b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c @@ -463,6 +463,7 @@ static Ecore_Evas_Engine_Func _ecore_psl1ght_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 }; EAPI Ecore_Evas * diff --git a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c index 440185e1db..782d06513e 100644 --- a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c +++ b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c @@ -555,6 +555,7 @@ static Ecore_Evas_Engine_Func _ecore_sdl_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 }; static Ecore_Evas* 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 85a103f637..565ff8187f 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,6 +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 }; #define _smart_frame_type "ecore_evas_wl_frame" diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c index 27b416089e..4469c66fca 100644 --- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c +++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c @@ -1207,6 +1207,7 @@ static Ecore_Evas_Engine_Func _ecore_win32_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 }; #endif /* BUILD_ECORE_EVAS_WIN32 */ diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c b/src/modules/ecore_evas/engines/x/ecore_evas_x.c index b6e4009a31..3c52034cb4 100644 --- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c +++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c @@ -3788,6 +3788,7 @@ static Ecore_Evas_Engine_Func _ecore_x_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 }; /* From 133b4fa65bc92baa3775e178e5e19521da0d7f78 Mon Sep 17 00:00:00 2001 From: Guilherme Iscaro Date: Mon, 21 Nov 2016 15:57:05 -0200 Subject: [PATCH 2/6] 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 +++++++++++++++++++ .../wayland/ecore_evas_wayland_common.c | 15 ++++++++- .../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 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; From 2e527851cfdfaa6efc0e261cea978e5cf11afac2 Mon Sep 17 00:00:00 2001 From: Guilherme Iscaro Date: Mon, 21 Nov 2016 17:05:18 -0200 Subject: [PATCH 3/6] Ecore Evas VNC: Add support for ecore_evas_pointer_device_xy_get(). This commit adds the support to fetch the mouse position of a VNC client. --- src/lib/ecore_evas/ecore_evas.c | 14 +++++++- .../vnc_server/ecore_evas_vnc_server.c | 33 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index 43ec72a6ad..b493383b43 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -2393,7 +2393,19 @@ ecore_evas_pointer_device_xy_get(const Ecore_Evas *ee, if (x) *x = 0; if (y) *y = 0; ECORE_EVAS_CHECK(ee); - if (ee->engine.func->fn_pointer_device_xy_get) + if (ee->vnc_server) + { + Eina_Module *mod; + void (*pointer_xy_get)(const void *, const Efl_Input_Device *, Evas_Coord *, Evas_Coord *y); + + mod = _ecore_evas_vnc_server_module_load(); + EINA_SAFETY_ON_NULL_RETURN(mod); + + pointer_xy_get = eina_module_symbol_get(mod, "ecore_evas_vnc_server_pointer_xy_get"); + EINA_SAFETY_ON_NULL_RETURN(pointer_xy_get); + pointer_xy_get(ee->vnc_server, pointer, x, y); + } + else if (ee->engine.func->fn_pointer_device_xy_get) ee->engine.func->fn_pointer_device_xy_get(ee, pointer, x, y); } } diff --git a/src/modules/ecore_evas/vnc_server/ecore_evas_vnc_server.c b/src/modules/ecore_evas/vnc_server/ecore_evas_vnc_server.c index c55fb9cf7e..88c02d22db 100644 --- a/src/modules/ecore_evas/vnc_server/ecore_evas_vnc_server.c +++ b/src/modules/ecore_evas/vnc_server/ecore_evas_vnc_server.c @@ -893,5 +893,38 @@ ecore_evas_vnc_server_del(Ecore_Evas_Vnc_Server *server) free(server); } +EAPI void +ecore_evas_vnc_server_pointer_xy_get(const Ecore_Evas_Vnc_Server *server, + const Evas_Device *pointer, + Evas_Coord *x, Evas_Coord *y) +{ + Evas_Coord sx, sy; + rfbClientIteratorPtr itr; + rfbClientRec *client; + Ecore_Evas_Vnc_Server_Client_Data *cdata; + + EINA_SAFETY_ON_NULL_RETURN(server); + EINA_SAFETY_ON_NULL_RETURN(pointer); + + sx = sy = 0; + itr = rfbGetClientIterator(server->vnc_screen); + + while ((client = rfbClientIteratorNext(itr))) + { + cdata = client->clientData; + + if (cdata->mouse == pointer) + { + sx = client->lastPtrX; + sy = client->lastPtrY; + break; + } + } + + rfbReleaseClientIterator(itr); + if (x) *x = sx; + if (y) *y = sy; +} + EINA_MODULE_INIT(_ecore_evas_vnc_server_init); EINA_MODULE_SHUTDOWN(_ecore_evas_vnc_server_shutdown); From e5acc5604a5bb728f1affc0a839878de55f5dafc Mon Sep 17 00:00:00 2001 From: Guilherme Iscaro Date: Tue, 22 Nov 2016 16:14:03 -0200 Subject: [PATCH 4/6] Ecore Evas: Add support to set cursor icon per mouse device. Since Ecore Evas now supports multiple mouses new APIs were added in order to be able to set the cursor image to any device. --- src/lib/ecore_evas/Ecore_Evas.h | 50 +- src/lib/ecore_evas/ecore_evas.c | 532 ++++++++++++++++-- src/lib/ecore_evas/ecore_evas_buffer.c | 5 + src/lib/ecore_evas/ecore_evas_ews.c | 56 +- src/lib/ecore_evas/ecore_evas_private.h | 27 +- .../engines/cocoa/ecore_evas_cocoa.c | 69 +-- .../ecore_evas/engines/drm/ecore_evas_drm.c | 66 +-- .../ecore_evas/engines/fb/ecore_evas_fb.c | 100 +--- .../engines/psl1ght/ecore_evas_psl1ght.c | 64 +-- .../ecore_evas/engines/sdl/ecore_evas_sdl.c | 64 +-- .../wayland/ecore_evas_wayland_common.c | 74 +-- .../engines/win32/ecore_evas_win32.c | 67 +-- .../ecore_evas/engines/x/ecore_evas_x.c | 67 +-- 13 files changed, 608 insertions(+), 633 deletions(-) diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h index 19493f872b..0af4bccab8 100644 --- a/src/lib/ecore_evas/Ecore_Evas.h +++ b/src/lib/ecore_evas/Ecore_Evas.h @@ -2143,7 +2143,7 @@ EAPI void ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h); EAPI void ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h); /** - * @brief Set the cursor of an Ecore_Evas. + * @brief Set the cursor for the default pointer device. * * @param ee The Ecore_Evas * @param file The path to an image file for the cursor. @@ -2166,9 +2166,9 @@ EAPI void ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h); */ EAPI void ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y); /** - * @brief Get information about an Ecore_Evas' cursor + * @brief Get information about an Ecore_Evas' default pointer device. * - * @param ee The Ecore_Evas to set + * @param ee The Ecore_Evas to get * @param obj A pointer to an Evas_Object to place the cursor Evas_Object. * @param layer A pointer to an int to place the cursor's layer in. * @param hot_x A pointer to an int to place the cursor's hot_x coordinate in. @@ -2183,10 +2183,9 @@ EAPI void ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int lay EAPI void ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y); /** - * @brief Set the cursor of an Ecore_Evas + * @brief Set the cursor for the default pointer device. * * @param ee The Ecore_Evas - * * @param obj The Evas_Object which will be the cursor. * @param layer The layer in which the cursor will appear. * @param hot_x The x coordinate of the cursor's hot spot. @@ -2202,7 +2201,7 @@ EAPI void ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y); /** - * @brief Unset the Ecore_Evas cursor + * @brief Unset the cursor of the default pointer device. * * @param ee The Ecore_Evas to unset the cursor. * @@ -2217,6 +2216,45 @@ EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, */ EAPI Evas_Object* ecore_evas_cursor_unset(Ecore_Evas *ee); +/** + * @brief Set the cursor of an Ecore_Evas specified pointer device. + * + * @param ee The Ecore_Evas + * @param pointer A pointer device to set the cursor. Use @c NULL for the default. + * @param obj The Evas_Object which will be the cursor. + * @param layer The layer in which the cursor will appear. + * @param hot_x The x coordinate of the cursor's hot spot. + * @param hot_y The y coordinate of the cursor's hot spot. + * + * This function makes the mouse cursor over @p ee be the object specified by + * @p obj. The actual point within the object that the mouse is at is specified + * by @p hot_x and @p hot_y, which are coordinates with respect to the top left + * corner of the cursor object. Cursor object will be delete with the Ecore_Evas. + * + * @since 1.19 + */ +EAPI void ecore_evas_object_cursor_device_set(Ecore_Evas *ee, Efl_Input_Device *pointer, + Evas_Object *obj, int layer, + int hot_x, int hot_y); +/** + * @brief Get information about an Ecore_Evas' specified pointer device. + * + * @param ee The Ecore_Evas + * @param pointer A pointer device to set the cursor. Use @c NULL for the default. + * @param obj A pointer to an Evas_Object to place the cursor Evas_Object. + * @param layer A pointer to an int to place the cursor's layer in. + * @param hot_x A pointer to an int to place the cursor's hot_x coordinate in. + * @param hot_y A pointer to an int to place the cursor's hot_y coordinate in. + * + * This function queries information about an Ecore_Evas' cursor. + * + * @see ecore_evas_cursor_device_set() + * @since 1.19 + */ +EAPI Eina_Bool ecore_evas_cursor_device_get(const Ecore_Evas *ee, Efl_Input_Device *pointer, + Evas_Object **obj, int *layer, + int *hot_x, int *hot_y); + /** * @brief Tell the WM whether or not to ignore an Ecore_Evas' window * diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index b493383b43..da485a8211 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -51,6 +51,13 @@ return __VA_ARGS__; \ } +#define ECORE_EVAS_CHECK_GOTO(_ee, _label) \ + if (!ECORE_MAGIC_CHECK(_ee, ECORE_MAGIC_EVAS)) \ + { \ + ECORE_MAGIC_FAIL(_ee, ECORE_MAGIC_EVAS, __FUNCTION__); \ + goto _label; \ + } + EAPI Eina_Bool _ecore_evas_app_comp_sync = EINA_FALSE; EAPI int _ecore_evas_log_dom = -1; static int _ecore_evas_init_count = 0; @@ -62,6 +69,8 @@ static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL; static Ecore_Evas *ecore_evases = NULL; static int _ecore_evas_fps_debug = 0; +static const Efl_Event_Description *_event_description_get(Efl_Pointer_Action action); + //RENDER_SYNC static int _ecore_evas_render_sync = 1; @@ -246,6 +255,87 @@ _ecore_evas_idle_enter(void *data EINA_UNUSED) return ECORE_CALLBACK_RENEW; } +static void +_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Ecore_Evas_Cursor *cursor = data; + cursor->object = NULL; +} + +static void +_ecore_evas_cursor_element_del(Ecore_Evas_Cursor *cursor) +{ + if (cursor->object) + { + evas_object_event_callback_del_full(cursor->object, EVAS_CALLBACK_DEL, + _ecore_evas_object_cursor_del, + cursor); + evas_object_del(cursor->object); + } + free(cursor); +} + +static void +_ecore_evas_cursor_add(Ecore_Evas *ee, Efl_Input_Device *dev) +{ + Ecore_Evas_Cursor *cursor = calloc(1, sizeof(Ecore_Evas_Cursor)); + EINA_SAFETY_ON_NULL_RETURN(cursor); + eina_hash_add(ee->prop.cursors, &dev, cursor); + if (ee->prop.cursor_cache.object) + { + ecore_evas_object_cursor_device_set(ee, dev, + ee->prop.cursor_cache.object, + ee->prop.cursor_cache.layer, + ee->prop.cursor_cache.hot.x, + ee->prop.cursor_cache.hot.y); + memset(&ee->prop.cursor_cache, 0, sizeof(Ecore_Evas_Cursor)); + } +} + +static void +_ecore_evas_dev_added_or_removed(void *data, const Efl_Event *event) +{ + Ecore_Evas *ee = data; + + if (efl_input_device_type_get(event->info) != EFL_INPUT_DEVICE_CLASS_MOUSE) + return; + + if (event->desc == EFL_CANVAS_EVENT_DEVICE_ADDED) + _ecore_evas_cursor_add(ee, event->info); + else + eina_hash_del_by_key(ee->prop.cursors, &event->info); +} + +EFL_CALLBACKS_ARRAY_DEFINE(_ecore_evas_device_cbs, + { EFL_CANVAS_EVENT_DEVICE_ADDED, _ecore_evas_dev_added_or_removed }, + { EFL_CANVAS_EVENT_DEVICE_REMOVED, _ecore_evas_dev_added_or_removed }); +Eina_Bool +_ecore_evas_cursors_init(Ecore_Evas *ee) +{ + const Eina_List *devs, *l; + Efl_Input_Device *dev; + + EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EINA_FALSE); + ee->prop.cursors = eina_hash_pointer_new(EINA_FREE_CB(_ecore_evas_cursor_element_del)); + EINA_SAFETY_ON_NULL_RETURN_VAL(ee->prop.cursors, EINA_FALSE); + + devs = evas_device_list(ee->evas, NULL); + + EINA_LIST_FOREACH(devs, l, dev) + { + if (efl_input_device_type_get(dev) != EFL_INPUT_DEVICE_CLASS_MOUSE) + continue; + _ecore_evas_cursor_add(ee, dev); + } + + efl_event_callback_array_priority_add(ee->evas, _ecore_evas_device_cbs(), + EFL_CALLBACK_PRIORITY_BEFORE, ee); + + return EINA_TRUE; +} + EAPI Ecore_Evas_Interface * _ecore_evas_interface_get(const Ecore_Evas *ee, const char *iname) { @@ -1534,13 +1624,106 @@ ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h) } } -EAPI void -ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y) +EAPI Evas_Object * +_ecore_evas_default_cursor_image_get(Ecore_Evas *ee) { - Evas_Object *obj = NULL; + Efl_Input_Device *pointer; + Ecore_Evas_Cursor *cursor; + + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, NULL); + return cursor->object; +} + +EAPI void +_ecore_evas_default_cursor_hide(Ecore_Evas *ee) +{ + Efl_Input_Device *pointer; + Ecore_Evas_Cursor *cursor; + + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + if (cursor->object) + evas_object_hide(cursor->object); +} + +static void +_ecore_evas_object_cursor_device_set(Ecore_Evas *ee, Efl_Input_Device *pointer, + Evas_Object *obj, int layer, + int hot_x, int hot_y) +{ + Ecore_Evas_Cursor *cursor; + int x, y; + Evas_Object *old; ECORE_EVAS_CHECK(ee); + if (!pointer) + { + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + if (!pointer) + { + ee->prop.cursor_cache.object = obj; + ee->prop.cursor_cache.layer = layer; + ee->prop.cursor_cache.hot.x = hot_x; + ee->prop.cursor_cache.hot.y = hot_y; + return; + } + } + + if (obj && ee->engine.func->fn_object_cursor_set) + ee->engine.func->fn_object_cursor_set(ee, obj, layer, hot_x, hot_y); + else if (!obj && ee->engine.func->fn_object_cursor_unset) + ee->engine.func->fn_object_cursor_unset(ee); + + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + old = cursor->object; + if (!obj) + { + cursor->object = NULL; + cursor->layer = 0; + cursor->hot.x = 0; + cursor->hot.y = 0; + goto end; + } + + cursor->object = obj; + cursor->layer = layer; + cursor->hot.x = hot_x; + cursor->hot.y = hot_y; + + evas_pointer_output_xy_get(ee->evas, &x, &y); + + if (obj != old) + { + evas_object_layer_set(cursor->object, cursor->layer); + evas_object_pass_events_set(cursor->object, 1); + if (evas_pointer_inside_get(ee->evas)) + evas_object_show(cursor->object); + evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, + _ecore_evas_object_cursor_del, cursor); + } + + evas_object_move(cursor->object, x - cursor->hot.x, + y - cursor->hot.y); + +end: + if ((old) && (obj != old)) + { + evas_object_event_callback_del_full + (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, cursor); + evas_object_del(old); + } +} + +EAPI void +ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, + int layer, int hot_x, int hot_y) +{ + Evas_Object *obj = NULL; if (file) { int x, y; @@ -1552,41 +1735,82 @@ ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, in evas_object_image_fill_set(obj, 0, 0, x, y); } - IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y); - IFE; + _ecore_evas_object_cursor_device_set(ee, NULL, obj, layer, hot_x, hot_y); } EAPI void -ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) +ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, + int layer, int hot_x, int hot_y) { - ECORE_EVAS_CHECK(ee); - IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y); - IFE; + _ecore_evas_object_cursor_device_set(ee, NULL, obj, layer, hot_x, hot_y); +} + +EAPI void +ecore_evas_object_cursor_device_set(Ecore_Evas *ee, Efl_Input_Device *pointer, + Evas_Object *obj, int layer, + int hot_x, int hot_y) +{ + _ecore_evas_object_cursor_device_set(ee, pointer, obj, layer, hot_x, hot_y); +} + +EAPI Eina_Bool +ecore_evas_cursor_device_get(const Ecore_Evas *ee, Efl_Input_Device *pointer, + Evas_Object **obj, int *layer, + int *hot_x, int *hot_y) +{ + Ecore_Evas_Cursor *cursor; + + ECORE_EVAS_CHECK_GOTO(ee, err); + + if (!pointer) + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + if (pointer) + { + cursor = eina_hash_find(ee->prop.cursors, &pointer); + if (cursor) + { + if (obj) *obj = cursor->object; + if (layer) *layer = cursor->layer; + if (hot_x) *hot_x = cursor->hot.x; + if (hot_y) *hot_y = cursor->hot.y; + return EINA_TRUE; + } + } + + err: + if (obj) *obj = NULL; + if (layer) *layer = 0; + if (hot_x) *hot_x = 0; + if (hot_y) *hot_y = 0; + return EINA_FALSE; } EAPI void ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y) { - ECORE_EVAS_CHECK(ee); - if (obj) *obj = ee->prop.cursor.object; - if (layer) *layer = ee->prop.cursor.layer; - if (hot_x) *hot_x = ee->prop.cursor.hot.x; - if (hot_y) *hot_y = ee->prop.cursor.hot.y; + ecore_evas_cursor_device_get(ee, NULL, obj, layer, hot_x, hot_y); } EAPI Evas_Object * ecore_evas_cursor_unset(Ecore_Evas *ee) { + Ecore_Evas_Cursor *cursor; + Efl_Input_Device *pointer; Evas_Object *obj; ECORE_EVAS_CHECK(ee, NULL); - obj = ee->prop.cursor.object; - IFC(ee, fn_object_cursor_unset) (ee); + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, NULL); + obj = cursor->object; + if (ee->engine.func->fn_object_cursor_unset) + ee->engine.func->fn_object_cursor_unset(ee); evas_object_hide(obj); - ee->prop.cursor.object = NULL; - } - + cursor->object = NULL; + evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, + _ecore_evas_object_cursor_del, + cursor); return obj; } @@ -2386,7 +2610,8 @@ ecore_evas_pointer_device_xy_get(const Ecore_Evas *ee, const Efl_Input_Device *pointer, Evas_Coord *x, Evas_Coord *y) { - if (!pointer || pointer == evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE)) + if ((!pointer) || + (pointer == evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE))) ecore_evas_pointer_xy_get(ee, x, y); else { @@ -2853,8 +3078,9 @@ _ecore_evas_free(Ecore_Evas *ee) ecore_timer_del(ee->prop.wm_rot.manual_mode.timer); _ecore_evas_aux_hint_free(ee); ee->prop.wm_rot.manual_mode.timer = NULL; - if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object); - ee->prop.cursor.object = NULL; + efl_event_callback_array_del(ee->evas, _ecore_evas_device_cbs(), ee); + eina_hash_free(ee->prop.cursors); + ee->prop.cursors = NULL; if (ee->evas) evas_free(ee->evas); ee->evas = NULL; ECORE_MAGIC_SET(ee, ECORE_MAGIC_NONE); @@ -2904,49 +3130,98 @@ _ecore_evas_idle_timeout_update(Ecore_Evas *ee) } static void -_ecore_evas_mouse_move_process_internal(Ecore_Evas *ee, int x, int y, unsigned int timestamp, Eina_Bool feed) +_ecore_evas_mouse_move_process_internal(Ecore_Evas *ee, + Efl_Input_Device *pointer, + int x, int y, unsigned int timestamp, + Eina_Bool feed) { - int fx, fy, fw, fh; + Efl_Input_Pointer_Data *ev; + Efl_Input_Pointer *evt; + Eina_Bool send_event = EINA_TRUE; + Ecore_Evas_Cursor *cursor; + int fx, fy, fw, fh, evt_x, evt_y; ee->mouse.x = x; ee->mouse.y = y; evas_output_framespace_get(ee->evas, &fx, &fy, &fw, &fh); - if (ee->prop.cursor.object) + if (!pointer) + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + if (cursor->object) { - evas_object_show(ee->prop.cursor.object); + evas_object_show(cursor->object); if (ee->rotation == 0) - evas_object_move(ee->prop.cursor.object, - x - fx - ee->prop.cursor.hot.x, - y - fy - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + x - fx - cursor->hot.x, + y - fy - cursor->hot.y); else if (ee->rotation == 90) - evas_object_move(ee->prop.cursor.object, - ee->h + fw - y - fx - 1 - ee->prop.cursor.hot.x, - x - fy - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + ee->h + fw - y - fx - 1 - cursor->hot.x, + x - fy - cursor->hot.y); else if (ee->rotation == 180) - evas_object_move(ee->prop.cursor.object, - ee->w + fw - x - fx - 1 - ee->prop.cursor.hot.x, - ee->h + fh - y - fy - 1 - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + ee->w + fw - x - fx - 1 - cursor->hot.x, + ee->h + fh - y - fy - 1 - cursor->hot.y); else if (ee->rotation == 270) - evas_object_move(ee->prop.cursor.object, - y - fx - ee->prop.cursor.hot.x, - ee->w + fh - x - fy - 1 - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + y - fx - cursor->hot.x, + ee->w + fh - x - fy - 1 - cursor->hot.y); } + if (!feed) return; if (ee->rotation == 0) - evas_event_input_mouse_move(ee->evas, x, y, timestamp, NULL); + { + evt_x = x; + evt_y = y; + } else if (ee->rotation == 90) - evas_event_input_mouse_move(ee->evas, ee->h + fw - y - 1, x, timestamp, NULL); + { + evt_x = ee->h + fw - y - 1; + evt_y = x; + } else if (ee->rotation == 180) - evas_event_input_mouse_move(ee->evas, ee->w + fw - x - 1, ee->h + fh - y - 1, timestamp, NULL); + { + evt_x = ee->w + fw - x - 1; + evt_y = ee->h + fh - y - 1; + } else if (ee->rotation == 270) - evas_event_input_mouse_move(ee->evas, y, ee->w + fh - x - 1, timestamp, NULL); + { + evt_x = y; + evt_y = ee->w + fh - x - 1; + } + else + send_event = EINA_FALSE; + + if (!send_event) return; + + evt = efl_input_instance_get(EFL_INPUT_POINTER_CLASS, ee->evas, (void **) &ev); + if (!evt) return; + + ev->action = EFL_POINTER_ACTION_MOVE; + ev->device = efl_ref(pointer); + ev->timestamp = timestamp; + ev->cur.x = evt_x; + ev->cur.y = evt_y; + efl_event_callback_legacy_call(ee->evas, + _event_description_get(ev->action), evt); + efl_del(evt); } EAPI void _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp) { - _ecore_evas_mouse_move_process_internal(ee, x, y, timestamp, EINA_TRUE); + _ecore_evas_mouse_move_process_internal(ee, NULL, x, y, timestamp, + EINA_TRUE); +} + +EAPI void +_ecore_evas_mouse_device_move_process(Ecore_Evas *ee, Efl_Input_Device *pointer, + int x, int y, unsigned int timestamp) +{ + _ecore_evas_mouse_move_process_internal(ee, pointer, x, y, timestamp, + EINA_TRUE); } EAPI void @@ -3203,6 +3478,7 @@ _ecore_evas_aux_hint_free(Ecore_Evas *ee) EAPI Ecore_Evas * ecore_evas_fb_new(const char *disp_name, int rotation, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, int, int, int); Eina_Module *m = _ecore_evas_engine_load("fb"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3210,12 +3486,19 @@ ecore_evas_fb_new(const char *disp_name, int rotation, int w, int h) new = eina_module_symbol_get(m, "ecore_evas_fb_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, rotation, w, h); + ee = new(disp_name, rotation, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, Ecore_X_Window, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("x"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3223,7 +3506,13 @@ ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, int x, new = eina_module_symbol_get(m, "ecore_evas_software_x11_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h); + ee = new(disp_name, parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_X_Window @@ -3269,6 +3558,7 @@ ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window wi EAPI Ecore_Evas * ecore_evas_software_x11_pixmap_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, Ecore_X_Window, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("x"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3276,7 +3566,14 @@ ecore_evas_software_x11_pixmap_new(const char *disp_name, Ecore_X_Window parent, new = eina_module_symbol_get(m, "ecore_evas_software_x11_pixmap_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h); + ee = new(disp_name, parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; + } EAPI Ecore_X_Pixmap @@ -3295,6 +3592,7 @@ ecore_evas_software_x11_pixmap_get(const Ecore_Evas *ee) EAPI Ecore_Evas * ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, Ecore_X_Window, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("x"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3302,12 +3600,20 @@ ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y new = eina_module_symbol_get(m, "ecore_evas_gl_x11_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h); + ee = new(disp_name, parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; + } EAPI Ecore_Evas * ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, const int *opt) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, Ecore_X_Window, int, int, int, int, const int*); Eina_Module *m = _ecore_evas_engine_load("x"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3315,12 +3621,19 @@ ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, int new = eina_module_symbol_get(m, "ecore_evas_gl_x11_options_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h, opt); + ee = new(disp_name, parent, x, y, w, h, opt); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_gl_x11_pixmap_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, Ecore_X_Window, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("x"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3328,7 +3641,14 @@ ecore_evas_gl_x11_pixmap_new(const char *disp_name, Ecore_X_Window parent, int x new = eina_module_symbol_get(m, "ecore_evas_gl_x11_pixmap_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h); + ee = new(disp_name, parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; + } EAPI Ecore_X_Pixmap @@ -3524,6 +3844,7 @@ ecore_evas_vnc_stop(Ecore_Evas *ee) EAPI Ecore_Evas * ecore_evas_extn_socket_new(int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(int, int); Eina_Module *m = _ecore_evas_engine_load("extn"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3531,7 +3852,14 @@ ecore_evas_extn_socket_new(int w, int h) new = eina_module_symbol_get(m, "ecore_evas_extn_socket_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(w, h); + ee = new(w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; + } EAPI Eina_Bool @@ -3634,6 +3962,7 @@ EAPI Ecore_Evas * ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, int, int, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("sdl"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3641,13 +3970,20 @@ ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, new = eina_module_symbol_get(m, "ecore_evas_sdl_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(name, w, h, fullscreen, hwsurface, noframe, alpha); + ee = new(name, w, h, fullscreen, hwsurface, noframe, alpha); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_sdl16_new(const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, int, int, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("sdl"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3655,12 +3991,19 @@ ecore_evas_sdl16_new(const char* name, int w, int h, int fullscreen, new = eina_module_symbol_get(m, "ecore_evas_sdl16_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(name, w, h, fullscreen, hwsurface, noframe, alpha); + ee = new(name, w, h, fullscreen, hwsurface, noframe, alpha); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_gl_sdl_new(const char* name, int w, int h, int fullscreen, int noframe) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("sdl"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3668,13 +4011,20 @@ ecore_evas_gl_sdl_new(const char* name, int w, int h, int fullscreen, int nofram new = eina_module_symbol_get(m, "ecore_evas_gl_sdl_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(name, w, h, fullscreen, noframe); + ee = new(name, w, h, fullscreen, noframe); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_wayland_shm_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, unsigned int, int, int, int, int, Eina_Bool); Eina_Module *m = _ecore_evas_engine_load("wayland"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3682,13 +4032,20 @@ ecore_evas_wayland_shm_new(const char *disp_name, unsigned int parent, new = eina_module_symbol_get(m, "ecore_evas_wayland_shm_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h, frame); + ee = new(disp_name, parent, x, y, w, h, frame); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_wayland_egl_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, unsigned int, int, int, int, int, Eina_Bool); Eina_Module *m = _ecore_evas_engine_load("wayland"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3696,7 +4053,13 @@ ecore_evas_wayland_egl_new(const char *disp_name, unsigned int parent, new = eina_module_symbol_get(m, "ecore_evas_wayland_egl_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h, frame); + ee = new(disp_name, parent, x, y, w, h, frame); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI void @@ -3772,6 +4135,7 @@ EAPI Ecore_Evas * ecore_evas_drm_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, unsigned int, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("drm"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3779,13 +4143,20 @@ ecore_evas_drm_new(const char *disp_name, unsigned int parent, new = eina_module_symbol_get(m, "ecore_evas_drm_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h); + ee = new(disp_name, parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_gl_drm_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, unsigned int, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("drm"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3793,7 +4164,14 @@ ecore_evas_gl_drm_new(const char *disp_name, unsigned int parent, new = eina_module_symbol_get(m, "ecore_evas_gl_drm_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(disp_name, parent, x, y, w, h); + ee = new(disp_name, parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; + } EAPI Ecore_Evas * @@ -3803,6 +4181,7 @@ ecore_evas_software_gdi_new(Ecore_Win32_Window *parent, int width, int height) { + Ecore_Evas *ee; Ecore_Evas *(*new)(Ecore_Win32_Window *, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("win32"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3810,7 +4189,14 @@ ecore_evas_software_gdi_new(Ecore_Win32_Window *parent, new = eina_module_symbol_get(m, "ecore_evas_software_gdi_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(parent, x, y, width, height); + ee = new(parent, x, y, width, height); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; + } EAPI Ecore_Evas * @@ -3820,6 +4206,7 @@ ecore_evas_software_ddraw_new(Ecore_Win32_Window *parent, int width, int height) { + Ecore_Evas *ee; Ecore_Evas *(*new)(Ecore_Win32_Window *, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("win32"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3827,7 +4214,13 @@ ecore_evas_software_ddraw_new(Ecore_Win32_Window *parent, new = eina_module_symbol_get(m, "ecore_evas_software_ddraw_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(parent, x, y, width, height); + ee = new(parent, x, y, width, height); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Win32_Window * @@ -3843,6 +4236,7 @@ ecore_evas_win32_window_get(const Ecore_Evas *ee) EAPI Ecore_Evas * ecore_evas_cocoa_new(Ecore_Cocoa_Window *parent, int x, int y, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(Ecore_Cocoa_Window *, int, int, int, int); Eina_Module *m = _ecore_evas_engine_load("cocoa"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3850,12 +4244,19 @@ ecore_evas_cocoa_new(Ecore_Cocoa_Window *parent, int x, int y, int w, int h) new = eina_module_symbol_get(m, "ecore_evas_cocoa_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(parent, x, y, w, h); + ee = new(parent, x, y, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } EAPI Ecore_Evas * ecore_evas_psl1ght_new(const char* name, int w, int h) { + Ecore_Evas *ee; Ecore_Evas *(*new)(const char*, int, int); Eina_Module *m = _ecore_evas_engine_load("psl1ght"); EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); @@ -3863,7 +4264,13 @@ ecore_evas_psl1ght_new(const char* name, int w, int h) new = eina_module_symbol_get(m, "ecore_evas_psl1ght_new_internal"); EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); - return new(name, w, h); + ee = new(name, w, h); + if (!_ecore_evas_cursors_init(ee)) + { + ecore_evas_free(ee); + return NULL; + } + return ee; } @@ -3995,7 +4402,8 @@ _direct_mouse_move_cb(Ecore_Evas *ee, const Ecore_Event_Mouse_Move *info) Evas *e = ee->evas; Eina_Bool processed; - _ecore_evas_mouse_move_process_internal(ee, info->x, info->y, info->timestamp, EINA_FALSE); + _ecore_evas_mouse_move_process_internal(ee, info->dev, info->x, info->y, + info->timestamp, EINA_FALSE); /* Unused information: * same_screen diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c b/src/lib/ecore_evas/ecore_evas_buffer.c index 979f92580d..74bcdd748a 100644 --- a/src/lib/ecore_evas/ecore_evas_buffer.c +++ b/src/lib/ecore_evas/ecore_evas_buffer.c @@ -721,6 +721,11 @@ ecore_evas_buffer_allocfunc_new(int w, int h, evas_key_lock_add(ee->evas, "Num_Lock"); evas_key_lock_add(ee->evas, "Scroll_Lock"); + if (!_ecore_evas_cursors_init(ee)) + { + ERR("Could not init the Ecore Evas cursors"); + ecore_evas_free(ee); + } evas_event_feed_mouse_in(ee->evas, 0, NULL); _ecore_evas_register(ee); diff --git a/src/lib/ecore_evas/ecore_evas_ews.c b/src/lib/ecore_evas/ecore_evas_ews.c index 719d5ea6df..199c1d8507 100644 --- a/src/lib/ecore_evas/ecore_evas_ews.c +++ b/src/lib/ecore_evas/ecore_evas_ews.c @@ -400,50 +400,10 @@ _ecore_evas_ews_size_step_set(Ecore_Evas *ee, int w, int h) } static void -_ecore_evas_ews_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +_ecore_evas_ews_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj EINA_UNUSED, + int layer EINA_UNUSED, int hot_x EINA_UNUSED, + int hot_y EINA_UNUSED) { - Ecore_Evas *ee = data; - ee->prop.cursor.object = NULL; -} - -static void -_ecore_evas_ews_object_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_ews_object_cursor_del, ee); -} - -static void -_ecore_evas_ews_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y; - - if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object); - - if (!obj) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - return; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - evas_pointer_output_xy_get(ee->evas, &x, &y); - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - - evas_object_event_callback_add - (obj, EVAS_CALLBACK_DEL, _ecore_evas_ews_object_cursor_del, ee); - _ecore_evas_ews_event(ee, ECORE_EVAS_EWS_EVENT_CONFIG_CHANGE); } @@ -670,7 +630,7 @@ static const Ecore_Evas_Engine_Func _ecore_ews_engine_func = _ecore_evas_ews_size_base_set, _ecore_evas_ews_size_step_set, _ecore_evas_ews_object_cursor_set, - _ecore_evas_ews_object_cursor_unset, + NULL, _ecore_evas_ews_layer_set, _ecore_evas_ews_focus_set, _ecore_evas_ews_iconified_set, @@ -883,7 +843,7 @@ _ecore_evas_ews_cb_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E if (ee->func.fn_mouse_out) ee->func.fn_mouse_out(ee); _ecore_evas_ews_modifiers_apply(ee, ev->modifiers); evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL); - if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); + _ecore_evas_default_cursor_hide(ee); _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp); } @@ -1261,6 +1221,12 @@ ecore_evas_ews_new(int x, int y, int w, int h) evas_key_lock_add(ee->evas, "Num_Lock"); evas_key_lock_add(ee->evas, "Scroll_Lock"); + if (!_ecore_evas_cursors_init(ee)) + { + ERR("Could not init the Ecore Evas cursors"); + ecore_evas_free(ee); + } + _ews_ee->sub_ecore_evas = eina_list_append(_ews_ee->sub_ecore_evas, ee); _ews_children = eina_list_append(_ews_children, ee); diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h index 919d2dac40..74af4dccf3 100644 --- a/src/lib/ecore_evas/ecore_evas_private.h +++ b/src/lib/ecore_evas/ecore_evas_private.h @@ -76,6 +76,7 @@ typedef struct _Ecore_Evas_Engine Ecore_Evas_Engine; typedef struct _Ecore_Evas_Engine_Func Ecore_Evas_Engine_Func; typedef struct _Ecore_Evas_Interface Ecore_Evas_Interface; typedef struct _Ecore_Evas_Aux_Hint Ecore_Evas_Aux_Hint; +typedef struct _Ecore_Evas_Cursor Ecore_Evas_Cursor; /* Engines interfaces */ struct _Ecore_Evas_Engine_Func @@ -187,6 +188,14 @@ struct _Ecore_Evas_Engine #endif }; +struct _Ecore_Evas_Cursor { + Evas_Object *object; + int layer; + struct { + int x, y; + } hot; +}; + struct _Ecore_Evas { EINA_INLIST; @@ -227,6 +236,7 @@ struct _Ecore_Evas } expecting_resize; struct { + Eina_Hash *cursors; char *title; char *name; char *clas; @@ -238,13 +248,7 @@ struct _Ecore_Evas struct { int w, h; } min, max, base, step; - struct { - Evas_Object *object; - int layer; - struct { - int x, y; - } hot; - } cursor; + Ecore_Evas_Cursor cursor_cache; struct { Eina_Bool supported; // indicate that the underlying window system supports window manager rotation protocol Eina_Bool app_set; // indicate that the ee supports window manager rotation protocol @@ -390,6 +394,8 @@ EAPI void _ecore_evas_register_animators(Ecore_Evas *ee); EAPI void _ecore_evas_free(Ecore_Evas *ee); EAPI void _ecore_evas_idle_timeout_update(Ecore_Evas *ee); EAPI void _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp); +EAPI void _ecore_evas_mouse_device_move_process(Ecore_Evas *ee, Efl_Input_Device *pointer, + int x, int y, unsigned int timestamp); EAPI void _ecore_evas_mouse_multi_move_process(Ecore_Evas *ee, int device, int x, int y, double radius, @@ -457,13 +463,18 @@ EAPI void ecore_evas_animator_tick(Ecore_Evas *ee, Eina_Rectangle *viewport, dou Eina_Module *_ecore_evas_vnc_server_module_load(void); - EAPI void _ecore_evas_focus_device_set(Ecore_Evas *ee, Efl_Input_Device *seat, Eina_Bool on); EAPI Eina_Bool _ecore_evas_mouse_in_check(Ecore_Evas *ee, Efl_Input_Device *mouse); EAPI void _ecore_evas_mouse_inout_set(Ecore_Evas *ee, Efl_Input_Device *mouse, Eina_Bool in, Eina_Bool force_out); + +EAPI Evas_Object *_ecore_evas_default_cursor_image_get(Ecore_Evas *ee); +EAPI void _ecore_evas_default_cursor_hide(Ecore_Evas *ee); + +Eina_Bool _ecore_evas_cursors_init(Ecore_Evas *ee); + #undef EAPI #define EAPI diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c index 488ed67a0d..6dabee4e42 100644 --- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c +++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c @@ -464,69 +464,16 @@ _ecore_evas_title_set(Ecore_Evas *ee, const char *title) } static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, + int layer EINA_UNUSED, int hot_x EINA_UNUSED, + int hot_y EINA_UNUSED) { - Ecore_Evas *ee; - - DBG(""); - - ee = data; - if (ee) - ee->prop.cursor.object = NULL; -} - -static void -_ecore_evas_object_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); -} - -static void -_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y; - Evas_Object *old; Ecore_Cocoa_Window *win = (Ecore_Cocoa_Window *)(ee->prop.window); - DBG(""); - old = ee->prop.cursor.object; - if (obj == NULL) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - ecore_cocoa_window_cursor_show(win, EINA_TRUE); - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - evas_pointer_output_xy_get(ee->evas, &x, &y); - if (obj != old) - { - ecore_cocoa_window_cursor_show(win, EINA_FALSE); - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full(old, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } + if (!obj) + ecore_cocoa_window_cursor_show(win, EINA_TRUE); + else if (obj != _ecore_evas_default_cursor_image_get(ee)) + ecore_cocoa_window_cursor_show(win, EINA_FALSE); } static void @@ -627,7 +574,7 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func = NULL, _ecore_evas_size_step_set, _ecore_evas_object_cursor_set, - _ecore_evas_object_cursor_unset, + NULL, NULL, NULL, _ecore_evas_iconified_set, diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c index b1ab702a01..d69c43009c 100644 --- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c +++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c @@ -433,68 +433,6 @@ _drm_size_step_set(Ecore_Evas *ee, int w, int h) ee->prop.step.h = h; } -static void -_drm_object_cursor_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) -{ - Ecore_Evas *ee; - - ee = data; - if (ee) ee->prop.cursor.object = NULL; -} - -static void -_drm_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - Evas_Object *old; - int x, y; - - old = ee->prop.cursor.object; - if (!obj) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - ecore_evas_pointer_xy_get(ee, &x, &y); - - if (obj != old) - { - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _drm_object_cursor_del, ee); - } - - evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _drm_object_cursor_del, ee); - evas_object_del(old); - } -} - -static void -_drm_object_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, - EVAS_CALLBACK_DEL, - _drm_object_cursor_del, ee); -} - static void _drm_layer_set(Ecore_Evas *ee, int layer) { @@ -747,8 +685,8 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func = _drm_size_max_set, _drm_size_base_set, _drm_size_step_set, - _drm_object_cursor_set, - _drm_object_cursor_unset, + NULL, + NULL, _drm_layer_set, NULL, //void (*fn_focus_set) (Ecore_Evas *ee, Eina_Bool on); _drm_iconified_set, diff --git a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c index 2e828624a8..d1ab63ab0b 100644 --- a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c +++ b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c @@ -56,30 +56,37 @@ struct _Ecore_Evas_Engine_FB_Data { static void _ecore_evas_mouse_move_process_fb(Ecore_Evas *ee, int x, int y) { + Efl_Input_Device *pointer; + Ecore_Evas_Cursor *cursor; int fbw, fbh; ee->mouse.x = x; ee->mouse.y = y; ecore_fb_size_get(&fbw, &fbh); - if (ee->prop.cursor.object) + + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + + if (cursor->object) { - evas_object_show(ee->prop.cursor.object); + evas_object_show(cursor->object); if (ee->rotation == 0) - evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + x - cursor->hot.x, + y - cursor->hot.y); else if (ee->rotation == 90) - evas_object_move(ee->prop.cursor.object, - (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.x, - x - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + (fbh - ee->h) + ee->h - y - 1 - cursor->hot.x, + x - cursor->hot.y); else if (ee->rotation == 180) - evas_object_move(ee->prop.cursor.object, - (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.x, - (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + (fbw - ee->w) + ee->w - x - 1 - cursor->hot.x, + (fbh - ee->h) + ee->h - y - 1 - cursor->hot.y); else if (ee->rotation == 270) - evas_object_move(ee->prop.cursor.object, - y - ee->prop.cursor.hot.x, - (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.y); + evas_object_move(cursor->object, + y - cursor->hot.x, + (fbw - ee->w) + ee->w - x - 1 - cursor->hot.y); } } @@ -430,67 +437,6 @@ _ecore_evas_hide(Ecore_Evas *ee) _ecore_evas_focus_device_set(ee, NULL, EINA_FALSE); } -static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Ecore_Evas *ee; - - ee = data; - if (ee) - ee->prop.cursor.object = NULL; -} - -static void -_ecore_evas_object_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); -} - -static void -_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y; - Evas_Object *old; - - old = ee->prop.cursor.object; - if (obj == NULL) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - evas_pointer_output_xy_get(ee->evas, &x, &y); - - if (obj != old) - { - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - - evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } -} - static void _ecore_evas_fullscreen_set(Ecore_Evas *ee, Eina_Bool on) { @@ -592,8 +538,8 @@ static Ecore_Evas_Engine_Func _ecore_fb_engine_func = NULL, NULL, NULL, - _ecore_evas_object_cursor_set, - _ecore_evas_object_cursor_unset, + NULL, + NULL, NULL, NULL, NULL, diff --git a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c index a65a61a776..935a7571ef 100644 --- a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c +++ b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c @@ -319,66 +319,6 @@ _ecore_evas_screen_geometry_get(const Ecore_Evas *ee EINA_UNUSED, int *x, int *y ecore_psl1ght_screen_resolution_get (w, h); } -static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Ecore_Evas *ee; - - ee = data; - if (ee) - ee->prop.cursor.object = NULL; -} - -static void -_ecore_evas_object_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); -} - -static void -_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y; - Evas_Object *old; - - old = ee->prop.cursor.object; - if (obj == NULL) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - if (obj != old) - { - evas_pointer_output_xy_get(ee->evas, &x, &y); - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - - evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } -} - static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func = { _ecore_evas_psl1ght_free, @@ -413,8 +353,8 @@ static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func = NULL, NULL, NULL, - _ecore_evas_object_cursor_set, - _ecore_evas_object_cursor_unset, + NULL, + NULL, NULL, NULL, NULL, diff --git a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c index 782d06513e..e12307a425 100644 --- a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c +++ b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c @@ -411,66 +411,6 @@ _ecore_evas_show(Ecore_Evas *ee) evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); } -static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Ecore_Evas *ee; - - ee = data; - if (ee) ee->prop.cursor.object = NULL; -} - -static void -_ecore_evas_object_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); -} - -static void -_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y; - Evas_Object *old; - - old = ee->prop.cursor.object; - if (obj == NULL) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - evas_pointer_output_xy_get(ee->evas, &x, &y); - - if (obj != old) - { - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - - evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } -} - static Ecore_Evas_Engine_Func _ecore_sdl_engine_func = { _ecore_evas_sdl_free, @@ -505,8 +445,8 @@ static Ecore_Evas_Engine_Func _ecore_sdl_engine_func = NULL, NULL, NULL, - _ecore_evas_object_cursor_set, - _ecore_evas_object_cursor_unset, + NULL, + NULL, NULL, NULL, NULL, 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 6bd452854b..5eeae7c809 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 @@ -43,7 +43,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func = _ecore_evas_wl_common_size_base_set, _ecore_evas_wl_common_size_step_set, _ecore_evas_wl_common_object_cursor_set, - _ecore_evas_wl_common_object_cursor_unset, + NULL, _ecore_evas_wl_common_layer_set, NULL, // focus set _ecore_evas_wl_common_iconified_set, @@ -171,7 +171,7 @@ _ecore_evas_wl_common_cb_mouse_in(void *data EINA_UNUSED, int type EINA_UNUSED, _ecore_evas_mouse_inout_set(ee, ev->dev, EINA_TRUE, EINA_FALSE); ecore_event_evas_seat_modifier_lock_update(ee->evas, ev->modifiers, ev->dev); evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL); - _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp); + _ecore_evas_mouse_device_move_process(ee, ev->dev, ev->x, ev->y, ev->timestamp); return ECORE_CALLBACK_PASS_ON; } @@ -191,10 +191,9 @@ _ecore_evas_wl_common_cb_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, ecore_event_evas_seat_modifier_lock_update(ee->evas, ev->modifiers, ev->dev); - _ecore_evas_mouse_move_process(ee, ev->x, ev->y, ev->timestamp); + _ecore_evas_mouse_device_move_process(ee, ev->dev, ev->x, ev->y, ev->timestamp); evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL); _ecore_evas_mouse_inout_set(ee, ev->dev, EINA_FALSE, EINA_FALSE); - if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); return ECORE_CALLBACK_PASS_ON; } @@ -1265,72 +1264,17 @@ _ecore_evas_wl_common_aspect_set(Ecore_Evas *ee, double aspect) ee->prop.aspect = aspect; } -static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Ecore_Evas *ee; - - ee = data; - if (ee) ee->prop.cursor.object = NULL; -} - void -_ecore_evas_wl_common_object_cursor_unset(Ecore_Evas *ee) +_ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, + int layer EINA_UNUSED, + int hot_x EINA_UNUSED, + int hot_y EINA_UNUSED) { - evas_object_event_callback_del_full(ee->prop.cursor.object, - EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); -} - -void -_ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y, fx, fy; Ecore_Evas_Engine_Wl_Data *wdata; - Evas_Object *old; - if (!ee) return; wdata = ee->engine.data; - old = ee->prop.cursor.object; - if (obj == NULL) - { - ecore_wl2_window_pointer_set(wdata->win, NULL, 0, 0); - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - evas_pointer_output_xy_get(ee->evas, &x, &y); - - if (obj != old) - { - ecore_wl2_window_pointer_set(wdata->win, NULL, 0, 0); - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - - evas_output_framespace_get(ee->evas, &fx, &fy, NULL, NULL); - evas_object_move(ee->prop.cursor.object, x - fx - ee->prop.cursor.hot.x, - y - fy - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } + if (obj != _ecore_evas_default_cursor_image_get(ee)) + ecore_wl2_window_pointer_set(wdata->win, NULL, 0, 0); } void diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c index 4469c66fca..e9dbd37693 100644 --- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c +++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c @@ -220,7 +220,7 @@ _ecore_evas_win32_event_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, if (evas_event_down_count_get(ee->evas) > 0) return ECORE_CALLBACK_PASS_ON; evas_event_feed_mouse_out(ee->evas, e->timestamp, NULL); _ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_FALSE); - if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); + _ecore_evas_default_cursor_hide(ee); } return ECORE_CALLBACK_PASS_ON; @@ -834,67 +834,6 @@ _ecore_evas_win32_size_step_set(Ecore_Evas *ee, int width, int height) width, height); } -static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) -{ - Ecore_Evas *ee; - - ee = data; - if (ee) ee->prop.cursor.object = NULL; -} - -static void -_ecore_evas_win32_cursor_unset(Ecore_Evas *ee) -{ - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); -} - -static void -_ecore_evas_win32_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x, y; - Evas_Object *old; - - old = ee->prop.cursor.object; - if (obj == NULL) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - evas_pointer_output_xy_get(ee->evas, &x, &y); - - if (obj != old) - { -// ecore_win32_window_cursor_show(ee->prop.window, 0); - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - - evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } -} - static void _ecore_evas_win32_focus_set(Ecore_Evas *ee, Eina_Bool on EINA_UNUSED) { @@ -1157,8 +1096,8 @@ static Ecore_Evas_Engine_Func _ecore_win32_engine_func = _ecore_evas_win32_size_max_set, _ecore_evas_win32_size_base_set, _ecore_evas_win32_size_step_set, - _ecore_evas_win32_cursor_set, - _ecore_evas_win32_cursor_unset, + NULL, + NULL, NULL, /* _ecore_evas_x_layer_set */ _ecore_evas_win32_focus_set, _ecore_evas_win32_iconified_set, diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c b/src/modules/ecore_evas/engines/x/ecore_evas_x.c index 3c52034cb4..2b4e00bfd5 100644 --- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c +++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c @@ -1315,7 +1315,7 @@ _fake_out(void *data) _feed_cancel_out(e, (e->mode == ECORE_X_EVENT_MODE_GRAB)); _ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_TRUE); - if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); + _ecore_evas_default_cursor_hide(ee); return EINA_FALSE; } @@ -1480,7 +1480,7 @@ _ecore_evas_x_event_mouse_out(void *data EINA_UNUSED, int type EINA_UNUSED, void _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time); _ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_FALSE); _feed_cancel_out(e, (e->mode == ECORE_X_EVENT_MODE_GRAB)); - if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); + _ecore_evas_default_cursor_hide(ee); } return ECORE_CALLBACK_PASS_ON; } @@ -1800,7 +1800,7 @@ _ecore_evas_x_event_window_hide(void *data EINA_UNUSED, int type EINA_UNUSED, vo }; _feed_cancel_out(&out, EINA_TRUE); _ecore_evas_mouse_inout_set(ee, NULL, EINA_FALSE, EINA_FALSE); - if (ee->prop.cursor.object) evas_object_hide(ee->prop.cursor.object); + _ecore_evas_default_cursor_hide(ee); } if (ee->prop.override) { @@ -3153,65 +3153,18 @@ _ecore_evas_x_size_step_set(Ecore_Evas *ee, int w, int h) } static void -_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +_ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, + int layer EINA_UNUSED, int hot_x EINA_UNUSED, + int hot_y EINA_UNUSED) { - Ecore_Evas *ee; - - ee = data; - if (ee) ee->prop.cursor.object = NULL; + if (obj != _ecore_evas_default_cursor_image_get(ee)) + ecore_x_window_cursor_show(ee->prop.window, 0); } static void -_ecore_evas_x_object_cursor_unset(Ecore_Evas *ee) +_ecore_evas_x_object_cursor_unset(Ecore_Evas *ee EINA_UNUSED) { - evas_object_event_callback_del_full(ee->prop.cursor.object, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); -} - -static void -_ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) -{ - int x = 0, y = 0; - Evas_Object *old; - - old = ee->prop.cursor.object; - if (!obj) - { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - ecore_x_window_cursor_show(ee->prop.window, 1); - goto end; - } - - ee->prop.cursor.object = obj; - ee->prop.cursor.layer = layer; - ee->prop.cursor.hot.x = hot_x; - ee->prop.cursor.hot.y = hot_y; - - evas_pointer_output_xy_get(ee->evas, &x, &y); - - if (obj != old) - { - ecore_x_window_cursor_show(ee->prop.window, 0); - evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); - evas_object_pass_events_set(ee->prop.cursor.object, 1); - if (evas_pointer_inside_get(ee->evas)) - evas_object_show(ee->prop.cursor.object); - evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, - _ecore_evas_object_cursor_del, ee); - } - - evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - -end: - if ((old) && (obj != old)) - { - evas_object_event_callback_del_full - (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); - evas_object_del(old); - } + ecore_x_window_cursor_show(ee->prop.window, 1); } /* From 044219226cf171aec201a9c4ee05b6e14e565e00 Mon Sep 17 00:00:00 2001 From: Guilherme Iscaro Date: Wed, 30 Nov 2016 13:29:19 -0200 Subject: [PATCH 5/6] Ecore Evas: Add support for multiple mouse positions. Since it's possible to have more than one mouse, Ecore Evas must take into account the position of all mouses and update them correctly. --- src/lib/ecore_evas/ecore_evas.c | 4 ++-- src/lib/ecore_evas/ecore_evas_private.h | 6 ++---- .../ecore_evas/engines/fb/ecore_evas_fb.c | 13 ++++++++---- .../engines/psl1ght/ecore_evas_psl1ght.c | 8 +++++++- .../wayland/ecore_evas_wayland_common.c | 20 +++++++++++++++---- .../engines/win32/ecore_evas_win32.c | 19 +++++++++++++++--- .../ecore_evas/engines/x/ecore_evas_x.c | 19 +++++++++++++++--- 7 files changed, 68 insertions(+), 21 deletions(-) diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index da485a8211..15217ce079 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -3140,8 +3140,6 @@ _ecore_evas_mouse_move_process_internal(Ecore_Evas *ee, Eina_Bool send_event = EINA_TRUE; Ecore_Evas_Cursor *cursor; int fx, fy, fw, fh, evt_x, evt_y; - ee->mouse.x = x; - ee->mouse.y = y; evas_output_framespace_get(ee->evas, &fx, &fy, &fw, &fh); @@ -3149,6 +3147,8 @@ _ecore_evas_mouse_move_process_internal(Ecore_Evas *ee, pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); cursor = eina_hash_find(ee->prop.cursors, &pointer); EINA_SAFETY_ON_NULL_RETURN(cursor); + cursor->pos_x = x; + cursor->pos_y = y; if (cursor->object) { evas_object_show(cursor->object); diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h index 74af4dccf3..aa1d7953a7 100644 --- a/src/lib/ecore_evas/ecore_evas_private.h +++ b/src/lib/ecore_evas/ecore_evas_private.h @@ -194,6 +194,8 @@ struct _Ecore_Evas_Cursor { struct { int x, y; } hot; + int pos_x; + int pos_y; }; struct _Ecore_Evas @@ -227,10 +229,6 @@ struct _Ecore_Evas int changed : 1; } shadow; - struct { - int x, y; - } mouse; - struct { int w, h; } expecting_resize; diff --git a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c index d1ab63ab0b..3ab0cdf006 100644 --- a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c +++ b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c @@ -60,14 +60,13 @@ _ecore_evas_mouse_move_process_fb(Ecore_Evas *ee, int x, int y) Ecore_Evas_Cursor *cursor; int fbw, fbh; - ee->mouse.x = x; - ee->mouse.y = y; ecore_fb_size_get(&fbw, &fbh); pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); cursor = eina_hash_find(ee->prop.cursors, &pointer); EINA_SAFETY_ON_NULL_RETURN(cursor); - + cursor->pos_x = x; + cursor->pos_y = y; if (cursor->object) { evas_object_show(cursor->object); @@ -361,9 +360,15 @@ _ecore_evas_move_resize(Ecore_Evas *ee, int x EINA_UNUSED, int y EINA_UNUSED, in static void _ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize EINA_UNUSED) { + Evas_Device *pointer; + Ecore_Evas_Cursor *cursor; Evas_Engine_Info_FB *einfo; int rot_dif; + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + if (ee->rotation == rotation) return; einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas); if (!einfo) return; @@ -416,7 +421,7 @@ _ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize EINA_UNUSED) else evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); - _ecore_evas_mouse_move_process_fb(ee, ee->mouse.x, ee->mouse.y); + _ecore_evas_mouse_move_process_fb(ee, cursor->pos_x, cursor->pos_y); if (ee->func.fn_resize) ee->func.fn_resize(ee); } diff --git a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c index 935a7571ef..2ea7429d60 100644 --- a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c +++ b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c @@ -255,6 +255,8 @@ _ecore_evas_psl1ght_callback_delete_request_set(Ecore_Evas *ee, Ecore_Evas_Event static void _ecore_evas_screen_resized(Ecore_Evas *ee) { + Evas_Device *pointer; + Ecore_Evas_Cursor *cursor; int w, h; /* Do not resize if the window is not fullscreen */ @@ -262,6 +264,10 @@ _ecore_evas_screen_resized(Ecore_Evas *ee) ecore_psl1ght_screen_resolution_get (&w, &h); + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + if (w != ee->w || h != ee->h) { ee->req.w = ee->w = w; @@ -271,7 +277,7 @@ _ecore_evas_screen_resized(Ecore_Evas *ee) ecore_psl1ght_resolution_set (w, h); evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, _ecore_evas_time_get()); if (ee->func.fn_resize) ee->func.fn_resize(ee); } 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 5eeae7c809..fea3638e66 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 @@ -301,6 +301,20 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_ return ECORE_CALLBACK_PASS_ON; } +static void +_mouse_move_dispatch(Ecore_Evas *ee) +{ + Ecore_Evas_Cursor *cursor; + Eina_Iterator *itr = eina_hash_iterator_data_new(ee->prop.cursors); + + EINA_SAFETY_ON_NULL_RETURN(itr); + + EINA_ITERATOR_FOREACH(itr, cursor) + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, + ecore_loop_time_get()); + eina_iterator_free(itr); +} + static void _rotation_do(Ecore_Evas *ee, int rotation, int resize) { @@ -422,8 +436,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize) * Yes, it's required to update the mouse position, relatively to * widgets. After a rotation change, e.g., the mouse might not be over * a button anymore. */ - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, - ecore_loop_time_get()); + _mouse_move_dispatch(ee); } else { @@ -437,8 +450,7 @@ _rotation_do(Ecore_Evas *ee, int rotation, int resize) * * NB: Is This Really Needed ? Yes, it's required to update the mouse * position, relatively to widgets. */ - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, - ecore_loop_time_get()); + _mouse_move_dispatch(ee); /* call the ecore_evas' resize function */ if (ee->func.fn_resize) ee->func.fn_resize(ee); diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c index e9dbd37693..30c322cccb 100644 --- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c +++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c @@ -371,9 +371,12 @@ _ecore_evas_win32_event_window_hide(void *data EINA_UNUSED, int type EINA_UNUSED static Eina_Bool _ecore_evas_win32_event_window_configure(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { + Evas_Device *pointer; + Ecore_Evas_Cursor *cursor; Ecore_Evas *ee; Ecore_Win32_Event_Window_Configure *e; + INF("window configure"); e = event; @@ -381,6 +384,10 @@ _ecore_evas_win32_event_window_configure(void *data EINA_UNUSED, int type EINA_U if (!ee) return 1; /* pass on event */ if ((Ecore_Window)e->window != ee->prop.window) return 1; + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, 1); + if (ee->prop.override) { if ((ee->x != e->x) || (ee->y != e->y)) @@ -426,7 +433,7 @@ _ecore_evas_win32_event_window_configure(void *data EINA_UNUSED, int type EINA_U { if ((ee->expecting_resize.w == ee->w) && (ee->expecting_resize.h == ee->h)) - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, ecore_win32_current_time_get()); ee->expecting_resize.w = 0; ee->expecting_resize.h = 0; @@ -588,11 +595,17 @@ _ecore_evas_win32_move_resize(Ecore_Evas *ee, int x, int y, int width, int heigh static void _ecore_evas_win32_rotation_set_internal(Ecore_Evas *ee, int rotation) { + Evas_Device *pointer; + Ecore_Evas_Cursor *cursor; int rot_dif; rot_dif = ee->rotation - rotation; if (rot_dif < 0) rot_dif = -rot_dif; + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + if (rot_dif != 180) { int minw, minh, maxw, maxh, basew, baseh, stepw, steph; @@ -633,13 +646,13 @@ _ecore_evas_win32_rotation_set_internal(Ecore_Evas *ee, int rotation) ecore_evas_size_max_set(ee, maxh, maxw); ecore_evas_size_base_set(ee, baseh, basew); ecore_evas_size_step_set(ee, steph, stepw); - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, ecore_win32_current_time_get()); } else { ee->rotation = rotation; - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, ecore_win32_current_time_get()); if (ee->func.fn_resize) ee->func.fn_resize(ee); } diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c b/src/modules/ecore_evas/engines/x/ecore_evas_x.c index 2b4e00bfd5..7949326ee3 100644 --- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c +++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c @@ -1616,6 +1616,9 @@ _ecore_evas_x_shadow_update(Ecore_Evas *ee) static Eina_Bool _ecore_evas_x_event_window_configure(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { + + Evas_Device *pointer; + Ecore_Evas_Cursor *cursor; Ecore_Evas *ee; Ecore_X_Event_Window_Configure *e; Ecore_Evas_Engine_Data_X11 *edata; @@ -1628,6 +1631,10 @@ _ecore_evas_x_event_window_configure(void *data EINA_UNUSED, int type EINA_UNUSE if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; if (edata->direct_resize) return ECORE_CALLBACK_PASS_ON; + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN_VAL(cursor, ECORE_CALLBACK_PASS_ON); + if (edata->configure_reqs > 0) edata->configure_reqs--; edata->configure_coming = 0; @@ -1684,7 +1691,7 @@ _ecore_evas_x_event_window_configure(void *data EINA_UNUSED, int type EINA_UNUSE { if ((ee->expecting_resize.w == ee->w) && (ee->expecting_resize.h == ee->h)) - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, ecore_x_current_time_get()); ee->expecting_resize.w = 0; ee->expecting_resize.h = 0; @@ -2340,10 +2347,16 @@ static void _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, Evas_Engine_Info *einfo) { + Evas_Device *pointer; + Ecore_Evas_Cursor *cursor; int rot_dif; Ecore_Evas_Engine_Data_X11 *edata = ee->engine.data; int fw = 0, fh = 0; + pointer = evas_default_device_get(ee->evas, EFL_INPUT_DEVICE_CLASS_MOUSE); + cursor = eina_hash_find(ee->prop.cursors, &pointer); + EINA_SAFETY_ON_NULL_RETURN(cursor); + rot_dif = ee->rotation - rotation; if (rot_dif < 0) rot_dif = -rot_dif; @@ -2422,7 +2435,7 @@ _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, ecore_evas_size_max_set(ee, maxh, maxw); ecore_evas_size_base_set(ee, baseh, basew); ecore_evas_size_step_set(ee, steph, stepw); - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, ecore_x_current_time_get()); } else @@ -2432,7 +2445,7 @@ _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } ee->rotation = rotation; - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + _ecore_evas_mouse_move_process(ee, cursor->pos_x, cursor->pos_y, ecore_x_current_time_get()); if (ee->func.fn_resize) ee->func.fn_resize(ee); From 87e458838dd4f5edff6b8ac9dae21380d69fa4ea Mon Sep 17 00:00:00 2001 From: Guilherme Iscaro Date: Fri, 2 Dec 2016 17:17:53 -0200 Subject: [PATCH 6/6] Ecore Evas: Add a new cursor example. This example sets the cursor image of each available mouse and report its position every one second. --- src/examples/ecore/.gitignore | 1 + src/examples/ecore/Makefile.am | 12 +- .../ecore/ecore_evas_cursor_example.c | 166 ++++++++++++++++++ 3 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 src/examples/ecore/ecore_evas_cursor_example.c diff --git a/src/examples/ecore/.gitignore b/src/examples/ecore/.gitignore index eeaf839ff3..5d577a6556 100644 --- a/src/examples/ecore/.gitignore +++ b/src/examples/ecore/.gitignore @@ -20,6 +20,7 @@ /ecore_evas_buffer_example_01 /ecore_evas_buffer_example_02 /ecore_evas_callbacks +/ecore_evas_cursor_example /ecore_evas_ews_example /ecore_evas_extn_plug_example /ecore_evas_extn_socket_example diff --git a/src/examples/ecore/Makefile.am b/src/examples/ecore/Makefile.am index f0f4557b14..c90e0c6f2b 100644 --- a/src/examples/ecore/Makefile.am +++ b/src/examples/ecore/Makefile.am @@ -57,9 +57,10 @@ ecore_con_url_ftp_example \ ecore_evas_basics_example \ ecore_evas_buffer_example_01 \ ecore_evas_buffer_example_02 \ +ecore_evas_callbacks \ +ecore_evas_cursor_example \ ecore_evas_extn_socket_example \ ecore_evas_extn_plug_example \ -ecore_evas_callbacks \ ecore_evas_ews_example \ ecore_evas_object_example \ ecore_evas_wayland_multiseat_example \ @@ -209,15 +210,18 @@ ecore_evas_buffer_example_01_LDADD = $(ECORE_EVAS_COMMON_LDADD) ecore_evas_buffer_example_02_SOURCES = ecore_evas_buffer_example_02.c ecore_evas_buffer_example_02_LDADD = $(ECORE_EVAS_COMMON_LDADD) +ecore_evas_callbacks_SOURCES = ecore_evas_callbacks.c +ecore_evas_callbacks_LDADD = $(ECORE_EVAS_COMMON_LDADD) + +ecore_evas_cursor_example_SOURCES = ecore_evas_cursor_example.c +ecore_evas_cursor_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) + ecore_evas_extn_socket_example_SOURCES = ecore_evas_extn_socket_example.c ecore_evas_extn_socket_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) ecore_evas_extn_plug_example_SOURCES = ecore_evas_extn_plug_example.c ecore_evas_extn_plug_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) -ecore_evas_callbacks_SOURCES = ecore_evas_callbacks.c -ecore_evas_callbacks_LDADD = $(ECORE_EVAS_COMMON_LDADD) - ecore_evas_ews_example_SOURCES = ecore_evas_ews_example.c ecore_evas_ews_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) diff --git a/src/examples/ecore/ecore_evas_cursor_example.c b/src/examples/ecore/ecore_evas_cursor_example.c new file mode 100644 index 0000000000..e5e83c5cc7 --- /dev/null +++ b/src/examples/ecore/ecore_evas_cursor_example.c @@ -0,0 +1,166 @@ +/** + * Ecore Evas example illustrating how to set a new cursor image for a pointer device. + * + * @verbatim + * gcc -o ecore_evas_cursor_example ecore_evas_cursor_example.c `pkg-config --libs --cflags evas ecore ecore-evas` + * @endverbatim + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include +#include +#include + +#define W (200) +#define H (200) +#define TIMEOUT (1.0) + +static void +_delete_request_cb(Ecore_Evas *ee EINA_UNUSED) +{ + ecore_main_loop_quit(); +} + +static void +_resize_cb(Ecore_Evas *ee) +{ + int w, h; + + ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); + evas_object_resize(ecore_evas_data_get(ee, "bg"), w, h); +} + +static Eina_Bool +_mouse_pos_print(void *data) +{ + Efl_Input_Device *pointer; + const Eina_List *devs, *l; + + devs = evas_device_list(ecore_evas_get(data), NULL); + + EINA_LIST_FOREACH(devs, l, pointer) + { + Evas_Coord x, y; + Efl_Input_Device *seat; + + if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_MOUSE) + continue; + ecore_evas_pointer_device_xy_get(data, pointer, &x, &y); + seat = efl_input_device_seat_get(pointer); + if (!seat) + { + fprintf(stderr, "Could not fetch the seat from mouse '%s'\n", + efl_input_device_name_get(pointer)); + continue; + } + printf("Mouse from seat '%s' is at (%d, %d)\n", + efl_input_device_name_get(seat), x, y); + } + return EINA_TRUE; +} + +static void +_cursor_set(Ecore_Evas *ee, Efl_Input_Device *pointer) +{ + Evas_Object *obj; + + obj = evas_object_rectangle_add(ecore_evas_get(ee)); + evas_object_color_set(obj, rand() % 256, rand() % 256, rand() % 256, 255); + evas_object_resize(obj, 30, 30); + evas_object_show(obj); + ecore_evas_object_cursor_device_set(ee, pointer, obj, 0, 10, 10); +} + +static void +_device_added(void *data, const Efl_Event *event) +{ + Efl_Input_Device *pointer = event->info; + Efl_Input_Device *seat; + + if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_MOUSE) + return; + seat = efl_input_device_seat_get(pointer); + if (!seat) + { + fprintf(stderr, "Could not fetch the seat from pointer '%s'\n", + efl_input_device_name_get(pointer)); + return; + } + printf("Setting cursor image at seat '%s'\n", efl_input_device_name_get(seat)); + _cursor_set(data, pointer); +} + +int +main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED) +{ + const Eina_List *devs, *l; + Efl_Input_Device *pointer; + Ecore_Evas *ee; + Evas_Object *bg; + Evas *e; + Ecore_Timer *t; + const char *driver; + + srand(time(NULL)); + if (!ecore_evas_init()) + { + fprintf(stderr, "Could not init the Ecore Evas\n"); + return EXIT_FAILURE; + } + + ee = ecore_evas_new(NULL, 0, 0, W, H, NULL); + if (!ee) + { + fprintf(stderr, "Could not create the Ecore Evas\n"); + goto err_ee; + } + + driver = ecore_evas_engine_name_get(ee); + printf("Using driver %s\n", driver); + if ((!strcmp(driver, "fb") || !strcmp(driver, "software_x11")) && + !ecore_evas_vnc_start(ee, "localhost", -1, NULL, NULL, NULL)) + { + fprintf(stderr, "Could not init the VNC server\n"); + goto err_ee; + } + + e = ecore_evas_get(ee); + bg = evas_object_rectangle_add(e); + evas_object_resize(bg, W, H); + evas_object_move(bg, 0, 0); + evas_object_color_set(bg, 255, 255, 255, 255); + evas_object_show(bg); + ecore_evas_data_set(ee, "bg", bg); + + devs = evas_device_list(e, NULL); + + EINA_LIST_FOREACH(devs, l, pointer) + { + if (efl_input_device_type_get(pointer) != EFL_INPUT_DEVICE_CLASS_MOUSE) + continue; + _cursor_set(ee, pointer); + } + + t = ecore_timer_add(TIMEOUT, _mouse_pos_print, ee); + efl_event_callback_add(e, EFL_CANVAS_EVENT_DEVICE_ADDED, + _device_added, ee); + ecore_evas_callback_resize_set(ee, _resize_cb); + ecore_evas_callback_delete_request_set(ee, _delete_request_cb); + + ecore_evas_show(ee); + ecore_main_loop_begin(); + ecore_evas_free(ee); + ecore_timer_del(t); + ecore_evas_shutdown(); + return EXIT_SUCCESS; + + err_ee: + ecore_evas_shutdown(); + return EXIT_FAILURE; +}