[PATCH libinput 1/6] Store the backend type in the interface

Peter Hutterer peter.hutterer at who-t.net
Thu Feb 6 13:38:07 PST 2014


On Thu, Feb 06, 2014 at 10:11:34PM +0100, Jonas Ådahl wrote:
> On Thu, Feb 06, 2014 at 02:13:05PM +1000, Peter Hutterer wrote:
> > This enables us to prevent callers from calling backend-specific functions on
> > mismatching backends.
> 
> This can be done instead by comparing the backend interface pointer in
> struct libinput to the one defined in either path.c or udev-seat.c.
> 
> if (libinput->interface_backend != &interface_backend) {
> 	log(...);
> 	return NULL;
> }
> 
> I think doing it like that is preferred, since we should avoid
> per-backend logic in the front end anyway.

ok, no problem. amended locally, and that drops this patch completely and
replaces it with the above condition in 3/6.

Cheers,
   Peter

> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  src/libinput-private.h | 6 ++++++
> >  src/path.c             | 1 +
> >  src/udev-seat.c        | 1 +
> >  3 files changed, 8 insertions(+)
> > 
> > diff --git a/src/libinput-private.h b/src/libinput-private.h
> > index 0d7de90..ee5a17d 100644
> > --- a/src/libinput-private.h
> > +++ b/src/libinput-private.h
> > @@ -26,7 +26,13 @@
> >  #include "libinput.h"
> >  #include "libinput-util.h"
> >  
> > +enum libinput_backend_type {
> > +	BACKEND_UDEV,
> > +	BACKEND_PATH,
> > +};
> > +
> >  struct libinput_interface_backend {
> > +	enum libinput_backend_type backend_type;
> >  	int (*resume)(struct libinput *libinput);
> >  	void (*suspend)(struct libinput *libinput);
> >  	void (*destroy)(struct libinput *libinput);
> > diff --git a/src/path.c b/src/path.c
> > index de2ca49..4924b31 100644
> > --- a/src/path.c
> > +++ b/src/path.c
> > @@ -167,6 +167,7 @@ path_input_destroy(struct libinput *input)
> >  }
> >  
> >  static const struct libinput_interface_backend interface_backend = {
> > +	.backend_type = BACKEND_PATH,
> >  	.resume = path_input_enable,
> >  	.suspend = path_input_disable,
> >  	.destroy = path_input_destroy,
> > diff --git a/src/udev-seat.c b/src/udev-seat.c
> > index 957e762..b564c83 100644
> > --- a/src/udev-seat.c
> > +++ b/src/udev-seat.c
> > @@ -330,6 +330,7 @@ udev_seat_get_named(struct udev_input *input, const char *seat_name)
> >  }
> >  
> >  static const struct libinput_interface_backend interface_backend = {
> > +	.backend_type = BACKEND_UDEV,
> >  	.resume = udev_input_enable,
> >  	.suspend = udev_input_disable,
> >  	.destroy = udev_input_destroy,
> > -- 
> > 1.8.4.2


More information about the wayland-devel mailing list