devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=1005a6d299957c16b733b8f2bdd7ae7afb4e2f36

commit 1005a6d299957c16b733b8f2bdd7ae7afb4e2f36
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Tue Oct 14 14:40:02 2014 -0400

    add code to integrate wayland event loop with ecore_main loop
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/bin/e_comp_wl.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index 47bafab..d558e6f 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -13,6 +13,30 @@ _e_comp_wl_log_cb_print(const char *format, va_list args)
    INF("WL: ", format, args);
 }
 
+static Eina_Bool 
+_e_comp_wl_cb_read(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
+{
+   E_Comp_Data *cdata;
+
+   if (!(cdata = data)) return ECORE_CALLBACK_RENEW;
+
+   /* dispatch pending wayland events */
+   wl_event_loop_dispatch(cdata->wl.loop, 0);
+
+   return ECORE_CALLBACK_RENEW;
+}
+
+static void 
+_e_comp_wl_cb_prepare(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
+{
+   E_Comp_Data *cdata;
+
+   if (!(cdata = data)) return;
+
+   /* flush pending client events */
+   wl_display_flush_clients(cdata->wl.disp);
+}
+
 static void 
 _e_comp_wl_compositor_cb_bind(struct wl_client *client, void *data, uint32_t 
version, uint32_t id)
 {
@@ -48,6 +72,7 @@ _e_comp_wl_compositor_create(void)
 {
    E_Comp *comp;
    const char *name;
+   int fd = 0;
 
    /* check for existing compositor. create if needed */
    if (!(comp = e_comp_get(NULL)))
@@ -97,6 +122,19 @@ _e_comp_wl_compositor_create(void)
    /* initialize shm mechanism */
    wl_display_init_shm(cdata->wl.disp);
 
+   /* get the wayland display loop */
+   cdata->wl.loop = wl_display_get_event_loop(cdata->wl.disp);
+
+   /* get the file descriptor of the wayland event loop */
+   fd = wl_event_loop_get_fd(cdata->wl.loop);
+
+   /* create a listener for wayland main loop events */
+   cdata->fd_hdlr = 
+     ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR), 
+                               _e_comp_wl_cb_read, cdata, NULL, NULL);
+   ecore_main_fd_handler_prepare_callback_set(cdata->fd_hdlr, 
+                                              _e_comp_wl_cb_prepare, cdata);
+
    return EINA_TRUE;
 
 comp_global_err:

-- 


Reply via email to