struct wl_list outputs;
struct wl_list globals; /** @since 1.7.6 */
+ Eina_Bool init_done;
+
struct
{
struct xkb_context *context;
/**
* Retrieves the Wayland Globals Interface list used for the current Wayland connection.
*
+ * This call, if done after the ECORE_WL_EVENT_INTERFACES_BOUND event was
+ * received already, won't block the mainloop or trigger a dispatch. It will
+ * return the current globals immediately. However, if done before this event,
+ * it will probably block the mainloop waiting for the sync "done" event to be
+ * received (by using one or more wl_display_dispatch call), and then finally
+ * return the wl globals list.
+ *
+ * There's no need to call dispatch manually, since this call will do it if necessary.
+ *
* @return The current wayland globals interface list
*
* @ingroup Ecore_Wl_Display_Group
static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED);
static void _ecore_wl_signal_exit(void);
static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event);
+static void _ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED);
/* local variables */
static int _ecore_wl_init_count = 0;
_ecore_wl_sync_callback
};
+static const struct wl_callback_listener _ecore_wl_init_sync_listener =
+{
+ _ecore_wl_init_callback
+};
+
static const struct wl_callback_listener _ecore_wl_anim_listener =
{
_ecore_wl_animator_callback
EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0;
EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0;
+static void
+_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
+{
+ Ecore_Wl_Display *ewd = data;
+
+ wl_callback_destroy(callback);
+ ewd->init_done = EINA_TRUE;
+}
+
+static void
+_ecore_wl_init_wait(void)
+{
+ while (!_ecore_wl_disp->init_done)
+ wl_display_dispatch(_ecore_wl_disp->wl.display);
+}
+
EAPI int
ecore_wl_init(const char *name)
{
+ struct wl_callback *callback;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count;
_ecore_wl_window_init();
_ecore_wl_events_init();
+ callback = wl_display_sync(_ecore_wl_disp->wl.display);
+ wl_callback_add_listener(callback, &_ecore_wl_init_sync_listener,
+ _ecore_wl_disp);
+
return _ecore_wl_init_count;
}
ecore_wl_shm_get(void)
{
if (!_ecore_wl_disp) return NULL;
+
+ _ecore_wl_init_wait();
+
return _ecore_wl_disp->wl.shm;
}
{
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
return NULL;
+
+ _ecore_wl_init_wait();
+
return &(_ecore_wl_disp->globals);
}
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
- if (!_ecore_wl_disp->output)
- ecore_wl_sync();
+ _ecore_wl_init_wait();
if (!_ecore_wl_disp->output) return;