ecore-wl2: Add new event for sync done

This removes the usage of ecore_main_loop_iterate inside of the
display_connect function. It creates a new event type for when display
sync is done, this was we can defer surface creation and EE showing
until the compositor has had a chance to synchronize globals. We need
this for Enlightenment so that it does not try to create error dialogs
too early and thus crash due to not having sync'd globals yet

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-12-11 11:24:32 -05:00
parent f6804ac1c6
commit 8c85a89303
3 changed files with 17 additions and 18 deletions

View File

@ -126,6 +126,11 @@ typedef struct _Ecore_Wl2_Event_Window_Configure
int x, y, w, h;
} Ecore_Wl2_Event_Window_Configure;
typedef struct _Ecore_Wl2_Event_Sync_Done
{
Ecore_Wl2_Display *display;
} Ecore_Wl2_Event_Sync_Done;
typedef enum _Ecore_Wl2_Window_Type
{
ECORE_WL2_WINDOW_TYPE_NONE,
@ -156,6 +161,7 @@ EAPI extern int ECORE_WL2_EVENT_DATA_SOURCE_TARGET;
EAPI extern int ECORE_WL2_EVENT_DATA_SOURCE_SEND;
EAPI extern int ECORE_WL2_EVENT_SELECTION_DATA_READY;
EAPI extern int ECORE_WL2_EVENT_WINDOW_CONFIGURE;
EAPI extern int ECORE_WL2_EVENT_SYNC_DONE;
/**
* @file

View File

@ -25,6 +25,7 @@ EAPI int ECORE_WL2_EVENT_DATA_SOURCE_TARGET = 0;
EAPI int ECORE_WL2_EVENT_DATA_SOURCE_SEND = 0;
EAPI int ECORE_WL2_EVENT_SELECTION_DATA_READY = 0;
EAPI int ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0;
EAPI int ECORE_WL2_EVENT_SYNC_DONE = 0;
/* public API functions */
EAPI int
@ -75,6 +76,7 @@ ecore_wl2_init(void)
ECORE_WL2_EVENT_DATA_SOURCE_SEND = ecore_event_type_new();
ECORE_WL2_EVENT_SELECTION_DATA_READY = ecore_event_type_new();
ECORE_WL2_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
ECORE_WL2_EVENT_SYNC_DONE = ecore_event_type_new();
}
return _ecore_wl2_init_count;
@ -117,6 +119,7 @@ ecore_wl2_shutdown(void)
ECORE_WL2_EVENT_DATA_SOURCE_SEND = 0;
ECORE_WL2_EVENT_SELECTION_DATA_READY = 0;
ECORE_WL2_EVENT_WINDOW_CONFIGURE = 0;
ECORE_WL2_EVENT_SYNC_DONE = 0;
/* shutdown Ecore_Event */
ecore_event_shutdown();

View File

@ -106,6 +106,7 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
wl_registry_bind(registry, id, &xdg_shell_interface, 1);
xdg_shell_use_unstable_version(ewd->wl.xdg_shell, XDG_VERSION);
xdg_shell_add_listener(ewd->wl.xdg_shell, &_xdg_shell_listener, NULL);
EINA_INLIST_FOREACH(ewd->windows, window)
_ecore_wl2_window_shell_surface_init(window);
}
@ -309,12 +310,19 @@ err:
static void
_cb_sync_done(void *data, struct wl_callback *cb, uint32_t serial EINA_UNUSED)
{
Ecore_Wl2_Event_Sync_Done *ev;
Ecore_Wl2_Display *ewd;
ewd = data;
ewd->sync_done = EINA_TRUE;
wl_callback_destroy(cb);
ev = calloc(1, sizeof(Ecore_Wl2_Event_Sync_Done));
if (!ev) return;
ev->display = ewd;
ecore_event_add(ECORE_WL2_EVENT_SYNC_DONE, ev, NULL, NULL);
}
static const struct wl_callback_listener _sync_listener =
@ -597,24 +605,6 @@ ecore_wl2_display_connect(const char *name)
while (!ewd->sync_done)
wl_display_dispatch(ewd->wl.display);
}
else
{
/* this client is on same pid as server so we need to iterate
* main loop until the "server" advertises it's globals
*
* NB: DO NOT REMOVE THIS !!
*
* This is NEEDED for E's internal dialogs to function because the
* "server" and "client" are on the same PID
* and thus the "server" never advertises out it's globals
* (wl_compositor, wl_shm, etc) unless we sit here and iterate the
* main loop until it's done.
*
* If we remove this, E will never show an internal dialog as it
* just sits and waits for the globals */
while (!ewd->sync_done)
ecore_main_loop_iterate();
}
return ewd;