wayland: Port to current Wayland
This change is one logical update to update the Wayland support. This comprises of the following parts: * Binding to both the shell and compositor global objects - necessary since the API for setting top level status moved to the wl_shell interface * The Wayland visual API went away and instead you setup the EGL surface appropriately * The message handling was refined to reflect the current behaviour - now obsolete comments were removed and new comments updated Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
00ca539845
commit
11d38e7ce8
@ -95,7 +95,7 @@ typedef struct _CoglRendererEGL
|
|||||||
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
||||||
struct wl_display *wayland_display;
|
struct wl_display *wayland_display;
|
||||||
struct wl_compositor *wayland_compositor;
|
struct wl_compositor *wayland_compositor;
|
||||||
uint32_t wayland_event_mask;
|
struct wl_shell *wayland_shell;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EGLDisplay edpy;
|
EGLDisplay edpy;
|
||||||
@ -319,18 +319,14 @@ display_handle_global_cb (struct wl_display *display,
|
|||||||
uint32_t version,
|
uint32_t version,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct wl_compositor **compositor = data;
|
CoglRendererEGL *egl_renderer = (CoglRendererEGL *)data;
|
||||||
|
|
||||||
if (strcmp (interface, "wl_compositor") == 0)
|
if (strcmp (interface, "wl_compositor") == 0)
|
||||||
*compositor = wl_compositor_create (display, id, 1);
|
egl_renderer->wayland_compositor =
|
||||||
}
|
wl_display_bind (display, id, &wl_compositor_interface);
|
||||||
|
else if (strcmp(interface, "wl_shell") == 0)
|
||||||
static int
|
egl_renderer->wayland_shell =
|
||||||
event_mask_update_cb (uint32_t mask, void *user_data)
|
wl_display_bind (display, id, &wl_shell_interface);
|
||||||
{
|
|
||||||
CoglRendererEGL *egl_renderer = user_data;
|
|
||||||
egl_renderer->wayland_event_mask = mask;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -418,20 +414,19 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX: For some reason, this can only be done after calling
|
|
||||||
* eglInitialize otherwise eglInitialize fails in
|
|
||||||
* dri2_initialize_wayland because dri2_dpy->wl_dpy->fd doesn't get
|
|
||||||
* updated.
|
|
||||||
*
|
|
||||||
* XXX: Hmm actually now it seems to work :-/
|
|
||||||
* There seems to be some fragility about when this is called.
|
|
||||||
*/
|
|
||||||
wl_display_add_global_listener (egl_renderer->wayland_display,
|
wl_display_add_global_listener (egl_renderer->wayland_display,
|
||||||
display_handle_global_cb,
|
display_handle_global_cb,
|
||||||
&egl_renderer->wayland_compositor);
|
egl_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that that we've received the messages setting up the compostor and
|
||||||
|
* shell object. This is better than just wl_display_iterate since it will
|
||||||
|
* always ensure that something is available to be read
|
||||||
|
*/
|
||||||
|
while (!(egl_renderer->wayland_compositor && egl_renderer->wayland_shell))
|
||||||
|
wl_display_roundtrip (egl_renderer->wayland_display);
|
||||||
|
|
||||||
egl_renderer->edpy =
|
egl_renderer->edpy =
|
||||||
eglGetDisplay ((EGLNativeDisplayType)egl_renderer->wayland_display);
|
eglGetDisplay ((EGLNativeDisplayType)egl_renderer->wayland_display);
|
||||||
|
|
||||||
@ -439,15 +434,6 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
|||||||
&egl_renderer->egl_version_major,
|
&egl_renderer->egl_version_major,
|
||||||
&egl_renderer->egl_version_minor);
|
&egl_renderer->egl_version_minor);
|
||||||
|
|
||||||
wl_display_flush (egl_renderer->wayland_display);
|
|
||||||
|
|
||||||
wl_display_get_fd (egl_renderer->wayland_display,
|
|
||||||
event_mask_update_cb, egl_renderer);
|
|
||||||
|
|
||||||
/* Wait until we have been notified about the compositor object */
|
|
||||||
while (!egl_renderer->wayland_compositor)
|
|
||||||
wl_display_iterate (egl_renderer->wayland_display,
|
|
||||||
egl_renderer->wayland_event_mask);
|
|
||||||
#else
|
#else
|
||||||
egl_renderer->edpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
|
egl_renderer->edpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
@ -664,9 +650,6 @@ try_create_context (CoglDisplay *display,
|
|||||||
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
||||||
XVisualInfo *xvisinfo;
|
XVisualInfo *xvisinfo;
|
||||||
XSetWindowAttributes attrs;
|
XSetWindowAttributes attrs;
|
||||||
#endif
|
|
||||||
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
||||||
struct wl_visual *wayland_visual;
|
|
||||||
#endif
|
#endif
|
||||||
const char *error_message;
|
const char *error_message;
|
||||||
|
|
||||||
@ -775,13 +758,10 @@ try_create_context (CoglDisplay *display,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
wayland_visual =
|
|
||||||
wl_display_get_premultiplied_argb_visual (egl_renderer->wayland_display);
|
|
||||||
egl_display->wayland_egl_native_window =
|
egl_display->wayland_egl_native_window =
|
||||||
wl_egl_window_create (egl_display->wayland_surface,
|
wl_egl_window_create (egl_display->wayland_surface,
|
||||||
1,
|
1,
|
||||||
1,
|
1);
|
||||||
wayland_visual);
|
|
||||||
if (!egl_display->wayland_egl_native_window)
|
if (!egl_display->wayland_egl_native_window)
|
||||||
{
|
{
|
||||||
error_message= "Failed to create a dummy wayland native egl surface";
|
error_message= "Failed to create a dummy wayland native egl surface";
|
||||||
@ -1205,9 +1185,6 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
|||||||
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
||||||
#endif
|
#endif
|
||||||
CoglOnscreenEGL *egl_onscreen;
|
CoglOnscreenEGL *egl_onscreen;
|
||||||
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
||||||
struct wl_visual *wayland_visual;
|
|
||||||
#endif
|
|
||||||
EGLint attributes[MAX_EGL_CONFIG_ATTRIBS];
|
EGLint attributes[MAX_EGL_CONFIG_ATTRIBS];
|
||||||
EGLConfig egl_config;
|
EGLConfig egl_config;
|
||||||
EGLint config_count = 0;
|
EGLint config_count = 0;
|
||||||
@ -1382,13 +1359,10 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wayland_visual =
|
|
||||||
wl_display_get_premultiplied_argb_visual (egl_renderer->wayland_display);
|
|
||||||
egl_onscreen->wayland_egl_native_window =
|
egl_onscreen->wayland_egl_native_window =
|
||||||
wl_egl_window_create (egl_onscreen->wayland_surface,
|
wl_egl_window_create (egl_onscreen->wayland_surface,
|
||||||
cogl_framebuffer_get_width (framebuffer),
|
cogl_framebuffer_get_width (framebuffer),
|
||||||
cogl_framebuffer_get_height (framebuffer),
|
cogl_framebuffer_get_height (framebuffer));
|
||||||
wayland_visual);
|
|
||||||
if (!egl_onscreen->wayland_egl_native_window)
|
if (!egl_onscreen->wayland_egl_native_window)
|
||||||
{
|
{
|
||||||
g_set_error (error, COGL_WINSYS_ERROR,
|
g_set_error (error, COGL_WINSYS_ERROR,
|
||||||
@ -1405,7 +1379,8 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
|||||||
egl_onscreen->wayland_egl_native_window,
|
egl_onscreen->wayland_egl_native_window,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
wl_surface_map_toplevel (egl_onscreen->wayland_surface);
|
wl_shell_set_toplevel (egl_renderer->wayland_shell,
|
||||||
|
egl_onscreen->wayland_surface);
|
||||||
|
|
||||||
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
|
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
|
||||||
defined (COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT) || \
|
defined (COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT) || \
|
||||||
@ -1596,13 +1571,15 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
|
|||||||
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
||||||
|
|
||||||
eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
|
eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
|
||||||
#if 0
|
|
||||||
/* XXX: I think really this should be done automatically for
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
||||||
* us in eglSwapBuffers since the spec says eglSwapBuffers
|
/*
|
||||||
* implicitly flushes client commands. */
|
* The implementation of eglSwapBuffers may do a flush however the semantics
|
||||||
while (egl_renderer->wayland_event_mask & WL_DISPLAY_WRITABLE)
|
* of eglSwapBuffers on Wayland has changed in the past. So to be safe to
|
||||||
wl_display_iterate (egl_renderer->wayland_display,
|
* the implementation changing we should explicitly ensure all messages are
|
||||||
WL_DISPLAY_WRITABLE);
|
* sent.
|
||||||
|
*/
|
||||||
|
wl_display_flush (egl_renderer->wayland_display);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user