[metacity] window: move shape clipping to MetaSurface



commit 75aa437588e78bc1269e11a63ac8a146a473e728
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Oct 18 19:36:02 2019 +0300

    window: move shape clipping to MetaSurface
    
    Shape region might not change when window is resized!

 src/compositor/meta-surface.c | 16 ++++++++++++++++
 src/core/window.c             | 13 -------------
 2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/src/compositor/meta-surface.c b/src/compositor/meta-surface.c
index 1ea15c45..29b6244f 100644
--- a/src/compositor/meta-surface.c
+++ b/src/compositor/meta-surface.c
@@ -113,6 +113,18 @@ get_frame_region (MetaSurface *self,
   return frame_region;
 }
 
+static void
+clip_shape_region (Display       *xdisplay,
+                   XserverRegion  shape_region,
+                   XRectangle    *client_rect)
+{
+  XserverRegion client_region;
+
+  client_region = XFixesCreateRegion (xdisplay, client_rect, 1);
+  XFixesIntersectRegion (xdisplay, shape_region, shape_region, client_region);
+  XFixesDestroyRegion (xdisplay, client_region);
+}
+
 static void
 update_shape_region (MetaSurface   *self,
                      XserverRegion  damage_region)
@@ -145,11 +157,15 @@ update_shape_region (MetaSurface   *self,
                              shape_region,
                              client_rect.x,
                              client_rect.y);
+
+      clip_shape_region (priv->xdisplay, shape_region, &client_rect);
     }
   else if (priv->window->shape_region != None)
     {
       shape_region = XFixesCreateRegion (priv->xdisplay, NULL, 0);
       XFixesCopyRegion (priv->xdisplay, shape_region, priv->window->shape_region);
+
+      clip_shape_region (priv->xdisplay, shape_region, &client_rect);
     }
   else
     {
diff --git a/src/core/window.c b/src/core/window.c
index 225bffd2..f45374f7 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -9220,19 +9220,6 @@ meta_window_update_shape_region (MetaWindow *window)
       return;
     }
 
-  if (shape_region != None)
-    {
-      XserverRegion tmp;
-
-      tmp = XFixesCreateRegion (xdisplay, &(XRectangle) {
-                                  .width = window->rect.width,
-                                  .height = window->rect.height
-                                }, 1);
-
-      XFixesIntersectRegion (xdisplay, shape_region, shape_region, tmp);
-      XFixesDestroyRegion (xdisplay, tmp);
-    }
-
   if (window->shape_region != None)
     XFixesDestroyRegion (xdisplay, window->shape_region);
   window->shape_region = shape_region;


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