summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-12-21 17:26:00 -0500
committerKristian Høgsberg <krh@redhat.com>2008-12-21 17:26:00 -0500
commit7e972a5b18883befec4f987b986eafc9cb5cc0a0 (patch)
tree5ea7aa5d2fc17f6447f8d56e045723420b0cf0c0
parente96dcb8f93565fd6d4ef49ccc6e03e9e70ed3ef6 (diff)
downloadwayland-7e972a5b18883befec4f987b986eafc9cb5cc0a0.tar.gz
wayland-7e972a5b18883befec4f987b986eafc9cb5cc0a0.tar.xz
wayland-7e972a5b18883befec4f987b986eafc9cb5cc0a0.zip
Move coordinate transformation to pick_surface().
-rw-r--r--wayland-system-compositor.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/wayland-system-compositor.c b/wayland-system-compositor.c
index e54b01f..a394893 100644
--- a/wayland-system-compositor.c
+++ b/wayland-system-compositor.c
@@ -567,7 +567,7 @@ const static struct wl_compositor_interface compositor_interface = {
};
static struct egl_surface *
-pick_surface(struct wlsc_input_device *device)
+pick_surface(struct wlsc_input_device *device, int32_t *sx, int32_t *sy)
{
struct egl_compositor *ec = device->ec;
struct egl_surface *es;
@@ -586,6 +586,10 @@ pick_surface(struct wlsc_input_device *device)
es = container_of(es->link.prev,
struct egl_surface, link);
+
+ /* Transform to surface coordinates. */
+ *sx = (x - es->map.x) * es->width / es->map.width;
+ *sy = (y - es->map.y) * es->height / es->map.height;
}
return NULL;
@@ -611,14 +615,10 @@ notify_motion(struct wlsc_input_device *device, int x, int y)
if (y >= ec->height)
y = ec->height - 1;
- es = pick_surface(device);
-
- if (es) {
- sx = (x - es->map.x) * es->width / es->map.width;
- sy = (y - es->map.y) * es->height / es->map.height;
+ es = pick_surface(device, &sx, &sy);
+ if (es)
wl_surface_post_event(&es->base, &device->base,
WL_INPUT_MOTION, x, y, sx, sy);
- }
device->x = x;
device->y = y;
@@ -639,7 +639,7 @@ notify_button(struct wlsc_input_device *device,
if (!ec->vt_active)
return;
- es = pick_surface(device);
+ es = pick_surface(device, &sx, &sy);
if (es) {
wl_list_remove(&es->link);
wl_list_insert(device->ec->surface_list.prev, &es->link);
@@ -654,9 +654,6 @@ notify_button(struct wlsc_input_device *device,
device->grab--;
}
- sx = (device->x - es->map.x) * es->width / es->map.width;
- sy = (device->y - es->map.y) * es->height / es->map.height;
-
/* FIXME: Swallow click on raise? */
wl_surface_post_event(&es->base, &device->base,
WL_INPUT_BUTTON, button, state,