Merge branch 'master' into tablet-support
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 24 Jul 2015 00:56:05 +0000 (10:56 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 24 Jul 2015 00:56:05 +0000 (10:56 +1000)
19 files changed:
1  2 
configure.ac
doc/Makefile.am
src/evdev-mt-touchpad.c
src/evdev.c
src/evdev.h
src/libinput-private.h
src/libinput-util.h
src/libinput.c
src/libinput.h
src/libinput.sym
test/Makefile.am
test/device.c
test/litest.c
test/litest.h
test/misc.c
test/pointer.c
tools/event-debug.c
tools/event-gui.c
tools/libinput-list-devices.c

diff --cc configure.ac
Simple merge
diff --cc doc/Makefile.am
@@@ -20,9 -21,9 +21,10 @@@ header_files = 
        $(srcdir)/scrolling.dox \
        $(srcdir)/seats.dox \
        $(srcdir)/t440-support.dox \
 +      $(srcdir)/tablet-support.dox \
        $(srcdir)/tapping.dox \
-       $(srcdir)/test-suite.dox
+       $(srcdir)/test-suite.dox \
+       $(srcdir)/tools.dox
  
  diagram_files = \
        $(srcdir)/dot/seats-sketch.gv \
Simple merge
diff --cc src/evdev.c
Simple merge
diff --cc src/evdev.h
Simple merge
Simple merge
Simple merge
diff --cc src/libinput.c
Simple merge
diff --cc src/libinput.h
Simple merge
@@@ -163,30 -162,9 +163,37 @@@ LIBINPUT_0.20.0 
        libinput_event_get_gesture_event;
  } LIBINPUT_0.19.0;
  
- } LIBINPUT_0.20.0;
+ LIBINPUT_0.21.0 {
+       libinput_device_config_dwt_is_available;
+       libinput_device_config_dwt_set_enabled;
+       libinput_device_config_dwt_get_enabled;
+       libinput_device_config_dwt_get_default_enabled;
+ } LIBINPUT_0.20.0;
++
 +/* tablet APIs, they are not part of any stable API promise yet.
 + * keep them separate */
 +LIBINPUT_TABLET_SUPPORT {
 +      libinput_event_get_tablet_event;
 +      libinput_event_tablet_axis_has_changed;
 +      libinput_event_tablet_get_axis_delta;
 +      libinput_event_tablet_get_axis_delta_discrete;
 +      libinput_event_tablet_get_axis_value;
 +      libinput_event_tablet_get_base_event;
 +      libinput_event_tablet_get_button;
 +      libinput_event_tablet_get_button_state;
 +      libinput_event_tablet_get_proximity_state;
 +      libinput_event_tablet_get_seat_button_count;
 +      libinput_event_tablet_get_time;
 +      libinput_event_tablet_get_tool;
 +      libinput_event_tablet_get_x_transformed;
 +      libinput_event_tablet_get_y_transformed;
 +      libinput_tool_get_serial;
 +      libinput_tool_get_tool_id;
 +      libinput_tool_get_type;
 +      libinput_tool_get_user_data;
 +      libinput_tool_has_button;
 +      libinput_tool_has_axis;
 +      libinput_tool_ref;
 +      libinput_tool_set_user_data;
 +      libinput_tool_unref;
++} LIBINPUT_0.21.0;
@@@ -60,8 -55,9 +60,10 @@@ endi
  run_tests = \
        test-touchpad \
        test-touchpad-tap \
+       test-touchpad-buttons \
 +      test-tablet \
        test-device \
+       test-gestures \
        test-pointer \
        test-touch \
        test-trackpoint \
diff --cc test/device.c
@@@ -1009,22 -1009,27 +1009,43 @@@ START_TEST(device_udev_tag_apple
  }
  END_TEST
  
+ START_TEST(device_udev_tag_synaptics_serial)
+ {
+       struct litest_device *dev = litest_current_device();
+       struct libinput_device *device = dev->libinput_device;
+       struct udev_device *d;
+       const char *prop;
+       d = libinput_device_get_udev_device(device);
+       prop = udev_device_get_property_value(d,
+                                             "LIBINPUT_MODEL_SYNAPTICS_SERIAL_TOUCHPAD");
+       if (libevdev_get_id_vendor(dev->evdev) == VENDOR_ID_SYNAPTICS_SERIAL &&
+           libevdev_get_id_product(dev->evdev) == PRODUCT_ID_SYNAPTICS_SERIAL)
+               ck_assert_notnull(prop);
+       else
+               ck_assert(prop == NULL);
+       udev_device_unref(d);
+ }
+ END_TEST
 +START_TEST(device_udev_tag_wacom_tablet)
 +{
 +      struct litest_device *dev = litest_current_device();
 +      struct libinput_device *device = dev->libinput_device;
 +      struct udev_device *d;
 +      const char *prop;
 +
 +      d = libinput_device_get_udev_device(device);
 +      prop = udev_device_get_property_value(d,
 +                                            "ID_INPUT_TABLET");
 +
 +      ck_assert_notnull(prop);
 +      udev_device_unref(d);
 +}
 +END_TEST
 +
  void
  litest_setup_tests(void)
  {
        litest_add("device:udev tags", device_udev_tag_alps, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("device:udev tags", device_udev_tag_wacom, LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("device:udev tags", device_udev_tag_apple, LITEST_TOUCHPAD, LITEST_ANY);
+       litest_add("device:udev tags", device_udev_tag_synaptics_serial, LITEST_TOUCHPAD, LITEST_ANY);
 +      litest_add("device:udev tags", device_udev_tag_wacom_tablet, LITEST_TABLET, LITEST_ANY);
  }
diff --cc test/litest.c
@@@ -2233,28 -2176,26 +2269,47 @@@ litest_is_keyboard_event(struct libinpu
        return kevent;
  }
  
+ struct libinput_event_gesture *
+ litest_is_gesture_event(struct libinput_event *event,
+                       enum libinput_event_type type,
+                       int nfingers)
+ {
+       struct libinput_event_gesture *gevent;
+       litest_assert(event != NULL);
+       litest_assert_int_eq(libinput_event_get_type(event), type);
+       gevent = libinput_event_get_gesture_event(event);
+       litest_assert(gevent != NULL);
+       if (nfingers != -1)
+               litest_assert_int_eq(libinput_event_gesture_get_finger_count(gevent),
+                                    nfingers);
+       return gevent;
+ }
  void
 +litest_assert_tablet_button_event(struct libinput *li, unsigned int button,
 +                                enum libinput_button_state state)
 +{
 +      struct libinput_event *event;
 +      struct libinput_event_tablet *tev;
 +      enum libinput_event_type type = LIBINPUT_EVENT_TABLET_BUTTON;
 +
 +      litest_wait_for_event(li);
 +      event = libinput_get_event(li);
 +
 +      litest_assert_notnull(event);
 +      litest_assert_int_eq(libinput_event_get_type(event), type);
 +      tev = libinput_event_get_tablet_event(event);
 +      litest_assert_int_eq(libinput_event_tablet_get_button(tev),
 +                           button);
 +      litest_assert_int_eq(libinput_event_tablet_get_button_state(tev),
 +                           state);
 +      libinput_event_destroy(event);
 +}
 +
 +void
  litest_assert_scroll(struct libinput *li,
                     enum libinput_pointer_axis axis,
                     int minimum_movement)
diff --cc test/litest.h
@@@ -334,15 -326,12 +334,21 @@@ void litest_touch_move_two_touches(stru
                                   double x1, double y1,
                                   double dx, double dy,
                                   int steps, int sleep_ms);
+ void litest_touch_move_three_touches(struct litest_device *d,
+                                    double x0, double y0,
+                                    double x1, double y1,
+                                    double x2, double y2,
+                                    double dx, double dy,
+                                    int steps, int sleep_ms);
 +
 +void litest_tablet_proximity_in(struct litest_device *d,
 +                              int x, int y,
 +                              struct axis_replacement *axes);
 +void litest_tablet_proximity_out(struct litest_device *d);
 +void litest_tablet_motion(struct litest_device *d,
 +                        int x, int y,
 +                        struct axis_replacement *axes);
 +
  void litest_hover_start(struct litest_device *d,
                        unsigned int slot,
                        double x,
diff --cc test/misc.c
@@@ -132,7 -131,7 +132,8 @@@ START_TEST(event_conversion_device_noti
                        ck_assert(libinput_event_get_pointer_event(event) == NULL);
                        ck_assert(libinput_event_get_keyboard_event(event) == NULL);
                        ck_assert(libinput_event_get_touch_event(event) == NULL);
+                       ck_assert(libinput_event_get_gesture_event(event) == NULL);
 +                      ck_assert(libinput_event_get_tablet_event(event) == NULL);
                        litest_restore_log_handler(li);
                }
  
@@@ -187,7 -186,7 +188,8 @@@ START_TEST(event_conversion_pointer
                        ck_assert(libinput_event_get_device_notify_event(event) == NULL);
                        ck_assert(libinput_event_get_keyboard_event(event) == NULL);
                        ck_assert(libinput_event_get_touch_event(event) == NULL);
+                       ck_assert(libinput_event_get_gesture_event(event) == NULL);
 +                      ck_assert(libinput_event_get_tablet_event(event) == NULL);
                        litest_restore_log_handler(li);
                }
                libinput_event_destroy(event);
@@@ -236,7 -235,7 +238,8 @@@ START_TEST(event_conversion_pointer_abs
                        ck_assert(libinput_event_get_device_notify_event(event) == NULL);
                        ck_assert(libinput_event_get_keyboard_event(event) == NULL);
                        ck_assert(libinput_event_get_touch_event(event) == NULL);
+                       ck_assert(libinput_event_get_gesture_event(event) == NULL);
 +                      ck_assert(libinput_event_get_tablet_event(event) == NULL);
                        litest_restore_log_handler(li);
                }
                libinput_event_destroy(event);
@@@ -278,7 -277,7 +281,8 @@@ START_TEST(event_conversion_key
                        ck_assert(libinput_event_get_device_notify_event(event) == NULL);
                        ck_assert(libinput_event_get_pointer_event(event) == NULL);
                        ck_assert(libinput_event_get_touch_event(event) == NULL);
+                       ck_assert(libinput_event_get_gesture_event(event) == NULL);
 +                      ck_assert(libinput_event_get_tablet_event(event) == NULL);
                        litest_restore_log_handler(li);
                }
                libinput_event_destroy(event);
@@@ -327,7 -326,7 +331,8 @@@ START_TEST(event_conversion_touch
                        ck_assert(libinput_event_get_device_notify_event(event) == NULL);
                        ck_assert(libinput_event_get_pointer_event(event) == NULL);
                        ck_assert(libinput_event_get_keyboard_event(event) == NULL);
+                       ck_assert(libinput_event_get_gesture_event(event) == NULL);
 +                      ck_assert(libinput_event_get_tablet_event(event) == NULL);
                        litest_restore_log_handler(li);
                }
                libinput_event_destroy(event);
  }
  END_TEST
  
+ START_TEST(event_conversion_gesture)
+ {
+       struct litest_device *dev = litest_current_device();
+       struct libinput *li = dev->libinput;
+       struct libinput_event *event;
+       int gestures = 0;
+       int i;
+       libinput_dispatch(li);
+       litest_touch_down(dev, 0, 70, 30);
+       litest_touch_down(dev, 1, 30, 70);
+       for (i = 0; i < 8; i++) {
+               litest_push_event_frame(dev);
+               litest_touch_move(dev, 0, 70 - i * 5, 30 + i * 5);
+               litest_touch_move(dev, 1, 30 + i * 5, 70 - i * 5);
+               litest_pop_event_frame(dev);
+               libinput_dispatch(li);
+       }
+       while ((event = libinput_get_event(li))) {
+               enum libinput_event_type type;
+               type = libinput_event_get_type(event);
+               if (type >= LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN &&
+                   type <= LIBINPUT_EVENT_GESTURE_PINCH_END) {
+                       struct libinput_event_gesture *g;
+                       struct libinput_event *base;
+                       g = libinput_event_get_gesture_event(event);
+                       base = libinput_event_gesture_get_base_event(g);
+                       ck_assert(event == base);
+                       gestures++;
+                       litest_disable_log_handler(li);
+                       ck_assert(libinput_event_get_device_notify_event(event) == NULL);
+                       ck_assert(libinput_event_get_pointer_event(event) == NULL);
+                       ck_assert(libinput_event_get_keyboard_event(event) == NULL);
+                       ck_assert(libinput_event_get_touch_event(event) == NULL);
+                       litest_restore_log_handler(li);
+               }
+               libinput_event_destroy(event);
+       }
+       ck_assert_int_gt(gestures, 0);
+ }
+ END_TEST
 +START_TEST(event_conversion_tablet)
 +{
 +      struct litest_device *dev = litest_current_device();
 +      struct libinput *li = dev->libinput;
 +      struct libinput_event *event;
 +      int events = 0;
 +      struct axis_replacement axes[] = {
 +              { ABS_DISTANCE, 10 },
 +              { -1, -1 }
 +      };
 +
 +      litest_tablet_proximity_in(dev, 50, 50, axes);
 +      litest_tablet_motion(dev, 60, 50, axes);
 +      litest_button_click(dev, BTN_STYLUS, true);
 +      litest_button_click(dev, BTN_STYLUS, false);
 +
 +      libinput_dispatch(li);
 +
 +      while ((event = libinput_get_event(li))) {
 +              enum libinput_event_type type;
 +              type = libinput_event_get_type(event);
 +
 +              if (type >= LIBINPUT_EVENT_TABLET_AXIS &&
 +                  type <= LIBINPUT_EVENT_TABLET_BUTTON) {
 +                      struct libinput_event_tablet *t;
 +                      struct libinput_event *base;
 +                      t = libinput_event_get_tablet_event(event);
 +                      base = libinput_event_tablet_get_base_event(t);
 +                      ck_assert(event == base);
 +
 +                      events++;
 +
 +                      litest_disable_log_handler(li);
 +                      ck_assert(libinput_event_get_device_notify_event(event) == NULL);
 +                      ck_assert(libinput_event_get_pointer_event(event) == NULL);
 +                      ck_assert(libinput_event_get_keyboard_event(event) == NULL);
 +                      ck_assert(libinput_event_get_touch_event(event) == NULL);
 +                      litest_restore_log_handler(li);
 +              }
 +              libinput_event_destroy(event);
 +      }
 +
 +      ck_assert_int_gt(events, 0);
 +}
 +END_TEST
 +
 +START_TEST(bitfield_helpers)
 +{
 +      /* This value has a bit set on all of the word boundaries we want to
 +       * test: 0, 1, 7, 8, 31, 32, and 33
 +       */
 +      unsigned char read_bitfield[] = { 0x83, 0x1, 0x0, 0x80, 0x3 };
 +      unsigned char write_bitfield[ARRAY_LENGTH(read_bitfield)];
 +      size_t i;
 +
 +      /* Now check that the bitfield we wrote to came out to be the same as
 +       * the bitfield we were writing from */
 +      for (i = 0; i < ARRAY_LENGTH(read_bitfield) * 8; i++) {
 +              switch (i) {
 +              case 0:
 +              case 1:
 +              case 7:
 +              case 8:
 +              case 31:
 +              case 32:
 +              case 33:
 +                      ck_assert(bit_is_set(read_bitfield, i));
 +                      set_bit(write_bitfield, i);
 +                      break;
 +              default:
 +                      ck_assert(!bit_is_set(read_bitfield, i));
 +                      clear_bit(write_bitfield, i);
 +                      break;
 +              }
 +      }
 +
 +      ck_assert_int_eq(memcmp(read_bitfield,
 +                              write_bitfield,
 +                              sizeof(read_bitfield)),
 +                       0);
 +}
 +END_TEST
 +
  START_TEST(context_ref_counting)
  {
        struct libinput *li;
@@@ -728,8 -692,7 +781,9 @@@ litest_setup_tests(void
        litest_add_for_device("events:conversion", event_conversion_pointer_abs, LITEST_XEN_VIRTUAL_POINTER);
        litest_add_for_device("events:conversion", event_conversion_key, LITEST_KEYBOARD);
        litest_add_for_device("events:conversion", event_conversion_touch, LITEST_WACOM_TOUCH);
+       litest_add_for_device("events:conversion", event_conversion_gesture, LITEST_BCM5974);
 +      litest_add_for_device("events:conversion", event_conversion_tablet, LITEST_WACOM_CINTIQ);
 +      litest_add_no_device("bitfield_helpers", bitfield_helpers);
  
        litest_add_no_device("context:refcount", context_ref_counting);
        litest_add_no_device("config:status string", config_status_string);
diff --cc test/pointer.c
Simple merge
Simple merge
Simple merge
Simple merge