touchpad: add helper function to get from tp to the libinput context
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 22 May 2015 05:16:31 +0000 (15:16 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 27 May 2015 07:38:25 +0000 (17:38 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
src/evdev-mt-touchpad-buttons.c
src/evdev-mt-touchpad-edge-scroll.c
src/evdev-mt-touchpad-tap.c
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h

index 43e983b295c48a31ede18316cd445d3f36bc4880..09ea6d7a915af51c58537414ff5a6773aabda1c1 100644 (file)
@@ -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);
        }
 
index 369fdedc256a7ed81201453f7f35d0ea457dfba0..9bf3f0c038e9d408b919fc15b57ee22c247859c4 100644 (file)
@@ -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);
        }
 
index fb8c9e432f45c08e4ecd5ee3b4c01f9e69ea8428..bb7c894527947e866aaa511a2297a9a0ebd0331f 100644 (file)
@@ -147,7 +147,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:
@@ -223,7 +223,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:
@@ -483,7 +483,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:
@@ -576,7 +576,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;
@@ -857,7 +857,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;
index 6bd8d1d9300e504961310742f6798226ef1bb837..1ea3bcec624619cdbda92c535a3bf17968dc7f35 100644 (file)
@@ -810,7 +810,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.
@@ -1251,7 +1251,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;
@@ -1352,11 +1352,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;
 }
index f6c5aff015ce3996db6b39dad4c175d2fc41cd85..1b644e0b7dc080f8216c82b6da31375cdc553e3f 100644 (file)
@@ -295,6 +295,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)
 {