ecore-wl2: Add implementation for supporting custom tick animators

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-09-25 14:31:30 -04:00
parent e04ab79ecc
commit 90217c80fc
4 changed files with 99 additions and 0 deletions

View File

@ -257,6 +257,9 @@ EAPI struct wl_shm *ecore_wl2_display_shm_get(Ecore_Wl2_Display *display);
*/
EAPI Eina_Iterator *ecore_wl2_display_globals_get(Ecore_Wl2_Display *display);
EAPI Eina_Bool ecore_wl2_display_animator_source_set(Ecore_Wl2_Display *display, Ecore_Animator_Source source);
/**
* @defgroup Ecore_Wl2_Window_Group Wayland Library Window Functions
* @ingroup Ecore_Wl2_Group

View File

@ -215,6 +215,30 @@ static const struct wl_callback_listener _sync_listener =
_cb_sync_done
};
static void
_animator_tick_cb_begin(void *data)
{
Ecore_Wl2_Display *display;
Ecore_Wl2_Window *window;
display = data;
if (!display) return;
EINA_INLIST_FOREACH(display->windows, window)
_ecore_wl2_window_animator_add(window);
}
static void
_animator_tick_cb_end(void *data)
{
Ecore_Wl2_Display *display;
display = data;
if (!display) return;
_ecore_wl2_window_animator_end();
}
static void
_ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
{
@ -402,3 +426,23 @@ ecore_wl2_display_globals_get(Ecore_Wl2_Display *display)
EINA_SAFETY_ON_NULL_RETURN_VAL(display, NULL);
return eina_hash_iterator_data_new(display->globals);
}
EAPI Eina_Bool
ecore_wl2_display_animator_source_set(Ecore_Wl2_Display *display, Ecore_Animator_Source source)
{
switch (source)
{
case ECORE_ANIMATOR_SOURCE_CUSTOM:
ecore_animator_custom_source_tick_begin_callback_set
(_animator_tick_cb_begin, display);
ecore_animator_custom_source_tick_end_callback_set
(_animator_tick_cb_end, display);
break;
case ECORE_ANIMATOR_SOURCE_TIMER:
ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
ecore_animator_custom_source_tick_end_callback_set(NULL, NULL);
break;
}
return EINA_TRUE;
}

View File

@ -86,6 +86,7 @@ struct _Ecore_Wl2_Window
struct wl_shell_surface *wl_shell_surface;
struct xdg_surface *xdg_surface;
struct xdg_popup *xdg_popup;
struct wl_callback *anim_cb;
Eina_Rectangle geometry;
@ -213,6 +214,9 @@ struct _Ecore_Wl2_Input
Ecore_Wl2_Window *_ecore_wl2_display_window_surface_find(Ecore_Wl2_Display *display, struct wl_surface *wl_surface);
void _ecore_wl2_window_animator_add(Ecore_Wl2_Window *window);
void _ecore_wl2_window_animator_end(void);
void _ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id);
void _ecore_wl2_output_del(Ecore_Wl2_Output *output);

View File

@ -4,6 +4,10 @@
#include "ecore_wl2_private.h"
static void _anim_cb_animate(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED);
static Eina_Bool _animator_busy = EINA_FALSE;
static void
_wl_shell_surface_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial)
{
@ -199,6 +203,50 @@ _ecore_wl2_window_type_set(Ecore_Wl2_Window *win)
}
}
static const struct wl_callback_listener _anim_listener =
{
_anim_cb_animate
};
static void
_anim_cb_animate(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
{
Ecore_Wl2_Window *window;
window = data;
if (!window) return;
ecore_animator_custom_tick();
wl_callback_destroy(callback);
window->anim_cb = NULL;
if (_animator_busy)
{
window->anim_cb = wl_surface_frame(window->surface);
wl_callback_add_listener(window->anim_cb, &_anim_listener, window);
wl_surface_commit(window->surface);
}
}
void
_ecore_wl2_window_animator_add(Ecore_Wl2_Window *window)
{
_animator_busy = EINA_TRUE;
if ((!window->surface) || (window->anim_cb)) return;
window->anim_cb = wl_surface_frame(window->surface);
wl_callback_add_listener(window->anim_cb, &_anim_listener, window);
wl_surface_commit(window->surface);
}
void
_ecore_wl2_window_animator_end(void)
{
_animator_busy = EINA_FALSE;
}
EAPI Ecore_Wl2_Window *
ecore_wl2_window_new(Ecore_Wl2_Display *display, Ecore_Wl2_Window *parent, int x, int y, int w, int h)
{