Add interface to libinput object and move screen dimension callback to it

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
Jonas Ådahl 2013-11-17 19:31:34 +01:00
parent d894b1d700
commit 3450e49c86
4 changed files with 23 additions and 16 deletions

View file

@ -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;

View file

@ -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;
};

View file

@ -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

View file

@ -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