[mutter/wayland] wayland: Make wl_subsurface.set_position properly synchronized



commit 16de7f66fba535111f6a6cf82740637e1328b625
Author: Jonas Ådahl <jadahl gmail com>
Date:   Sun Jan 12 23:17:29 2014 +0100

    wayland: Make wl_subsurface.set_position properly synchronized
    
    The position set by wl_subsurface.set_position should be applied when
    the parent surface invokes wl_surface.commit.
    
    Signed-off-by: Jonas Ådahl <jadahl gmail com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705502

 src/wayland/meta-wayland-surface.c |   25 ++++++++++++++++++++++++-
 src/wayland/meta-wayland-surface.h |    4 ++++
 2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index e96c922..bd1feea 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -327,6 +327,9 @@ subsurface_surface_commit (MetaWaylandSurface *surface)
 }
 
 static void
+wl_subsurface_parent_surface_committed (gpointer data, gpointer user_data);
+
+static void
 meta_wayland_surface_commit (struct wl_client *client,
                              struct wl_resource *resource)
 {
@@ -346,6 +349,10 @@ meta_wayland_surface_commit (struct wl_client *client,
   else if (surface->subsurface.resource)
     subsurface_surface_commit (surface);
 
+  g_list_foreach (surface->subsurfaces,
+                  wl_subsurface_parent_surface_committed,
+                  NULL);
+
   if (surface->pending.buffer)
     {
       wl_list_remove (&surface->pending.buffer_destroy_listener.link);
@@ -994,6 +1001,20 @@ bind_gtk_shell (struct wl_client *client,
 }
 
 static void
+wl_subsurface_parent_surface_committed (gpointer data, gpointer user_data)
+{
+  MetaWaylandSurface *surface = data;
+
+  if (surface->sub.pending_pos)
+    {
+      clutter_actor_set_position (CLUTTER_ACTOR (surface->surface_actor),
+                                  surface->sub.pending_x,
+                                  surface->sub.pending_y);
+      surface->sub.pending_pos = FALSE;
+    }
+}
+
+static void
 wl_subsurface_destructor (struct wl_resource *resource)
 {
   MetaWaylandSurfaceExtension *subsurface = wl_resource_get_user_data (resource);
@@ -1026,7 +1047,9 @@ wl_subsurface_set_position (struct wl_client *client,
   MetaWaylandSurfaceExtension *subsurface = wl_resource_get_user_data (resource);
   MetaWaylandSurface *surface = wl_container_of (subsurface, surface, subsurface);
 
-  clutter_actor_set_position (CLUTTER_ACTOR (surface->surface_actor), x, y);
+  surface->sub.pending_x = x;
+  surface->sub.pending_y = y;
+  surface->sub.pending_pos = TRUE;
 }
 
 static gboolean
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index fe2bfea..32fa0fd 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -90,6 +90,10 @@ struct _MetaWaylandSurface
   struct {
     MetaWaylandSurface *parent;
     struct wl_listener parent_destroy_listener;
+
+    int32_t pending_x;
+    int32_t pending_y;
+    gboolean pending_pos;
   } sub;
 
   /* All the pending state, that wl_surface.commit will apply. */


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