Move coordinate transformation to pick_surface().
This commit is contained in:
parent
e96dcb8f93
commit
7e972a5b18
@ -567,7 +567,7 @@ const static struct wl_compositor_interface compositor_interface = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct egl_surface *
|
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_compositor *ec = device->ec;
|
||||||
struct egl_surface *es;
|
struct egl_surface *es;
|
||||||
@ -586,6 +586,10 @@ pick_surface(struct wlsc_input_device *device)
|
|||||||
|
|
||||||
es = container_of(es->link.prev,
|
es = container_of(es->link.prev,
|
||||||
struct egl_surface, link);
|
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;
|
return NULL;
|
||||||
@ -611,14 +615,10 @@ notify_motion(struct wlsc_input_device *device, int x, int y)
|
|||||||
if (y >= ec->height)
|
if (y >= ec->height)
|
||||||
y = ec->height - 1;
|
y = ec->height - 1;
|
||||||
|
|
||||||
es = pick_surface(device);
|
es = pick_surface(device, &sx, &sy);
|
||||||
|
if (es)
|
||||||
if (es) {
|
|
||||||
sx = (x - es->map.x) * es->width / es->map.width;
|
|
||||||
sy = (y - es->map.y) * es->height / es->map.height;
|
|
||||||
wl_surface_post_event(&es->base, &device->base,
|
wl_surface_post_event(&es->base, &device->base,
|
||||||
WL_INPUT_MOTION, x, y, sx, sy);
|
WL_INPUT_MOTION, x, y, sx, sy);
|
||||||
}
|
|
||||||
|
|
||||||
device->x = x;
|
device->x = x;
|
||||||
device->y = y;
|
device->y = y;
|
||||||
@ -639,7 +639,7 @@ notify_button(struct wlsc_input_device *device,
|
|||||||
if (!ec->vt_active)
|
if (!ec->vt_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
es = pick_surface(device);
|
es = pick_surface(device, &sx, &sy);
|
||||||
if (es) {
|
if (es) {
|
||||||
wl_list_remove(&es->link);
|
wl_list_remove(&es->link);
|
||||||
wl_list_insert(device->ec->surface_list.prev, &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--;
|
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? */
|
/* FIXME: Swallow click on raise? */
|
||||||
wl_surface_post_event(&es->base, &device->base,
|
wl_surface_post_event(&es->base, &device->base,
|
||||||
WL_INPUT_BUTTON, button, state,
|
WL_INPUT_BUTTON, button, state,
|
||||||
|
Loading…
Reference in New Issue
Block a user