wayland/surface: Move relative coordinate calculating to roles

The role determines how a relative coordinate is calculated. More
specifically, using clutters API to transform coordinates is only
accurate right after a clutter layout pass but this function is used
e.g. to deliver pointer motion events which can happen at any time. This
isn't a problem for Wayland clients since they don't control their
position, but X clients do and we'd be sending outdated coordinates if a
client is moving a window in response to motion events.

This was already done already, but now move the Xwayland specific logic
to the Xwayland surface role, keeping the generic transformation logic
in the generic actor surface role.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
This commit is contained in:
Jonas Ådahl
2019-10-09 09:47:23 +02:00
committed by Robert Mader
parent c0c74484bc
commit 54194e67e3
4 changed files with 48 additions and 26 deletions

View File

@@ -325,6 +325,23 @@ meta_wayland_actor_surface_is_on_logical_monitor (MetaWaylandSurfaceRole *surfac
return is_on_monitor;
}
static void
meta_wayland_actor_surface_get_relative_coordinates (MetaWaylandSurfaceRole *surface_role,
float abs_x,
float abs_y,
float *out_sx,
float *out_sy)
{
MetaWaylandActorSurface *actor_surface =
META_WAYLAND_ACTOR_SURFACE (surface_role);
MetaWaylandActorSurfacePrivate *priv =
meta_wayland_actor_surface_get_instance_private (actor_surface);
clutter_actor_transform_stage_point (CLUTTER_ACTOR (priv->actor),
abs_x, abs_y,
out_sx, out_sy);
}
static void
meta_wayland_actor_surface_init (MetaWaylandActorSurface *actor_surface)
{
@@ -348,6 +365,8 @@ meta_wayland_actor_surface_class_init (MetaWaylandActorSurfaceClass *klass)
surface_role_class->apply_state = meta_wayland_actor_surface_apply_state;
surface_role_class->is_on_logical_monitor =
meta_wayland_actor_surface_is_on_logical_monitor;
surface_role_class->get_relative_coordinates =
meta_wayland_actor_surface_get_relative_coordinates;
klass->sync_actor_state = meta_wayland_actor_surface_real_sync_actor_state;
}