summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2015-06-17 10:16:02 +0800
committerJonas Ådahl <jadahl@gmail.com>2016-02-16 19:02:47 +0800
commitbc8ec2d90d5f39f34ccf1548d6cb0e7dbd8214a7 (patch)
tree884a8a4f8ce1ff15dd1f3edf5f88ef6a558a72db
parent5b0eabec51cbb08e2ded9133740cd1418afa75b7 (diff)
downloadmutter-bc8ec2d90d5f39f34ccf1548d6cb0e7dbd8214a7.tar.gz
wayland: Add global to surface coordinate helper
https://bugzilla.gnome.org/show_bug.cgi?id=744104
-rw-r--r--src/wayland/meta-wayland-pointer.c7
-rw-r--r--src/wayland/meta-wayland-surface.c15
-rw-r--r--src/wayland/meta-wayland-surface.h6
3 files changed, 24 insertions, 4 deletions
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index ef3228ec4..663e35f7d 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -924,11 +924,10 @@ meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer,
ClutterPoint pos;
clutter_input_device_get_coords (pointer->device, NULL, &pos);
- clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor)),
- pos.x, pos.y, &xf, &yf);
+ meta_wayland_surface_get_relative_coordinates (surface, pos.x, pos.y, &xf, &yf);
- *sx = wl_fixed_from_double (xf) / surface->scale;
- *sy = wl_fixed_from_double (yf) / surface->scale;
+ *sx = wl_fixed_from_double (xf);
+ *sy = wl_fixed_from_double (yf);
}
static void
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index cab05df57..29465e709 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -2417,6 +2417,21 @@ meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface)
return NULL;
}
+void
+meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
+ float abs_x,
+ float abs_y,
+ float *sx,
+ float *sy)
+{
+ ClutterActor *actor =
+ CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor));
+
+ clutter_actor_transform_stage_point (actor, abs_x, abs_y, sx, sy);
+ *sx /= surface->scale;
+ *sy /= surface->scale;
+}
+
static void
meta_wayland_surface_init (MetaWaylandSurface *surface)
{
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 7a5ec6d32..6f3c1e853 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -253,6 +253,12 @@ void meta_wayland_surface_queue_pending_frame_callbacks (MetaWayl
void meta_wayland_surface_queue_pending_state_frame_callbacks (MetaWaylandSurface *surface,
MetaWaylandPendingState *pending);
+void meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
+ float abs_x,
+ float abs_y,
+ float *sx,
+ float *sy);
+
MetaWaylandSurface * meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role);
#endif