From a5e44d393481c6e2a261ce43f4884caa8d85628d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 15 Jul 2013 18:27:33 +0100 Subject: [PATCH] wayland: Add API for disabling the event dispatching This allows the integration of Clutter with another library, like GTK+, that is dispatching the events itself. This is implemented by calling into the cogl_wayland_renderer_set_event_dispatch_enabled() and since that function must be called on the newly created renderer the newly added clutter_wayland_disable_event_retrieval must be called before clutter_init() https://bugzilla.gnome.org/show_bug.cgi?id=704279 --- clutter/clutter.symbols | 1 + clutter/wayland/clutter-backend-wayland.c | 31 ++++++++++++++++++++++ clutter/wayland/clutter-wayland.h | 3 +++ doc/reference/clutter/clutter-sections.txt | 1 + 4 files changed, 36 insertions(+) diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols index bc5ca603b..448a0bb40 100644 --- a/clutter/clutter.symbols +++ b/clutter/clutter.symbols @@ -1598,6 +1598,7 @@ clutter_wayland_input_device_get_wl_seat clutter_wayland_stage_get_wl_shell_surface clutter_wayland_stage_get_wl_surface clutter_wayland_set_display +clutter_wayland_disable_event_retrieval #endif #ifdef CLUTTER_WINDOWING_WIN32 clutter_win32_disable_event_retrieval diff --git a/clutter/wayland/clutter-backend-wayland.c b/clutter/wayland/clutter-backend-wayland.c index bebfcd2d4..48e8eadeb 100644 --- a/clutter/wayland/clutter-backend-wayland.c +++ b/clutter/wayland/clutter-backend-wayland.c @@ -61,6 +61,7 @@ G_DEFINE_TYPE (ClutterBackendWayland, clutter_backend_wayland, CLUTTER_TYPE_BACKEND); static struct wl_display *_foreign_display = NULL; +static gboolean _no_event_dispatch = FALSE; static void clutter_backend_wayland_load_cursor (ClutterBackendWayland *backend_wayland); @@ -240,6 +241,7 @@ clutter_backend_wayland_get_renderer (ClutterBackend *backend, renderer = cogl_renderer_new (); + cogl_wayland_renderer_set_event_dispatch_enabled (renderer, !_no_event_dispatch); cogl_renderer_set_winsys_id (renderer, COGL_WINSYS_ID_EGL_WAYLAND); cogl_wayland_renderer_set_foreign_display (renderer, @@ -352,3 +354,32 @@ clutter_wayland_set_display (struct wl_display *display) _foreign_display = display; } + +/** + * clutter_wayland_disable_event_retrieval: + * + * Disables the dispatch of the events in the main loop. + * + * This is useful for integrating Clutter with another library that will do the + * event dispatch; in general only a single source should be acting on changes + * on the Wayland file descriptor. + * + * This function can only be called before calling + * clutter_init(). + * + * This function should not be normally used by applications. + * + * Since: 1.16 + */ +void +clutter_wayland_disable_event_retrieval (void) +{ + if (_clutter_context_is_initialized ()) + { + g_warning ("%s() can only be used before calling clutter_init()", + G_STRFUNC); + return; + } + + _no_event_dispatch = TRUE; +} diff --git a/clutter/wayland/clutter-wayland.h b/clutter/wayland/clutter-wayland.h index 53a896827..414343aac 100644 --- a/clutter/wayland/clutter-wayland.h +++ b/clutter/wayland/clutter-wayland.h @@ -52,5 +52,8 @@ struct wl_surface *clutter_wayland_stage_get_wl_surface (ClutterStage *stage); CLUTTER_AVAILABLE_IN_1_16 void clutter_wayland_set_display (struct wl_display *display); +CLUTTER_AVAILABLE_IN_1_16 +void clutter_wayland_disable_event_retrieval (void); + G_END_DECLS #endif /* __CLUTTER_WAYLAND_H__ */ diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 6a336e34d..3daf739e1 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1436,6 +1436,7 @@ clutter_wayland_input_device_get_wl_seat clutter_wayland_stage_get_wl_shell_surface clutter_wayland_stage_get_wl_surface clutter_wayland_set_display +clutter_wayland_disable_event_retrieval