[mutter] Clip the shaped region to the bounding region



commit 2b93c19328c8d09f0713374f431b0ea67b2daea5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun May 15 00:10:47 2011 -0400

    Clip the shaped region to the bounding region
    
    According to the XShape specification, the shaped region should always be
    a subset of the bounding region. Certain programs such as wine depended
    on this behavior.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=627880

 src/compositor/meta-window-actor.c |   37 +++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index 4aab5c9..ecfbe99 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -1683,13 +1683,22 @@ meta_window_actor_update_bounding_region (MetaWindowActor *self,
 
   priv->bounding_region = cairo_region_create_rectangle (&bounding_rectangle);
 
-  /* When we're shaped, we use the shape region to generate the shadow; the shape
-   * region only changes when we get ShapeNotify event; but for unshaped windows
-   * we generate the shadow from the bounding region, so we need to recompute
-   * the shadow when the size changes.
-   */
-  if (!priv->shaped)
-    meta_window_actor_invalidate_shadow (self);
+  if (priv->shaped)
+    {
+      /* If we're shaped, the implicit shape region clipping we need to do needs
+       * to be updated.
+       */
+      meta_window_actor_update_shape (self, TRUE);
+    }
+  else
+    {
+      /* When we're shaped, we use the shape region to generate the shadow; the shape
+       * region only changes when we get ShapeNotify event; but for unshaped windows
+       * we generate the shadow from the bounding region, so we need to recompute
+       * the shadow when the size changes.
+       */
+      meta_window_actor_invalidate_shadow (self);
+    }
 
   g_signal_emit (self, signals[SIZE_CHANGED], 0);
 }
@@ -1710,6 +1719,20 @@ meta_window_actor_update_shape_region (MetaWindowActor *self,
       cairo_rectangle_int_t rect = { rects[i].x, rects[i].y, rects[i].width, rects[i].height };
       cairo_region_union_rectangle (priv->shape_region, &rect);
     }
+
+  /* Our "shape_region" is called the "bounding region" in the X Shape
+   * Extension Documentation.
+   *
+   * Our "bounding_region" is called the "bounding rectangle", which defines
+   * the shape of the window as if it the window was unshaped.
+   *
+   * The X Shape extension requires that the "bounding region" can never
+   * extend outside the "bounding rectangle", and says it must be implicitly
+   * clipped before rendering. The region we get back hasn't been clipped.
+   * We explicitly clip the region here.
+   */
+  if (priv->bounding_region != NULL)
+    cairo_region_intersect (priv->shape_region, priv->bounding_region);
 }
 
 /**



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