From c007b9aa435bb04066874fada4e5ef35147a3f4d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 22 May 2015 15:16:31 +1000 Subject: [PATCH libinput 03/10] touchpad: add helper function to get from tp to the libinput context Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede Tested-by: Benjamin Tissoires --- src/evdev-mt-touchpad-buttons.c | 8 ++++---- src/evdev-mt-touchpad-edge-scroll.c | 12 ++++++------ src/evdev-mt-touchpad-tap.c | 10 +++++----- src/evdev-mt-touchpad.c | 8 ++++---- src/evdev-mt-touchpad.h | 6 ++++++ 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index d6acbf0..2f24ee6 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -392,7 +392,7 @@ tp_button_handle_event(struct tp_dispatch *tp, enum button_event event, uint64_t time) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); enum button_state current = t->button.state; switch(t->button.state) { @@ -478,7 +478,7 @@ tp_process_button(struct tp_dispatch *tp, const struct input_event *e, uint64_t time) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); uint32_t mask = 1 << (e->code - BTN_LEFT); /* Ignore other buttons on clickpads */ @@ -680,7 +680,7 @@ int tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); struct tp_touch *t; int width, height; double diagonal; @@ -731,7 +731,7 @@ tp_init_buttons(struct tp_dispatch *tp, tp_for_each_touch(tp, t) { t->button.state = BUTTON_STATE_NONE; libinput_timer_init(&t->button.timer, - tp->device->base.seat->libinput, + tp_libinput_context(tp), tp_button_handle_timeout, t); } diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 369fded..9bf3f0c 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -121,7 +121,7 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case SCROLL_EVENT_TOUCH: @@ -149,7 +149,7 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case SCROLL_EVENT_TOUCH: @@ -178,7 +178,7 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case SCROLL_EVENT_TOUCH: @@ -209,7 +209,7 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case SCROLL_EVENT_TOUCH: @@ -232,7 +232,7 @@ tp_edge_scroll_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum scroll_event event) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); enum tp_edge_scroll_touch_state current = t->scroll.edge_state; switch (current) { @@ -301,7 +301,7 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device) tp_for_each_touch(tp, t) { t->scroll.direction = -1; libinput_timer_init(&t->scroll.timer, - device->base.seat->libinput, + tp_libinput_context(tp), tp_edge_scroll_handle_timeout, t); } diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 61f94e5..21b2e29 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -146,7 +146,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case TAP_EVENT_TOUCH: @@ -222,7 +222,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case TAP_EVENT_MOTION: @@ -456,7 +456,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); switch (event) { case TAP_EVENT_RELEASE: @@ -549,7 +549,7 @@ tp_tap_handle_event(struct tp_dispatch *tp, enum tap_event event, uint64_t time) { - struct libinput *libinput = tp->device->base.seat->libinput; + struct libinput *libinput = tp_libinput_context(tp); enum tp_tap_state current; current = tp->tap.state; @@ -826,7 +826,7 @@ tp_init_tap(struct tp_dispatch *tp) tp->tap.enabled = tp_tap_default(tp->device); libinput_timer_init(&tp->tap.timer, - tp->device->base.seat->libinput, + tp_libinput_context(tp), tp_tap_handle_timeout, tp); return 0; diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 26edcb4..6c0daf0 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -775,7 +775,7 @@ tp_release_fake_touches(struct tp_dispatch *tp) static void tp_clear_state(struct tp_dispatch *tp) { - uint64_t now = libinput_now(tp->device->base.seat->libinput); + uint64_t now = libinput_now(tp_libinput_context(tp)); struct tp_touch *t; /* Unroll the touchpad state. @@ -1178,7 +1178,7 @@ tp_scroll_config_scroll_method_set_method(struct libinput_device *device, { struct evdev_device *evdev = (struct evdev_device*)device; struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; - uint64_t time = libinput_now(device->seat->libinput); + uint64_t time = libinput_now(tp_libinput_context(tp)); if (method == tp->scroll.method) return LIBINPUT_CONFIG_STATUS_SUCCESS; @@ -1279,11 +1279,11 @@ tp_init_sendevents(struct tp_dispatch *tp, struct evdev_device *device) { libinput_timer_init(&tp->sendevents.trackpoint_timer, - tp->device->base.seat->libinput, + tp_libinput_context(tp), tp_trackpoint_timeout, tp); libinput_timer_init(&tp->dwt.keyboard_timer, - tp->device->base.seat->libinput, + tp_libinput_context(tp), tp_keyboard_timeout, tp); return 0; } diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 70b35f4..f8c837d 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -292,6 +292,12 @@ struct tp_dispatch { #define tp_for_each_touch(_tp, _t) \ for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++) +static inline struct libinput* +tp_libinput_context(struct tp_dispatch *tp) +{ + return tp->device->base.seat->libinput; +} + static inline struct normalized_coords tp_normalize_delta(struct tp_dispatch *tp, struct device_float_coords delta) { -- 2.4.1