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
This commit is contained in:
Rob Bradford 2013-07-15 18:27:33 +01:00
parent 74ab8c3bda
commit a5230278b4
4 changed files with 36 additions and 0 deletions

View File

@ -1162,6 +1162,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

View File

@ -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,
@ -356,3 +358,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.
*
* <warning>This function can only be called before calling
* clutter_init().</warning>
*
* 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;
}

View File

@ -49,5 +49,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__ */

View File

@ -923,6 +923,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
</SECTION>
<SECTION>