From 07024ab6c84ddadd74a7c5c08a2661af51e38997 Mon Sep 17 00:00:00 2001 From: thierry E Date: Tue, 9 May 2017 10:13:11 -0700 Subject: [PATCH] ecore_x: add function to show and hide X cursor. Signed-off-by: Cedric BAIL --- src/lib/ecore_x/Ecore_X.h | 2 ++ src/lib/ecore_x/ecore_x_fixes.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h index c81be31808..8c0c7d3ef1 100644 --- a/src/lib/ecore_x/Ecore_X.h +++ b/src/lib/ecore_x/Ecore_X.h @@ -2436,6 +2436,8 @@ EAPI void ecore_x_region_expand(Ecore_X_Region dest, Ecore_X_Regio EAPI void ecore_x_region_gc_clip_set(Ecore_X_Region region, Ecore_X_GC gc, int x_origin, int y_origin); EAPI void ecore_x_region_window_shape_set(Ecore_X_Region region, Ecore_X_Window win, Ecore_X_Shape_Type type, int x_offset, int y_offset); EAPI void ecore_x_region_picture_clip_set(Ecore_X_Region region, Ecore_X_Picture picture, int x_origin, int y_origin); +EAPI void ecore_x_cursor_show(void); +EAPI void ecore_x_cursor_hide(void); /** * xfixes selection notification request. diff --git a/src/lib/ecore_x/ecore_x_fixes.c b/src/lib/ecore_x/ecore_x_fixes.c index 30432354d5..f656edec6e 100644 --- a/src/lib/ecore_x/ecore_x_fixes.c +++ b/src/lib/ecore_x/ecore_x_fixes.c @@ -10,6 +10,7 @@ static int _fixes_available; #ifdef ECORE_XFIXES static int _fixes_major, _fixes_minor; +static int _cursor_visible = 1; #endif /* ifdef ECORE_XFIXES */ void @@ -406,3 +407,31 @@ ecore_x_region_picture_clip_set(Ecore_X_Region region, if (_ecore_xlib_sync) ecore_x_sync(); #endif /* ifdef ECORE_XFIXES */ } + +EAPI void +ecore_x_cursor_show(void) +{ + EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp); +#ifdef ECORE_XFIXES + if (!_cursor_visible) + { + XFixesShowCursor(_ecore_x_disp, DefaultRootWindow(_ecore_x_disp)); + XFlush(_ecore_x_disp); + _cursor_visible = 1; + } +#endif /* ifdef ECORE_XFIXES */ +} + +EAPI void +ecore_x_cursor_hide(void) +{ + EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp); +#ifdef ECORE_XFIXES + if (_cursor_visible) + { + XFixesHideCursor(_ecore_x_disp, DefaultRootWindow(_ecore_x_disp)); + XFlush(_ecore_x_disp); + _cursor_visible = 0; + } +#endif /* ifdef ECORE_XFIXES */ +}