[cogl/cogl-1.16] wayland: Add API to prevent Cogl from dispatching the wayland display



commit 3d9eaef3acd9e55ae9c4e8afeca9300371f805a6
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>
    
    (cherry picked from commit f5b8d98676ab3e90ad80459019c737ec2ff90aa4)

 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 ++++++++++++++-----
 .../cogl-2.0-experimental-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 75ae149..3e2601f 100644
--- a/cogl/cogl-renderer-private.h
+++ b/cogl/cogl-renderer-private.h
@@ -76,6 +76,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 e3008db..41b1eaa 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -197,6 +197,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 4b4d522..4b4e377 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;
 
@@ -547,6 +549,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/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt 
b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index 9b31f3a..00ed18f 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-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]