From b6802e1f001ef6a2d5c29cd568267426c2936487 Mon Sep 17 00:00:00 2001 From: msizanoen Date: Wed, 14 Feb 2024 20:54:36 +0700 Subject: [PATCH] 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: --- src/wayland/meta-wayland-surface.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 60f306bfb..3761c7b72 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1786,24 +1786,27 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface, } void -meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface, - float sx, - float sy, +meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface, + float sx, + float sy, float *x, float *y) { ClutterActor *actor = 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 = { .x = sx, .y = sy, }; 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; - *y = v.y; + *x = clutter_actor_get_x (window_actor) + v.x; + *y = clutter_actor_get_y (window_actor) + v.y; } static void