[mutter/gnome-3-36] wayland: Ensure pointer constraint region consistency



commit d06d5fc895ec059d66cac266e6581f85bfa68669
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 23 18:58:48 2020 +0100

    wayland: Ensure pointer constraint region consistency
    
    Changes in games between fullscreen and windowed modes may trigger
    chaotic situations where the buffer and the frame size temporarily
    disagree, producing rectangles with negative width/height. This is
    usually followed by other updates that bring the pointer constraint
    up to date.
    
    This makes cairo panic and return an "error" empty region, which breaks
    deeper down when using the region rectangles to apply the pointer
    constraint.
    
    If we hit this situation, ignore the frame rectangle, and just go with
    the buffer rectangle.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1655>
    
    (cherry picked from commit 98ef6d0d0521b3cfb72153bc427a9bfc86b8d338)

 src/wayland/meta-wayland-pointer-constraints.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 7547d7e13f..c36f4654c6 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -625,12 +625,15 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
                                                   frame->right_width);
       actual_height = window->buffer_rect.height - (frame->child_y +
                                                     frame->bottom_height);
-      cairo_region_intersect_rectangle (region, &(cairo_rectangle_int_t) {
-                                          .x = frame->child_x,
-                                          .y = frame->child_y,
-                                          .width = actual_width,
-                                          .height = actual_height
-                                        });
+      if (actual_width > 0 && actual_height > 0)
+        {
+          cairo_region_intersect_rectangle (region, &(cairo_rectangle_int_t) {
+                                              .x = frame->child_x,
+                                              .y = frame->child_y,
+                                              .width = actual_width,
+                                              .height = actual_height
+                                            });
+        }
     }
 
   return region;


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