antognolli pushed a commit to branch ecore-1.7.
commit a7d403cc5734d8cdbdb28fb0298b12d0116ef4a4
Author: Rafael Antognolli <[email protected]>
Date: Mon Apr 8 15:25:10 2013 -0300
Backport: e38c985cd0250814d2b222ce8ab9a599e81aeee4
ecore/wayland: Actually wait for the sync callback on ecore_wl_sync().
The wl_display_sync() request doesn't really wait for all the requests
to be processed, but instead sends a request for the "done" event.
Wayland relies on the fact that the requests are processed in order, so
when the "done" event is received, it means that all the other requests
requested prior to the respective "sync" have been processed already.
This commit makes the ecore_wl_sync() call actually wait for its "done"
event (thus blocking the ecore mainloop).
---
src/lib/ecore_wayland/Ecore_Wayland.h | 1 +
src/lib/ecore_wayland/ecore_wl.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h
b/src/lib/ecore_wayland/Ecore_Wayland.h
index 98093f1..382414c 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -101,6 +101,7 @@ struct _Ecore_Wl_Display
int fd;
unsigned int mask;
unsigned int serial;
+ int sync_ref_count;
Ecore_Fd_Handler *fd_hdl;
Ecore_Idle_Enterer *idle_enterer;
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index 68437b6..60931a6 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -38,6 +38,8 @@ static Eina_Bool _ecore_wl_cb_handle_data(void *data,
Ecore_Fd_Handler *hdl);
static void _ecore_wl_cb_handle_global(void *data, struct wl_registry
*registry, unsigned int id, const char *interface, unsigned int version
__UNUSED__);
static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd);
static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd);
+static void _ecore_wl_sync_wait(Ecore_Wl_Display *ewd);
+static void _ecore_wl_sync_callback(void *data, struct wl_callback *callback,
uint32_t serial);
/* local variables */
static int _ecore_wl_init_count = 0;
@@ -47,6 +49,11 @@ static const struct wl_registry_listener
_ecore_wl_registry_listener =
NULL // handle_global_remove
};
+static const struct wl_callback_listener _ecore_wl_sync_listener =
+{
+ _ecore_wl_sync_callback
+};
+
/* external variables */
int _ecore_wl_log_dom = -1;
Ecore_Wl_Display *_ecore_wl_disp = NULL;
@@ -252,7 +259,9 @@ ecore_wl_sync(void)
{
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
- wl_display_sync(_ecore_wl_disp->wl.display);
+ _ecore_wl_sync_wait(_ecore_wl_disp);
+ while (_ecore_wl_disp->sync_ref_count > 0)
+ wl_display_dispatch(_ecore_wl_disp->wl.display);
}
/**
@@ -605,3 +614,22 @@ _ecore_wl_create_data_source(Ecore_Wl_Display *ewd)
{
return
wl_data_device_manager_create_data_source(ewd->wl.data_device_manager);
}
+
+static void
+_ecore_wl_sync_callback(void *data, struct wl_callback *callback, uint32_t
serial EINA_UNUSED)
+{
+ Ecore_Wl_Display *ewd = data;
+
+ ewd->sync_ref_count--;
+ wl_callback_destroy(callback);
+}
+
+static void
+_ecore_wl_sync_wait(Ecore_Wl_Display *ewd)
+{
+ struct wl_callback *callback;
+
+ ewd->sync_ref_count++;
+ callback = wl_display_sync(ewd->wl.display);
+ wl_callback_add_listener(callback, &_ecore_wl_sync_listener, ewd);
+}
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter