[mutter] compositor-view/native: Check that the actor covers the the view



commit 85ef0d1a46b9c8d179f33208b5396b6a1f4225c9
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Sep 14 23:12:52 2022 +0200

    compositor-view/native: Check that the actor covers the the view
    
    If we have a window that match the size (i.e. will pass the "fits
    framebuffer" low level check), that doesn't mean it matches the
    position. For example, if we have two monitors 2K monitors, with two 2K
    sized windows, one on monitor A, and one on monitor both monitor A and
    B, overlapping both, if the latter window is above the former, it'll end
    up bing scanned out on both if it ends up fitting all the other
    requirements.
    
    Fix this by checking that the paint box matches the stage view layout,
    as that makes sure the actor we're painting isn't just partially on the
    right view.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2387
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2624>

 clutter/clutter/clutter-mutter.h             |  5 +++++
 src/compositor/meta-compositor-view-native.c | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)
---
diff --git a/clutter/clutter/clutter-mutter.h b/clutter/clutter/clutter-mutter.h
index b383ff518c..04efa5d86d 100644
--- a/clutter/clutter/clutter-mutter.h
+++ b/clutter/clutter/clutter-mutter.h
@@ -38,6 +38,11 @@
 #include "clutter-stage-view-private.h"
 #include "clutter.h"
 
+/* An epsilon larger than FLT_EPSILON that is useful when comparing coordinates
+ * while ignoring floating point precision loss that might happen during
+ * various matrix calculations. */
+#define CLUTTER_COORDINATE_EPSILON (1.0 / 256.0)
+
 typedef struct _ClutterMainContext ClutterContext;
 
 typedef ClutterBackend * (* ClutterBackendConstructor) (gpointer user_data);
diff --git a/src/compositor/meta-compositor-view-native.c b/src/compositor/meta-compositor-view-native.c
index 932d43a3b9..4c7e7f7a89 100644
--- a/src/compositor/meta-compositor-view-native.c
+++ b/src/compositor/meta-compositor-view-native.c
@@ -83,6 +83,8 @@ find_scanout_candidate (MetaCompositorView  *compositor_view,
   CoglFramebuffer *framebuffer;
   MetaWindowActor *window_actor;
   MetaWindow *window;
+  MetaRectangle view_rect;
+  ClutterActorBox actor_box;
   MetaSurfaceActor *surface_actor;
   MetaSurfaceActorWayland *surface_actor_wayland;
   MetaWaylandSurface *surface;
@@ -126,6 +128,21 @@ find_scanout_candidate (MetaCompositorView  *compositor_view,
   if (meta_surface_actor_is_obscured (surface_actor))
     return FALSE;
 
+  if (!clutter_actor_get_paint_box (CLUTTER_ACTOR (surface_actor),
+                                    &actor_box))
+    return FALSE;
+
+  clutter_stage_view_get_layout (stage_view, &view_rect);
+  if (!G_APPROX_VALUE (actor_box.x1, view_rect.x,
+                       CLUTTER_COORDINATE_EPSILON) ||
+      !G_APPROX_VALUE (actor_box.y1, view_rect.y,
+                       CLUTTER_COORDINATE_EPSILON) ||
+      !G_APPROX_VALUE (actor_box.x2, view_rect.x + view_rect.width,
+                       CLUTTER_COORDINATE_EPSILON) ||
+      !G_APPROX_VALUE (actor_box.y2, view_rect.y + view_rect.height,
+                       CLUTTER_COORDINATE_EPSILON))
+    return FALSE;
+
   surface_actor_wayland = META_SURFACE_ACTOR_WAYLAND (surface_actor);
   surface = meta_surface_actor_wayland_get_surface (surface_actor_wayland);
   if (!surface)


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