[mutter/wayland] wayland: Ensure that opaque / input regions are set at commit time



commit b1206ceb665789f982a8528219ee25c2e80f3e41
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Aug 31 13:27:41 2013 -0400

    wayland: Ensure that opaque / input regions are set at commit time
    
    The protocol specification says that opaque / input regions should be
    considered pending state and should only be actually swapped out when
    the surface is committed, so it can be set atomically.

 src/wayland/meta-wayland-private.h |    3 +++
 src/wayland/meta-wayland.c         |   17 +++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index b52f449..af43ab2 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -89,6 +89,9 @@ struct _MetaWaylandSurface
     /* wl_surface.damage */
     cairo_region_t *damage;
 
+    cairo_region_t *input_region;
+    cairo_region_t *opaque_region;
+
     /* wl_surface.frame */
     struct wl_list frame_callback_list;
   } pending;
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 56ac249..f4056c2 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -335,8 +335,8 @@ meta_wayland_surface_set_opaque_region (struct wl_client *client,
   if (!surface)
     return;
 
-  if (surface->window)
-    meta_window_set_opaque_region (surface->window, cairo_region_copy (region->region));
+  g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
+  surface->pending.opaque_region = cairo_region_copy (region->region);
 }
 
 static void
@@ -351,8 +351,8 @@ meta_wayland_surface_set_input_region (struct wl_client *client,
   if (!surface)
     return;
 
-  if (surface->window)
-    meta_window_set_input_region (surface->window, cairo_region_copy (region->region));
+  g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
+  surface->pending.input_region = cairo_region_copy (region->region);
 }
 
 static void
@@ -420,6 +420,15 @@ meta_wayland_surface_commit (struct wl_client *client,
   surface->pending.sy = 0;
   surface->pending.newly_attached = FALSE;
 
+  if (surface->window)
+    {
+      meta_window_set_opaque_region (surface->window, surface->pending.opaque_region);
+      g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
+
+      meta_window_set_input_region (surface->window, surface->pending.input_region);
+      g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
+    }
+
   surface_process_damage (surface, surface->pending.damage);
   empty_region (surface->pending.damage);
 


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