#include "data_device_private.h"
static const struct ds_pointer_grab_interface drag_pointer_grab_iface;
+static const struct ds_touch_grab_interface drag_touch_grab_iface;
static const struct ds_keyboard_grab_interface drag_keyboard_grab_iface;
static void drag_destroy(struct ds_drag *drag);
}
WL_EXPORT void
-ds_drag_start_touch_drag(struct ds_drag *drag, uint32_t serial)
+ds_drag_start_touch_drag(struct ds_drag *drag, uint32_t serial,
+ struct ds_touch_point *point)
{
drag->grab_type = DS_DRAG_GRAB_KEYBOARD_TOUCH;
+ drag->grab_touch_id = ds_seat_touch_get_grab_id(drag->seat);
+ drag->touch_id = point->touch_id;
- // TODO
+ ds_seat_touch_start_grab(drag->seat, &drag->touch_grab);
+ drag_set_focus(drag, point->surface, point->sx, point->sy);
+
+ drag_start(drag, serial);
}
WL_EXPORT void
drag->pointer_grab.data = drag;
drag->pointer_grab.iface = &drag_pointer_grab_iface;
+ drag->touch_grab.data = drag;
+ drag->touch_grab.iface = &drag_touch_grab_iface;
+
drag->keyboard_grab.data = drag;
drag->keyboard_grab.iface = &drag_keyboard_grab_iface;
ds_seat_pointer_end_grab(drag->seat);
break;
case DS_DRAG_GRAB_KEYBOARD_TOUCH:
- // TODO
+ ds_seat_touch_end_grab(drag->seat);
break;
default:
case DS_DRAG_GRAB_KEYBOARD:
{
struct ds_drag *drag = grab->data;
struct ds_data_device *data_device;
- struct wl_resource *resource;
if (!drag->focused_surface || !drag->focused_client)
return;
data_device = data_device_for_seat_client(drag->data_device->manager,
drag->focused_client);
- if (data_device) {
- wl_resource_for_each(resource, &data_device->resources) {
- wl_data_device_send_motion(resource, time,
- wl_fixed_from_double(sx), wl_fixed_from_double(sy));
- }
- }
+ if (data_device)
+ data_device_send_drag_motion(data_device, time, sx, sy);
struct ds_event_drag_motion event = {
.drag = drag,
.cancel = drag_pointer_grab_iface_cancel,
};
+static uint32_t
+drag_touch_grab_iface_down(struct ds_seat_touch_grab *grab, uint32_t time_msec,
+ struct ds_touch_point *point)
+{
+ // eat the event
+ return 0;
+}
+
+static void
+drag_touch_grab_iface_up(struct ds_seat_touch_grab *grab, uint32_t time_msec,
+ struct ds_touch_point *point)
+{
+ struct ds_drag *drag = grab->data;
+
+ if (drag->grab_touch_id != point->touch_id)
+ return;
+
+ if (drag->focused_client)
+ drag_drop(drag, time_msec);
+
+ drag_destroy(drag);
+}
+
+static void
+drag_touch_grab_iface_motion(struct ds_seat_touch_grab *grab, uint32_t time_msec,
+ struct ds_touch_point *point)
+{
+ struct ds_drag *drag = grab->data;
+ struct ds_data_device *data_device;
+
+ if (!drag->focused_surface || !drag->focused_client)
+ return;
+
+ data_device = data_device_for_seat_client(drag->data_device->manager,
+ drag->focused_client);
+ if (data_device)
+ data_device_send_drag_motion(data_device, time_msec,
+ point->sx, point->sy);
+}
+
+static void
+drag_touch_grab_iface_enter(struct ds_seat_touch_grab *grab, uint32_t time_msec,
+ struct ds_touch_point *point)
+{
+ struct ds_drag *drag = grab->data;
+ drag_set_focus(drag, point->focused_surface, point->sx, point->sy);
+}
+
+static void
+drag_touch_grab_iface_cancel(struct ds_seat_touch_grab *grab)
+{
+ struct ds_drag *drag = grab->data;
+ drag_destroy(drag);
+}
+
+
+static const struct ds_touch_grab_interface drag_touch_grab_iface = {
+ .down = drag_touch_grab_iface_down,
+ .up = drag_touch_grab_iface_up,
+ .motion = drag_touch_grab_iface_motion,
+ .enter = drag_touch_grab_iface_enter,
+ .cancel = drag_touch_grab_iface_cancel,
+};
+
static void
drag_keyboard_grab_iface_enter(struct ds_seat_keyboard_grab *grab,
struct ds_surface *surface, uint32_t keycodes[], size_t num_keycodes,
}
WL_EXPORT void
+ds_seat_touch_start_grab(struct ds_seat *seat, struct ds_seat_touch_grab *grab)
+{
+ grab->seat = seat;
+ seat->touch.grab = grab;
+ wl_signal_emit(&seat->events.touch_grab_begin, grab);
+}
+
+WL_EXPORT void
+ds_seat_touch_end_grab(struct ds_seat *seat)
+{
+ struct ds_seat_touch *touch = &seat->touch;
+ struct ds_seat_touch_grab *grab = touch->grab;
+
+ if (grab != touch->default_grab) {
+ touch->grab = touch->default_grab;
+ wl_signal_emit(&seat->events.touch_grab_end, grab);
+ if (grab->iface->cancel)
+ grab->iface->cancel(grab);
+ }
+}
+
+WL_EXPORT void
ds_seat_touch_add_grab_start_listener(struct ds_seat *seat,
struct wl_listener *listener)
{
}
}
+uint32_t
+ds_seat_touch_get_grab_id(struct ds_seat *seat)
+{
+ return seat->touch.grab_id;
+}
+
bool
seat_touch_init(struct ds_seat *seat)
{