[mutter/wip/xwayland: 4/5] wayland: Move surface_set_buffer back into the commits



commit ce121a492c447f8d8c91e426e6ee7c66e6f1a94c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Apr 2 11:24:19 2014 -0400

    wayland: Move surface_set_buffer back into the commits
    
    For XWayland support, we need to delay the buffer set until after
    we do the typechecking, as we need to bail out early in that case.

 src/wayland/meta-wayland-surface.c |   57 +++++++++++++++++++-----------------
 1 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 5446877..c3987f7 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -144,22 +144,37 @@ ensure_buffer_texture (MetaWaylandBuffer *buffer)
   buffer->texture = texture;
 }
 
+static gboolean
+commit_attached_surface (MetaWaylandSurface             *surface,
+                         MetaWaylandDoubleBufferedState *pending)
+{
+  /* wl_surface.attach */
+  if (pending->newly_attached && surface->buffer != pending->buffer)
+    {
+      surface_set_buffer (surface, pending->buffer);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
 static void
 cursor_surface_commit (MetaWaylandSurface             *surface,
-                       MetaWaylandDoubleBufferedState *pending,
-                       gboolean                        buffer_changed)
+                       MetaWaylandDoubleBufferedState *pending)
 {
-  if (buffer_changed)
+  if (commit_attached_surface (surface, pending))
     meta_wayland_seat_update_cursor_surface (surface->compositor->seat);
 }
 
-static void
+static gboolean
 actor_surface_commit (MetaWaylandSurface             *surface,
-                      MetaWaylandDoubleBufferedState *pending,
-                      gboolean                        buffer_changed)
+                      MetaWaylandDoubleBufferedState *pending)
 {
   MetaSurfaceActor *surface_actor = surface->surface_actor;
   MetaWaylandBuffer *buffer = pending->buffer;
+  gboolean buffer_changed;
+
+  buffer_changed = commit_attached_surface (surface, pending);
 
   if (buffer_changed && buffer)
     {
@@ -173,16 +188,15 @@ actor_surface_commit (MetaWaylandSurface             *surface,
     meta_surface_actor_set_opaque_region (surface_actor, pending->opaque_region);
   if (pending->input_region)
     meta_surface_actor_set_input_region (surface_actor, pending->input_region);
+
+  return buffer_changed;
 }
 
 static void
 toplevel_surface_commit (MetaWaylandSurface             *surface,
-                         MetaWaylandDoubleBufferedState *pending,
-                         gboolean                        buffer_changed)
+                         MetaWaylandDoubleBufferedState *pending)
 {
-  actor_surface_commit (surface, pending, buffer_changed);
-
-  if (buffer_changed)
+  if (actor_surface_commit (surface, pending))
     {
       MetaWindow *window = surface->window;
       MetaWaylandBuffer *buffer = pending->buffer;
@@ -291,8 +305,7 @@ move_double_buffered_state (MetaWaylandDoubleBufferedState *from,
 
 static void
 subsurface_surface_commit (MetaWaylandSurface             *surface,
-                           MetaWaylandDoubleBufferedState *pending,
-                           gboolean                        buffer_changed)
+                           MetaWaylandDoubleBufferedState *pending)
 {
   /*
    * If the sub-surface is in synchronous mode, post-pone the commit of its
@@ -312,9 +325,7 @@ subsurface_surface_commit (MetaWaylandSurface             *surface,
     }
   else
     {
-      actor_surface_commit (surface, pending, buffer_changed);
-
-      if (buffer_changed)
+      if (actor_surface_commit (surface, pending))
         {
           MetaSurfaceActor *surface_actor = surface->surface_actor;
           MetaWaylandBuffer *buffer = pending->buffer;
@@ -347,21 +358,13 @@ commit_double_buffered_state (MetaWaylandSurface             *surface,
                               MetaWaylandDoubleBufferedState *pending)
 {
   MetaWaylandCompositor *compositor = surface->compositor;
-  gboolean buffer_changed = FALSE;
-
-  /* wl_surface.attach */
-  if (pending->newly_attached && surface->buffer != pending->buffer)
-    {
-      surface_set_buffer (surface, pending->buffer);
-      buffer_changed = TRUE;
-    }
 
   if (surface == compositor->seat->cursor_surface)
-    cursor_surface_commit (surface, pending, buffer_changed);
+    cursor_surface_commit (surface, pending);
   else if (surface->window)
-    toplevel_surface_commit (surface, pending, buffer_changed);
+    toplevel_surface_commit (surface, pending);
   else if (surface->subsurface.resource)
-    subsurface_surface_commit (surface, pending, buffer_changed);
+    subsurface_surface_commit (surface, pending);
 
   g_list_foreach (surface->subsurfaces,
                   parent_surface_committed,


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