wayland-surface: Fix get_absolute_coordinates() for active transition cases

Currently, we blindly apply the transformation matrices of all parent
actors when calculating the absolute coordinates. This means if this
function is called while the window actor containing the surface is in
the middle of a transition (e.g. window open animation), it may return
incorrect values. As this function is used for calculating pointer
confinement bounds for a specific surface, this will result in incorrect
bounds value being used if pointer constraints are applied by the
application at the same time the window is created and the mouse is
inside the surface's bounds when it's created.

Fix this by only applying transformation matrices up to the window actor
of the surface and then calculating the absolute coordinates by adding
the position of the window actor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3585>
This commit is contained in:
msizanoen 2024-02-14 20:54:36 +07:00 committed by Marge Bot
parent c63fdba6b3
commit b6802e1f00

View File

@ -1786,24 +1786,27 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
} }
void void
meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface, meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
float sx, float sx,
float sy, float sy,
float *x, float *x,
float *y) float *y)
{ {
ClutterActor *actor = ClutterActor *actor =
CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface));
MetaWindow *window = meta_wayland_surface_get_window (surface);
ClutterActor *window_actor =
CLUTTER_ACTOR (meta_window_actor_from_window (window));
graphene_point3d_t sv = { graphene_point3d_t sv = {
.x = sx, .x = sx,
.y = sy, .y = sy,
}; };
graphene_point3d_t v = { 0 }; graphene_point3d_t v = { 0 };
clutter_actor_apply_relative_transform_to_point (actor, NULL, &sv, &v); clutter_actor_apply_relative_transform_to_point (actor, window_actor, &sv, &v);
*x = v.x; *x = clutter_actor_get_x (window_actor) + v.x;
*y = v.y; *y = clutter_actor_get_y (window_actor) + v.y;
} }
static void static void