From: Jonas Ådahl Date: Sun, 17 Nov 2013 18:31:34 +0000 (+0100) Subject: Add interface to libinput object and move screen dimension callback to it X-Git-Tag: 0.1.0~163^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3450e49c867e6f00db49f9093df75909147cce97;p=platform%2Fupstream%2Flibinput.git Add interface to libinput object and move screen dimension callback to it Signed-off-by: Jonas Ådahl --- diff --git a/src/evdev.c b/src/evdev.c index 0316c6f..55d8a15 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -227,13 +227,15 @@ evdev_process_touch(struct evdev_device *device, struct input_event *e, uint32_t time) { + struct libinput *libinput = device->base.libinput; int screen_width; int screen_height; - device->base.device_interface->get_current_screen_dimensions( + libinput->interface->get_current_screen_dimensions( + &device->base, &screen_width, &screen_height, - device->base.device_interface_data); + libinput->user_data); switch (e->code) { case ABS_MT_SLOT: @@ -270,13 +272,15 @@ static inline void evdev_process_absolute_motion(struct evdev_device *device, struct input_event *e) { + struct libinput *libinput = device->base.libinput; int screen_width; int screen_height; - device->base.device_interface->get_current_screen_dimensions( + libinput->interface->get_current_screen_dimensions( + &device->base, &screen_width, &screen_height, - device->base.device_interface_data); + libinput->user_data); switch (e->code) { case ABS_X: @@ -608,7 +612,6 @@ libinput_device_create_evdev( struct libinput *libinput, const char *devnode, int fd, - const struct libinput_device_interface *device_interface, void *user_data) { struct evdev_device *device; @@ -619,8 +622,7 @@ libinput_device_create_evdev( return NULL; device->base.libinput = libinput; - device->base.device_interface = device_interface; - device->base.device_interface_data = user_data; + device->base.user_data = user_data; device->seat_caps = 0; device->is_mt = 0; diff --git a/src/libinput-private.h b/src/libinput-private.h index e9a5aaa..f49badc 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -35,12 +35,14 @@ struct libinput { size_t events_len; size_t events_in; size_t events_out; + + const struct libinput_interface *interface; + void *user_data; }; struct libinput_device { struct libinput *libinput; - const struct libinput_device_interface *device_interface; - void *device_interface_data; + void *user_data; int terminated; }; diff --git a/src/libinput.c b/src/libinput.c index 0226b81..10d6fc1 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -81,7 +81,7 @@ libinput_remove_source(struct libinput *libinput, } LIBINPUT_EXPORT struct libinput * -libinput_create(void) +libinput_create(const struct libinput_interface *interface, void *user_data) { struct libinput *libinput; @@ -91,6 +91,9 @@ libinput_create(void) list_init(&libinput->source_destroy_list); + libinput->interface = interface; + libinput->user_data = user_data; + libinput->epoll_fd = epoll_create1(EPOLL_CLOEXEC);; if (libinput->epoll_fd < 0) return NULL; @@ -414,7 +417,7 @@ libinput_device_destroy(struct libinput_device *device) LIBINPUT_EXPORT void * libinput_device_get_user_data(struct libinput_device *device) { - return device->device_interface_data; + return device->user_data; } LIBINPUT_EXPORT void diff --git a/src/libinput.h b/src/libinput.h index ee6b98a..a051e4a 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -140,17 +140,18 @@ struct libinput_fd_handle; typedef void (*libinput_fd_callback)(int fd, void *data); -struct libinput_device_interface { - void (*get_current_screen_dimensions)(int *width, +struct libinput_interface { + void (*get_current_screen_dimensions)(struct libinput_device *device, + int *width, int *height, - void *data); + void *user_data); }; struct libinput; struct libinput_device; struct libinput * -libinput_create(void); +libinput_create(const struct libinput_interface *interface, void *user_data); int libinput_get_fd(struct libinput *libinput); @@ -168,7 +169,6 @@ struct libinput_device * libinput_device_create_evdev(struct libinput *libinput, const char *devnode, int fd, - const struct libinput_device_interface *interface, void *user_data); void