[PATCH libinput] Make touch event slots seat wide

Jonas Ådahl jadahl at gmail.com
Mon Feb 10 01:11:47 PST 2014


On Mon, Feb 10, 2014 at 03:13:55PM +1000, Peter Hutterer wrote:
> 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.

I think it could be good to have libinput help out with virtual seat
devices, such as ways to avoid double button and key presses,
overlapping touch point slots, etc, as this is as well something that
would otherwise need to be duplicated in almost every (seat aware)
application.

Regarding seat slots, it's more convenient to manage these in libinput
since we already do keep track of per slot state, and with this patch,
at least weston doesn't need to be aware of per-device slots at all.

What do you think of providing this but not via the _get_slot()
function?

As a side note, making slots seat wide does not make them any less
device wide.


Jonas

> 
> Cheers,
>    Peter
> 
> > 
> > Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
> > ---
> >  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
> > wayland-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> > 


More information about the wayland-devel mailing list