compositor: Make surface picking not depend on an input device

dev
Kristian Høgsberg 13 years ago
parent 325bb60792
commit 773d13b543
  1. 30
      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,

Loading…
Cancel
Save