1
0
Fork 0

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>
This commit is contained in:
Jonas Ådahl 2022-09-14 23:12:52 +02:00 committed by Marge Bot
parent 41f488a65c
commit 85ef0d1a46
2 changed files with 22 additions and 0 deletions

View file

@ -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);

View file

@ -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)