On Thu, Feb 06, 2014 at 10:27:54PM +0100, Jonas Ådahl wrote:
> Since a Wayland compositor have to represent all touch devices of a seat
> as one virtual device, lets make that easier by making the slots of
> touch events seat wide unique.

is this really something we want to expose from libinput? it seems odd,
given that everything else is per-device and even seats themselves are
almost second-class citizens - i.e. you don't have to care about them at all
if you don't need them.

I don't think tying slot number to seats is a good idea here.

Cheers,
   Peter

> 
> Signed-off-by: Jonas Ådahl <[email protected]>
> ---
>  src/evdev.c            | 24 +++++++++++++++++++++---
>  src/evdev.h            |  3 +++
>  src/libinput-private.h |  1 +
>  src/libinput.h         |  4 ++--
>  4 files changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 2bc301b..80210fb 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -109,7 +109,9 @@ evdev_flush_pending_event(struct evdev_device *device, 
> uint32_t time)
>  {
>       int32_t cx, cy;
>       int slot;
> +     uint32_t seat_slot;
>       struct libinput_device *base = &device->base;
> +     struct libinput_seat *seat = base->seat;
>  
>       slot = device->mt.slot;
>  
> @@ -128,9 +130,13 @@ 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;
> +             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);
> @@ -139,6 +145,8 @@ 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;
> +
>               touch_notify_touch(base,
>                                  time,
>                                  slot,
> @@ -150,9 +158,12 @@ 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;
> +             seat->slot_map &= ~(1 << seat_slot);
> +
>               touch_notify_touch(base,
>                                  time,
> -                                slot,
> +                                seat_slot,
>                                  0, 0,
>                                  LIBINPUT_TOUCH_TYPE_UP);
>               break;
> @@ -160,6 +171,10 @@ 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;
> +             seat->slot_map |= 1 << seat_slot;
> +
>               transform_absolute(device, &cx, &cy);
>               touch_notify_touch(base,
>                                  time,
> @@ -173,7 +188,7 @@ evdev_flush_pending_event(struct evdev_device *device, 
> uint32_t time)
>               if (device->seat_caps & EVDEV_DEVICE_TOUCH) {
>                       touch_notify_touch(base,
>                                          time,
> -                                        slot,
> +                                        device->abs.seat_slot,
>                                          li_fixed_from_int(cx),
>                                          li_fixed_from_int(cy),
>                                          LIBINPUT_TOUCH_TYPE_DOWN);
> @@ -188,6 +203,9 @@ 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;
> +             seat->slot_map &= ~(1 << seat_slot);
> +
>               touch_notify_touch(base,
>                                  time,
>                                  0, 0, 0, LIBINPUT_TOUCH_TYPE_UP);
> diff --git a/src/evdev.h b/src/evdev.h
> index 37c32e5..b0feb28 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -64,6 +64,8 @@ struct evdev_device {
>               int min_x, max_x, min_y, max_y;
>               int32_t x, y;
>  
> +             uint32_t seat_slot;
> +
>               int apply_calibration;
>               float calibration[6];
>       } abs;
> @@ -71,6 +73,7 @@ struct evdev_device {
>       struct {
>               int slot;
>               struct {
> +                     uint32_t seat_slot;
>                       int32_t x, y;
>               } slots[MAX_SLOTS];
>       } mt;
> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index 0d7de90..2eea012 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -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;
> diff --git a/src/libinput.h b/src/libinput.h
> index e2d83bf..9cd9d5b 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -568,8 +568,8 @@ libinput_event_touch_get_time(
>  /**
>   * @ingroup event_touch
>   *
> - * Get the currently active slot on this device. See the kernel's multitouch
> - * protocol B documentation for more information.
> + * Get the slot of the touch event. A slot is a seat wide unique identifyer
> + * of a touch point.
>   *
>   * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
>   *
> -- 
> 1.8.3.2
> 
> _______________________________________________
> wayland-devel mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to