mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-26 21:30:13 +01:00
Add seat wide slot to touch events
Since a Wayland compositor have to represent all touch devices of a seat as one virtual device, lets make that easier by also providing seat wide slots with touch events. Seat wide slots may be accessed using libinput_event_touch_get_seat_slot(). Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
parent
bc06973c2e
commit
e80cff7b0e
6 changed files with 80 additions and 1 deletions
48
src/evdev.c
48
src/evdev.c
|
|
@ -110,7 +110,9 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
{
|
||||
int32_t cx, cy;
|
||||
int slot;
|
||||
int seat_slot;
|
||||
struct libinput_device *base = &device->base;
|
||||
struct libinput_seat *seat = base->seat;
|
||||
|
||||
slot = device->mt.slot;
|
||||
|
||||
|
|
@ -129,9 +131,18 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
|
||||
break;
|
||||
|
||||
seat_slot = ffs(~seat->slot_map) - 1;
|
||||
device->mt.slots[slot].seat_slot = seat_slot;
|
||||
|
||||
if (seat_slot == -1)
|
||||
break;
|
||||
|
||||
seat->slot_map |= 1 << seat_slot;
|
||||
|
||||
touch_notify_touch(base,
|
||||
time,
|
||||
slot,
|
||||
seat_slot,
|
||||
li_fixed_from_int(device->mt.slots[slot].x),
|
||||
li_fixed_from_int(device->mt.slots[slot].y),
|
||||
LIBINPUT_TOUCH_TYPE_DOWN);
|
||||
|
|
@ -140,9 +151,15 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
|
||||
break;
|
||||
|
||||
seat_slot = device->mt.slots[slot].seat_slot;
|
||||
|
||||
if (seat_slot == -1)
|
||||
break;
|
||||
|
||||
touch_notify_touch(base,
|
||||
time,
|
||||
slot,
|
||||
seat_slot,
|
||||
li_fixed_from_int(device->mt.slots[slot].x),
|
||||
li_fixed_from_int(device->mt.slots[slot].y),
|
||||
LIBINPUT_TOUCH_TYPE_MOTION);
|
||||
|
|
@ -151,9 +168,17 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
|
||||
break;
|
||||
|
||||
seat_slot = device->mt.slots[slot].seat_slot;
|
||||
|
||||
if (seat_slot == -1)
|
||||
break;
|
||||
|
||||
seat->slot_map &= ~(1 << seat_slot);
|
||||
|
||||
touch_notify_touch(base,
|
||||
time,
|
||||
slot,
|
||||
seat_slot,
|
||||
0, 0,
|
||||
LIBINPUT_TOUCH_TYPE_UP);
|
||||
break;
|
||||
|
|
@ -161,10 +186,19 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
|
||||
break;
|
||||
|
||||
seat_slot = ffs(~seat->slot_map) - 1;
|
||||
device->abs.seat_slot = seat_slot;
|
||||
|
||||
if (seat_slot == -1)
|
||||
break;
|
||||
|
||||
seat->slot_map |= 1 << seat_slot;
|
||||
|
||||
transform_absolute(device, &cx, &cy);
|
||||
touch_notify_touch(base,
|
||||
time,
|
||||
-1,
|
||||
seat_slot,
|
||||
li_fixed_from_int(cx),
|
||||
li_fixed_from_int(cy),
|
||||
LIBINPUT_TOUCH_TYPE_DOWN);
|
||||
|
|
@ -172,9 +206,15 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
case EVDEV_ABSOLUTE_MOTION:
|
||||
transform_absolute(device, &cx, &cy);
|
||||
if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
|
||||
seat_slot = device->abs.seat_slot;
|
||||
|
||||
if (seat_slot == -1)
|
||||
break;
|
||||
|
||||
touch_notify_touch(base,
|
||||
time,
|
||||
-1,
|
||||
seat_slot,
|
||||
li_fixed_from_int(cx),
|
||||
li_fixed_from_int(cy),
|
||||
LIBINPUT_TOUCH_TYPE_DOWN);
|
||||
|
|
@ -189,9 +229,17 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
|
|||
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
|
||||
break;
|
||||
|
||||
seat_slot = device->abs.seat_slot;
|
||||
|
||||
if (seat_slot == -1)
|
||||
break;
|
||||
|
||||
seat->slot_map &= ~(1 << seat_slot);
|
||||
|
||||
touch_notify_touch(base,
|
||||
time,
|
||||
-1,
|
||||
seat_slot,
|
||||
0, 0,
|
||||
LIBINPUT_TOUCH_TYPE_UP);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ struct evdev_device {
|
|||
int min_x, max_x, min_y, max_y;
|
||||
int32_t x, y;
|
||||
|
||||
int32_t seat_slot;
|
||||
|
||||
int apply_calibration;
|
||||
float calibration[6];
|
||||
} abs;
|
||||
|
|
@ -73,6 +75,7 @@ struct evdev_device {
|
|||
struct {
|
||||
int slot;
|
||||
struct {
|
||||
int32_t seat_slot;
|
||||
int32_t x, y;
|
||||
} slots[MAX_SLOTS];
|
||||
} mt;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ struct libinput_seat {
|
|||
struct list devices_list;
|
||||
void *user_data;
|
||||
int refcount;
|
||||
uint32_t slot_map;
|
||||
char *physical_name;
|
||||
char *logical_name;
|
||||
libinput_seat_destroy_func destroy;
|
||||
|
|
@ -155,6 +156,7 @@ void
|
|||
touch_notify_touch(struct libinput_device *device,
|
||||
uint32_t time,
|
||||
int32_t slot,
|
||||
int32_t seat_slot,
|
||||
li_fixed_t x,
|
||||
li_fixed_t y,
|
||||
enum libinput_touch_type touch_type);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ struct libinput_event_touch {
|
|||
struct libinput_event base;
|
||||
uint32_t time;
|
||||
int32_t slot;
|
||||
int32_t seat_slot;
|
||||
li_fixed_t x;
|
||||
li_fixed_t y;
|
||||
enum libinput_touch_type touch_type;
|
||||
|
|
@ -357,6 +358,12 @@ libinput_event_touch_get_slot(struct libinput_event_touch *event)
|
|||
return event->slot;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT int32_t
|
||||
libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
|
||||
{
|
||||
return event->seat_slot;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT li_fixed_t
|
||||
libinput_event_touch_get_x(struct libinput_event_touch *event)
|
||||
{
|
||||
|
|
@ -836,6 +843,7 @@ void
|
|||
touch_notify_touch(struct libinput_device *device,
|
||||
uint32_t time,
|
||||
int32_t slot,
|
||||
int32_t seat_slot,
|
||||
li_fixed_t x,
|
||||
li_fixed_t y,
|
||||
enum libinput_touch_type touch_type)
|
||||
|
|
@ -849,6 +857,7 @@ touch_notify_touch(struct libinput_device *device,
|
|||
*touch_event = (struct libinput_event_touch) {
|
||||
.time = time,
|
||||
.slot = slot,
|
||||
.seat_slot = seat_slot,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.touch_type = touch_type,
|
||||
|
|
|
|||
|
|
@ -577,6 +577,22 @@ libinput_event_touch_get_time(struct libinput_event_touch *event);
|
|||
int32_t
|
||||
libinput_event_touch_get_slot(struct libinput_event_touch *event);
|
||||
|
||||
/**
|
||||
* @ingroup event_touch
|
||||
*
|
||||
* Get the seat slot of the touch event. A seat slot is a non-negative seat
|
||||
* wide unique identifier of an active touch point.
|
||||
*
|
||||
* Events from single touch devices will be represented as one individual
|
||||
* touch point per device.
|
||||
*
|
||||
* @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
|
||||
*
|
||||
* @return The seat slot of the touch event
|
||||
*/
|
||||
int32_t
|
||||
libinput_event_touch_get_seat_slot(struct libinput_event_touch *event);
|
||||
|
||||
/**
|
||||
* @ingroup event_touch
|
||||
*
|
||||
|
|
|
|||
|
|
@ -336,9 +336,10 @@ print_touch_event(struct libinput_event *ev)
|
|||
|
||||
print_event_time(libinput_event_touch_get_time(t));
|
||||
|
||||
printf("%6s %d %5.2f/%5.2f\n",
|
||||
printf("%6s %d (%d) %5.2f/%5.2f\n",
|
||||
type,
|
||||
libinput_event_touch_get_slot(t),
|
||||
libinput_event_touch_get_seat_slot(t),
|
||||
li_fixed_to_double(x),
|
||||
li_fixed_to_double(y));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue