devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=90217c80fc3e800c00b7e453d739b3e6dc1b92ae

commit 90217c80fc3e800c00b7e453d739b3e6dc1b92ae
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Fri Sep 25 14:31:30 2015 -0400

    ecore-wl2: Add implementation for supporting custom tick animators
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/lib/ecore_wl2/Ecore_Wl2.h         |  3 +++
 src/lib/ecore_wl2/ecore_wl2_display.c | 44 ++++++++++++++++++++++++++++++++
 src/lib/ecore_wl2/ecore_wl2_private.h |  4 +++
 src/lib/ecore_wl2/ecore_wl2_window.c  | 48 +++++++++++++++++++++++++++++++++++
 4 files changed, 99 insertions(+)

diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 871eab6..d02e587 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -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
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c 
b/src/lib/ecore_wl2/ecore_wl2_display.c
index 97867a8..afa6d52 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -216,6 +216,30 @@ static const struct wl_callback_listener _sync_listener =
 };
 
 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)
 {
    Ecore_Wl2_Output *output;
@@ -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;
+}
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h 
b/src/lib/ecore_wl2/ecore_wl2_private.h
index 04343c4..1bdb993 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -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);
 
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c 
b/src/lib/ecore_wl2/ecore_wl2_window.c
index 495faaf..b9546fb 100644
--- a/src/lib/ecore_wl2/ecore_wl2_window.c
+++ b/src/lib/ecore_wl2/ecore_wl2_window.c
@@ -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)
 {

-- 


Reply via email to