diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c index 8f066b0240..0c9b032b7b 100644 --- a/src/lib/ecore_wl2/ecore_wl2_display.c +++ b/src/lib/ecore_wl2/ecore_wl2_display.c @@ -184,6 +184,22 @@ _cb_globals_hash_del(void *data) free(global); } +static void +_cb_sync_done(void *data, struct wl_callback *cb, uint32_t serial EINA_UNUSED) +{ + Ecore_Wl2_Display *ewd; + + ewd = data; + ewd->sync_done = EINA_TRUE; + + wl_callback_destroy(cb); +} + +static const struct wl_callback_listener _sync_listener = +{ + _cb_sync_done +}; + static void _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd) { @@ -254,6 +270,7 @@ EAPI Ecore_Wl2_Display * ecore_wl2_display_connect(const char *name) { Ecore_Wl2_Display *ewd; + struct wl_callback *cb; /* allocate space for display structure */ ewd = calloc(1, sizeof(Ecore_Wl2_Display)); @@ -280,6 +297,16 @@ ecore_wl2_display_connect(const char *name) ewd->xkb_context = xkb_context_new(0); if (!ewd->xkb_context) goto context_err; + /* NB: If we are connecting (as a client), then we will need to setup + * a callback for display_sync and wait for it to complete. There is no + * other option here as we need the compositor, shell, etc, to be setup + * before we can allow a user to make use of the API functions we provide */ + cb = wl_display_sync(ewd->wl.display); + wl_callback_add_listener(cb, &_sync_listener, ewd); + + while (!ewd->sync_done) + wl_display_dispatch(ewd->wl.display); + return ewd; context_err: