diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c index efccede83..d61603905 100644 --- a/src/wayland/meta-wayland-actor-surface.c +++ b/src/wayland/meta-wayland-actor-surface.c @@ -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; } diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index a17431853..d94e5b63a 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1592,33 +1592,12 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface, float *sx, float *sy) { - MetaWindow *window; + MetaWaylandSurfaceRoleClass *surface_role_class = + META_WAYLAND_SURFACE_ROLE_GET_CLASS (surface->role); - /* Using clutter 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. - */ - window = meta_wayland_surface_get_window (surface); - if (window && - window->client_type == META_WINDOW_CLIENT_TYPE_X11) - { - MetaRectangle window_rect; - - meta_window_get_buffer_rect (window, &window_rect); - *sx = abs_x - window_rect.x; - *sy = abs_y - window_rect.y; - } - else - { - ClutterActor *actor = - CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); - - clutter_actor_transform_stage_point (actor, abs_x, abs_y, sx, sy); - } + surface_role_class->get_relative_coordinates (surface->role, + abs_x, abs_y, + sx, sy); } void diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 5477eb99e..7420274d4 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -63,6 +63,11 @@ struct _MetaWaylandSurfaceRoleClass MetaWaylandSurface * (*get_toplevel) (MetaWaylandSurfaceRole *surface_role); gboolean (*should_cache_state) (MetaWaylandSurfaceRole *surface_role); void (*notify_subsurface_state_changed) (MetaWaylandSurfaceRole *surface_role); + void (*get_relative_coordinates) (MetaWaylandSurfaceRole *surface_role, + float abs_x, + float abs_y, + float *out_sx, + float *out_sy); }; struct _MetaWaylandSurfaceState diff --git a/src/wayland/meta-xwayland-surface.c b/src/wayland/meta-xwayland-surface.c index b1894ef8c..905b49afd 100644 --- a/src/wayland/meta-xwayland-surface.c +++ b/src/wayland/meta-xwayland-surface.c @@ -80,6 +80,23 @@ meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surfa } } +static void +meta_xwayland_surface_get_relative_coordinates (MetaWaylandSurfaceRole *surface_role, + float abs_x, + float abs_y, + float *out_sx, + float *out_sy) +{ + MetaWaylandSurface *surface = + meta_wayland_surface_role_get_surface (surface_role); + MetaRectangle window_rect; + + meta_window_get_buffer_rect (meta_wayland_surface_get_window (surface), + &window_rect); + *out_sx = abs_x - window_rect.x; + *out_sy = abs_y - window_rect.y; +} + static MetaWaylandSurface * meta_xwayland_surface_get_toplevel (MetaWaylandSurfaceRole *surface_role) { @@ -143,6 +160,8 @@ meta_xwayland_surface_class_init (MetaXwaylandSurfaceClass *klass) object_class->finalize = meta_xwayland_surface_finalize; + surface_role_class->get_relative_coordinates = + meta_xwayland_surface_get_relative_coordinates; surface_role_class->get_toplevel = meta_xwayland_surface_get_toplevel; actor_surface_class->get_geometry_scale =