From 773d13b5432a76267d5286100f23ae0d1d8eb8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 21 Dec 2011 15:15:08 -0500 Subject: [PATCH] compositor: Make surface picking not depend on an input device --- compositor/compositor.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/compositor/compositor.c b/compositor/compositor.c index 4dc99cb3..844d59df 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -1070,25 +1070,33 @@ wlsc_surface_transform(struct wlsc_surface *surface, *sy = y - surface->y; } -WL_EXPORT struct wlsc_surface * -pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy) +static struct wlsc_surface * +wlsc_compositor_pick_surface(struct wlsc_compositor *compositor, + int32_t x, int32_t y, int32_t *sx, int32_t *sy) { - struct wlsc_input_device *wd = (struct wlsc_input_device *) device; - struct wlsc_compositor *ec = wd->compositor; - struct wlsc_surface *es; + struct wlsc_surface *surface; - wl_list_for_each(es, &ec->surface_list, link) { - if (es->surface.resource.client == NULL) + wl_list_for_each(surface, &compositor->surface_list, link) { + if (surface->surface.resource.client == NULL) continue; - wlsc_surface_transform(es, device->x, device->y, sx, sy); - if (0 <= *sx && *sx < es->width && - 0 <= *sy && *sy < es->height) - return es; + wlsc_surface_transform(surface, x, y, sx, sy); + if (0 <= *sx && *sx < surface->width && + 0 <= *sy && *sy < surface->height) + return surface; } return NULL; } +WL_EXPORT struct wlsc_surface * +pick_surface(struct wl_input_device *device, int32_t *sx, int32_t *sy) +{ + struct wlsc_input_device *wd = (struct wlsc_input_device *) device; + + return wlsc_compositor_pick_surface(wd->compositor, + device->x, device->y, sx, sy); +} + static void implicit_grab_motion(struct wl_grab *grab,