[clutter/clutter-1.16] wayland: Add foreign surface support to stage



commit b6d2232150f3c6212c4e4ff79b46ff885679d0c4
Author: Chris Cummins <christopher e cummins intel com>
Date:   Thu May 2 17:46:49 2013 +0100

    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

 clutter/clutter.symbols                    |    1 +
 clutter/wayland/clutter-stage-wayland.c    |   47 ++++++++++++++++++++++++++++
 clutter/wayland/clutter-stage-wayland.h    |    1 +
 clutter/wayland/clutter-wayland.h          |    3 ++
 doc/reference/clutter/clutter-sections.txt |    1 +
 5 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 448a0bb..c28dfd6 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -1597,6 +1597,7 @@ clutter_vertex_new
 clutter_wayland_input_device_get_wl_seat
 clutter_wayland_stage_get_wl_shell_surface
 clutter_wayland_stage_get_wl_surface
+clutter_wayland_stage_set_wl_surface
 clutter_wayland_set_display
 clutter_wayland_disable_event_retrieval
 #endif
diff --git a/clutter/wayland/clutter-stage-wayland.c b/clutter/wayland/clutter-stage-wayland.c
index c8c5679..099f407 100644
--- a/clutter/wayland/clutter-stage-wayland.c
+++ b/clutter/wayland/clutter-stage-wayland.c
@@ -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");
+}
diff --git a/clutter/wayland/clutter-stage-wayland.h b/clutter/wayland/clutter-stage-wayland.h
index 3c7eb42..a8124b5 100644
--- a/clutter/wayland/clutter-stage-wayland.h
+++ b/clutter/wayland/clutter-stage-wayland.h
@@ -53,6 +53,7 @@ struct _ClutterStageWayland
   struct wl_surface *wayland_surface;
   struct wl_shell_surface *wayland_shell_surface;
   gboolean fullscreen;
+  gboolean foreign_wl_surface;
 };
 
 struct _ClutterStageWaylandClass
diff --git a/clutter/wayland/clutter-wayland.h b/clutter/wayland/clutter-wayland.h
index 414343a..08f63a8 100644
--- a/clutter/wayland/clutter-wayland.h
+++ b/clutter/wayland/clutter-wayland.h
@@ -50,6 +50,9 @@ CLUTTER_AVAILABLE_IN_1_10
 struct wl_surface *clutter_wayland_stage_get_wl_surface (ClutterStage *stage);
 
 CLUTTER_AVAILABLE_IN_1_16
+void clutter_wayland_stage_set_wl_surface (ClutterStage *stage, struct wl_surface *surface);
+
+CLUTTER_AVAILABLE_IN_1_16
 void clutter_wayland_set_display (struct wl_display *display);
 
 CLUTTER_AVAILABLE_IN_1_16
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index 3daf739..c9eb98c 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -1435,6 +1435,7 @@ clutter_glx_texture_pixmap_get_type
 clutter_wayland_input_device_get_wl_seat
 clutter_wayland_stage_get_wl_shell_surface
 clutter_wayland_stage_get_wl_surface
+clutter_wayland_stage_set_wl_surface
 clutter_wayland_set_display
 clutter_wayland_disable_event_retrieval
 </SECTION>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]