return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
-struct weston_surface *
+WL_EXPORT struct weston_surface *
weston_compositor_pick_surface(struct weston_compositor *compositor,
wl_fixed_t x, wl_fixed_t y,
wl_fixed_t *sx, wl_fixed_t *sy)
struct weston_pointer_grab;
struct weston_pointer_grab_interface {
- void (*focus)(struct weston_pointer_grab *grab,
- struct weston_surface *surface,
- wl_fixed_t x,
- wl_fixed_t y);
+ void (*focus)(struct weston_pointer_grab *grab);
void (*motion)(struct weston_pointer_grab *grab, uint32_t time);
void (*button)(struct weston_pointer_grab *grab,
uint32_t time, uint32_t button, uint32_t state);
}
static void
-drag_grab_focus(struct weston_pointer_grab *grab,
- struct weston_surface *surface, wl_fixed_t x, wl_fixed_t y)
+weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
+ wl_fixed_t sx, wl_fixed_t sy)
{
- struct weston_drag *drag =
- container_of(grab, struct weston_drag, grab);
+ struct weston_pointer *pointer = drag->grab.pointer;
struct wl_resource *resource, *offer = NULL;
struct wl_display *display;
uint32_t serial;
if (!drag->data_source && surface->resource.client != drag->client)
return;
- resource = find_resource(&drag->grab.pointer->seat->drag_resource_list,
+ resource = find_resource(&pointer->seat->drag_resource_list,
surface->resource.client);
if (!resource)
return;
offer = wl_data_source_send_offer(drag->data_source, resource);
wl_data_device_send_enter(resource, serial, &surface->resource,
- x, y, offer);
+ sx, sy, offer);
drag->focus = surface;
drag->focus_listener.notify = destroy_drag_focus;
}
static void
+drag_grab_focus(struct weston_pointer_grab *grab)
+{
+ struct weston_drag *drag =
+ container_of(grab, struct weston_drag, grab);
+ struct weston_pointer *pointer = grab->pointer;
+ struct weston_surface *surface;
+ wl_fixed_t sx, sy;
+
+ surface = weston_compositor_pick_surface(pointer->seat->compositor,
+ pointer->x, pointer->y,
+ &sx, &sy);
+ if (drag->focus != surface)
+ weston_drag_set_focus(drag, surface, sx, sy);
+}
+
+static void
drag_grab_motion(struct weston_pointer_grab *grab, uint32_t time)
{
struct weston_drag *drag =
wl_list_remove(&drag->icon_destroy_listener.link);
}
- drag_grab_focus(&drag->grab, NULL,
- wl_fixed_from_int(0), wl_fixed_from_int(0));
+ weston_drag_set_focus(drag, NULL, 0, 0);
weston_pointer_end_grab(drag->grab.pointer);
weston_seat_repick(struct weston_seat *seat)
{
const struct weston_pointer_grab_interface *interface;
- struct weston_surface *surface;
- struct weston_pointer *pointer = seat->pointer;
- wl_fixed_t sx, sy;
- if (!pointer)
+ if (seat->pointer == NULL)
return;
- surface = weston_compositor_pick_surface(seat->compositor,
- pointer->x,
- pointer->y,
- &sx, &sy);
-
- interface = pointer->grab->interface;
- interface->focus(pointer->grab, surface, sx, sy);
+ interface = seat->pointer->grab->interface;
+ interface->focus(seat->pointer->grab);
}
static void
}
static void
-default_grab_focus(struct weston_pointer_grab *grab,
- struct weston_surface *surface, wl_fixed_t x, wl_fixed_t y)
+default_grab_focus(struct weston_pointer_grab *grab)
{
struct weston_pointer *pointer = grab->pointer;
+ struct weston_surface *surface;
+ wl_fixed_t sx, sy;
if (pointer->button_count > 0)
return;
+ surface = weston_compositor_pick_surface(pointer->seat->compositor,
+ pointer->x, pointer->y,
+ &sx, &sy);
+
if (pointer->focus != surface)
- weston_pointer_set_focus(pointer, surface, x, y);
+ weston_pointer_set_focus(pointer, surface, sx, sy);
}
static void
struct weston_pointer_grab *grab)
{
const struct weston_pointer_grab_interface *interface;
- struct weston_compositor *compositor = pointer->seat->compositor;
- struct weston_surface *surface;
- wl_fixed_t sx, sy;
pointer->grab = grab;
interface = pointer->grab->interface;
grab->pointer = pointer;
-
- surface = weston_compositor_pick_surface(compositor,
- pointer->x, pointer->y,
- &sx, &sy);
-
- if (surface)
- interface->focus(pointer->grab, surface, sx, sy);
+ interface->focus(pointer->grab);
}
WL_EXPORT void
weston_pointer_end_grab(struct weston_pointer *pointer)
{
const struct weston_pointer_grab_interface *interface;
- struct weston_compositor *compositor = pointer->seat->compositor;
- struct weston_surface *surface;
- wl_fixed_t sx, sy;
-
- surface = weston_compositor_pick_surface(compositor,
- pointer->x, pointer->y,
- &sx, &sy);
pointer->grab = &pointer->default_grab;
interface = pointer->grab->interface;
- interface->focus(pointer->grab, surface, sx, sy);
+ interface->focus(pointer->grab);
}
WL_EXPORT void
ix, iy, NULL))
weston_output_update_zoom(output, ZOOM_FOCUS_POINTER);
- weston_seat_repick(seat);
-
if (pointer->sprite) {
weston_surface_set_position(pointer->sprite,
ix - pointer->hotspot_x,
move_pointer(seat, pointer->x + dx, pointer->y + dy);
interface = pointer->grab->interface;
+ interface->focus(pointer->grab);
interface->motion(pointer->grab, time);
}
move_pointer(seat, x, y);
interface = pointer->grab->interface;
+ interface->focus(pointer->grab);
interface->motion(pointer->grab, time);
}
}
static void
-noop_grab_focus(struct weston_pointer_grab *grab,
- struct weston_surface *surface, wl_fixed_t x, wl_fixed_t y)
+noop_grab_focus(struct weston_pointer_grab *grab)
{
}
}
static void
-busy_cursor_grab_focus(struct weston_pointer_grab *base,
- struct weston_surface *surface, int32_t x, int32_t y)
+busy_cursor_grab_focus(struct weston_pointer_grab *base)
{
struct shell_grab *grab = (struct shell_grab *) base;
+ struct weston_pointer *pointer = base->pointer;
+ struct weston_surface *surface;
+ wl_fixed_t sx, sy;
+
+ surface = weston_compositor_pick_surface(pointer->seat->compositor,
+ pointer->x, pointer->y,
+ &sx, &sy);
if (grab->shsurf->surface != surface) {
shell_grab_end(grab);
}
static void
-popup_grab_focus(struct weston_pointer_grab *grab,
- struct weston_surface *surface,
- wl_fixed_t x,
- wl_fixed_t y)
+popup_grab_focus(struct weston_pointer_grab *grab)
{
struct weston_pointer *pointer = grab->pointer;
+ struct weston_surface *surface;
struct shell_seat *shseat =
container_of(grab, struct shell_seat, popup_grab.grab);
struct wl_client *client = shseat->popup_grab.client;
+ wl_fixed_t sx, sy;
+
+ surface = weston_compositor_pick_surface(pointer->seat->compositor,
+ pointer->x, pointer->y,
+ &sx, &sy);
if (surface && surface->resource.client == client) {
- weston_pointer_set_focus(pointer, surface, x, y);
+ weston_pointer_set_focus(pointer, surface, sx, sy);
} else {
weston_pointer_set_focus(pointer, NULL,
wl_fixed_from_int(0),