wayland: Add foreign surface support to stage

This adds support for optionally a providing a foreign Wayland surface
to a ClutterStage before it is first show. Setting a foreign surface
prevents Cogl from allocating a surface and shell surface for the stage
automatically.

v2: add CLUTTER_AVAILABLE_IN_1_16 annotation and API reference docs
    (review from Emmanuele Bassi)
v3: set a boolean to indicate that this stage is using a foreign surface
(Rob Bradford)

https://bugzilla.gnome.org/show_bug.cgi?id=699578
This commit is contained in:
Chris Cummins
2013-05-02 17:46:49 +01:00
committed by Rob Bradford
parent a5230278b4
commit d390a44615
5 changed files with 53 additions and 0 deletions

View File

@ -290,3 +290,50 @@ clutter_wayland_stage_get_wl_surface (ClutterStage *stage)
return stage_wayland->wayland_surface;
}
/**
* clutter_wayland_stage_set_wl_surface:
* @stage: a #ClutterStage
* @surface: A Wayland surface to associate with the @stage.
*
* Allows you to explicitly provide an existing Wayland surface to associate
* with @stage, preventing Cogl from allocating a surface and shell surface for
* the stage automatically.
*
* This function must be called before @stage is shown.
*
* Note: this function can only be called when running on the Wayland
* platform. Calling this function at any other time has no effect.
*
* Since: 1.16
*/
void
clutter_wayland_stage_set_wl_surface (ClutterStage *stage,
struct wl_surface *surface)
{
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
ClutterStageWayland *stage_wayland;
ClutterStageCogl *stage_cogl;
if (!CLUTTER_IS_STAGE_WAYLAND (stage_window))
return;
stage_cogl = CLUTTER_STAGE_COGL (stage_window);
if (stage_cogl->onscreen == NULL)
{
ClutterBackend *backend = clutter_get_default_backend ();
/* Use the same default dimensions as clutter_stage_cogl_realize() */
stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
800, 600);
cogl_wayland_onscreen_set_foreign_surface (stage_cogl->onscreen,
surface);
stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
stage_wayland->foreign_wl_surface = TRUE;
}
else
g_warning (G_STRLOC ": cannot set foreign surface for stage");
}