[cogl] wayland: Add API to prevent Cogl from dispatching the wayland display
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] wayland: Add API to prevent Cogl from dispatching the wayland display
- Date: Tue, 9 Jul 2013 12:47:56 +0000 (UTC)
commit f5b8d98676ab3e90ad80459019c737ec2ff90aa4
Author: Neil Roberts <neil linux intel com>
Date: Thu Jul 4 13:14:04 2013 +0100
wayland: Add API to prevent Cogl from dispatching the wayland display
This adds cogl_wayland_renderer_set_event_dispatch_enabled() which can
be used to prevent Cogl from adding the socket for the Wayland display
to its list of file descriptors to poll. This can be used in
applications that want to integrate Cogl with existing code that is
reading from the Wayland socket itself.
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/cogl-renderer-private.h | 1 +
cogl/cogl-renderer.c | 4 ++++
cogl/cogl-wayland-renderer.h | 22 ++++++++++++++++++++++
cogl/winsys/cogl-winsys-egl-wayland.c | 27 ++++++++++++++++++++-------
doc/reference/cogl2/cogl2-sections.txt | 1 +
5 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-renderer-private.h b/cogl/cogl-renderer-private.h
index dfc79c6..8b8d2bf 100644
--- a/cogl/cogl-renderer-private.h
+++ b/cogl/cogl-renderer-private.h
@@ -77,6 +77,7 @@ struct _CoglRenderer
#if defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
struct wl_display *foreign_wayland_display;
+ CoglBool wayland_enable_event_dispatch;
#endif
#ifdef COGL_HAS_SDL_SUPPORT
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index 33e086c..2564c9d 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -288,6 +288,10 @@ cogl_renderer_new (void)
renderer->win32_enable_event_retrieval = TRUE;
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ renderer->wayland_enable_event_dispatch = TRUE;
+#endif
+
return _cogl_renderer_object_new (renderer);
}
diff --git a/cogl/cogl-wayland-renderer.h b/cogl/cogl-wayland-renderer.h
index 3f9e434..20b0b49 100644
--- a/cogl/cogl-wayland-renderer.h
+++ b/cogl/cogl-wayland-renderer.h
@@ -52,6 +52,28 @@ cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer,
struct wl_display *display);
/**
+ * cogl_wayland_renderer_set_event_dispatch_enabled:
+ * @renderer: A #CoglRenderer
+ * @enable: The new value
+ *
+ * Sets whether Cogl should handle calling wl_display_dispatch() and
+ * wl_display_flush() as part of its main loop integration via
+ * cogl_poll_renderer_get_info() and cogl_poll_renderer_dispatch().
+ * The default value is %TRUE. When it is enabled the application can
+ * register listeners for Wayland interfaces and the callbacks will be
+ * invoked during cogl_poll_renderer_dispatch(). If the application
+ * wants to integrate with its own code that is already handling
+ * reading from the Wayland display socket, it should disable this to
+ * avoid having competing code read from the socket.
+ *
+ * Since: 1.16
+ * Stability: unstable
+ */
+void
+cogl_wayland_renderer_set_event_dispatch_enabled (CoglRenderer *renderer,
+ CoglBool enable);
+
+/**
* cogl_wayland_renderer_get_display:
* @renderer: A #CoglRenderer
*
diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
index fad0cae..f5a6047 100644
--- a/cogl/winsys/cogl-winsys-egl-wayland.c
+++ b/cogl/winsys/cogl-winsys-egl-wayland.c
@@ -233,13 +233,15 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
if (!_cogl_winsys_egl_renderer_connect_common (renderer, error))
goto error;
- wayland_renderer->fd = wl_display_get_fd(wayland_renderer->wayland_display);
- _cogl_poll_renderer_add_fd (renderer,
- wayland_renderer->fd,
- COGL_POLL_FD_EVENT_IN,
- prepare_wayland_display_events,
- dispatch_wayland_display_events,
- renderer);
+ wayland_renderer->fd = wl_display_get_fd (wayland_renderer->wayland_display);
+
+ if (renderer->wayland_enable_event_dispatch)
+ _cogl_poll_renderer_add_fd (renderer,
+ wayland_renderer->fd,
+ COGL_POLL_FD_EVENT_IN,
+ prepare_wayland_display_events,
+ dispatch_wayland_display_events,
+ renderer);
return TRUE;
@@ -546,6 +548,17 @@ cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer,
renderer->foreign_wayland_display = display;
}
+void
+cogl_wayland_renderer_set_event_dispatch_enabled (CoglRenderer *renderer,
+ CoglBool enable)
+{
+ _COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
+ /* NB: Renderers are considered immutable once connected */
+ _COGL_RETURN_IF_FAIL (!renderer->connected);
+
+ renderer->wayland_enable_event_dispatch = enable;
+}
+
struct wl_display *
cogl_wayland_renderer_get_display (CoglRenderer *renderer)
{
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index 1a6feee..1a6e343 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -89,6 +89,7 @@ cogl_win32_renderer_set_event_retrieval_enabled
<SUBSECTION>
cogl_wayland_renderer_set_foreign_display
+cogl_wayland_renderer_set_event_dispatch_enabled
cogl_wayland_renderer_get_display
</SECTION>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]