debian/changelog                                                  |    9 
 debian/patches/fix-premature-flushing-of-evdev-event-on-mx4.patch |  179 
++++++++
 debian/patches/series                                             |    1 
 debian/patches/touch-point-orientation-size.patch                 |  220 
+++++-----
 4 files changed, 303 insertions(+), 106 deletions(-)

New commits:
commit 0ce381ef522eedfebdee70b944bc1afd36eeffe8
Author: Timo Aaltonen <[email protected]>
Date:   Thu Nov 5 11:03:26 2015 +0200

    fix-premature-flushing-of-evdev-event-on-mx4.patch: Added. (LP: #1504168)

diff --git a/debian/changelog b/debian/changelog
index 55fa12a..b6a1e94 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ libinput (1.1.0-1ubuntu2) UNRELEASED; urgency=medium
 
   * touch-point-orientation-size.patch: Updated to v8 from list, but use
     old version for symbols.
+  * fix-premature-flushing-of-evdev-event-on-mx4.patch: Added. (LP:
+    #1504168)
 
  -- Timo Aaltonen <[email protected]>  Thu, 05 Nov 2015 11:01:40 +0200
 
diff --git a/debian/patches/fix-premature-flushing-of-evdev-event-on-mx4.patch 
b/debian/patches/fix-premature-flushing-of-evdev-event-on-mx4.patch
new file mode 100644
index 0000000..790c144
--- /dev/null
+++ b/debian/patches/fix-premature-flushing-of-evdev-event-on-mx4.patch
@@ -0,0 +1,179 @@
+Subject: [PATCH v2 libinput] Fix premature flushing of evdev event on mx4 
touchscreen
+From: Andreas Pokorny <[email protected]>
+Date: 07.09.2015 22:57
+To: [email protected], [email protected]
+CC: Andreas Pokorny <[email protected]>
+
+The mx4 touchscreen driver emits BTN_TOUCH and BTN_TOOL_FINGER key events
+on a new contact. Prior to this patch only the BTN_TOUCH event was filtered
+out. Now the whole range of BTN_ events for tool types and certain builtin
+multi finger gestures are marked as non-key type.
+
+Signed-off-by: Andreas Pokorny <[email protected]>
+---
+ src/evdev.c  |  10 +++---
+ test/touch.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 115 insertions(+), 5 deletions(-)
+
+diff --git a/src/evdev.c b/src/evdev.c
+index 04df275..3e22aa9 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -557,7 +557,7 @@ evdev_flush_pending_event(struct evdev_device *device, 
uint64_t time)
+ static enum evdev_key_type
+ get_key_type(uint16_t code)
+ {
+-      if (code == BTN_TOUCH)
++      if (code >= BTN_DIGI && code <= BTN_TOOL_QUADTAP)
+               return EVDEV_KEY_TYPE_NONE;
+ 
+       if (code >= KEY_ESC && code <= KEY_MICMUTE)
+@@ -630,16 +630,16 @@ evdev_process_key(struct evdev_device *device,
+       if (e->value == 2)
+               return;
+ 
+-      if (e->code == BTN_TOUCH) {
+-              if (!device->is_mt)
++      type = get_key_type(e->code);
++
++      if (type == EVDEV_KEY_TYPE_NONE) {
++              if (e->code == BTN_TOUCH && !device->is_mt)
+                       evdev_process_touch_button(device, time, e->value);
+               return;
+       }
+ 
+       evdev_flush_pending_event(device, time);
+ 
+-      type = get_key_type(e->code);
+-
+       /* Ignore key release events from the kernel for keys that libinput
+        * never got a pressed event for. */
+       if (e->value == 0) {
+diff --git a/test/touch.c b/test/touch.c
+index 875d94d..0e7f893 100644
+--- a/test/touch.c
++++ b/test/touch.c
+@@ -912,6 +912,114 @@ START_TEST(touch_point_no_minor_or_orientation)
+ }
+ END_TEST
+ 
++START_TEST(touchscreen_with_btn_tool_finger_on_down)
++{
++      struct libevdev_uinput *uinput;
++      struct libinput *li;
++      struct libinput_device *device;
++      struct libinput_event *event;
++      struct libinput_event_touch *tev;
++      const struct input_absinfo abs[] = {
++              { ABS_X, 0, 1152, 0, 0, 0 },
++              { ABS_Y, 0, 1920, 0, 0, 0 },
++              { ABS_MT_SLOT, 0, 9, 0, 0, 0 },
++              { ABS_MT_TRACKING_ID, 0, 65535, 0, 0, 0 },
++              { ABS_MT_POSITION_X, 0, 1152, 0, 0, 0 },
++              { ABS_MT_POSITION_Y, 0, 1920, 0, 0, 0 },
++              { ABS_MT_TOUCH_MAJOR, 0, 23, 0, 0, 0 },
++              { ABS_MT_TOUCH_MINOR, 0, 23, 0, 0, 0 },
++              { -1, -1, -1, -1, -1, -1 }
++      };
++      const struct input_event input_sequence[] = {
++              { {0}, EV_ABS, ABS_MT_SLOT, 0},
++              { {0}, EV_ABS, ABS_MT_TRACKING_ID, 9},
++              { {0}, EV_KEY, BTN_TOUCH, 1},
++              { {0}, EV_KEY, BTN_TOOL_FINGER, 1},
++              { {0}, EV_ABS, ABS_MT_POSITION_X, 128},
++              { {0}, EV_ABS, ABS_MT_POSITION_Y, 240},
++              { {0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 5},
++              { {0}, EV_ABS, ABS_MT_TOUCH_MINOR, 4},
++              { {0}, EV_SYN, SYN_REPORT, 0},
++              { {0}, EV_ABS, ABS_MT_TOUCH_MAJOR, 6},
++              { {0}, EV_SYN, SYN_REPORT, 0},
++              { {0}, EV_ABS, ABS_MT_TRACKING_ID, -1},
++              { {0}, EV_KEY, BTN_TOUCH, 0},
++              { {0}, EV_KEY, BTN_TOOL_FINGER, 0},
++              { {0}, EV_SYN, SYN_REPORT, 0}
++      };
++      const int num_events = ARRAY_LENGTH(input_sequence);
++      const int width = 1152;
++      const int height = 1920;
++      int x, y, major, minor;
++
++      uinput = litest_create_uinput_abs_device(
++              "test device",
++              NULL, abs,
++              EV_KEY, BTN_TOUCH,
++              EV_KEY, BTN_TOOL_FINGER,
++              INPUT_PROP_MAX, INPUT_PROP_DIRECT,
++              -1, -1);
++
++      li = litest_create_context();
++      device = libinput_path_add_device(li,
++                                        libevdev_uinput_get_devnode(uinput));
++      ck_assert(device != NULL);
++      device = libinput_device_ref(device);
++      litest_drain_events(li);
++
++      for (int i = 0; i!=num_events; ++i)
++              libevdev_uinput_write_event(uinput,
++                                          input_sequence[i].type,
++                                          input_sequence[i].code,
++                                          input_sequence[i].value);
++
++      litest_wait_for_event(li);
++
++      event = libinput_get_event(li);
++      tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_DOWN);
++      x = round(libinput_event_touch_get_x_transformed(tev, width));
++      y = round(libinput_event_touch_get_y_transformed(tev, height)),
++      major = round(
++              libinput_event_touch_get_major_transformed(tev, width, height));
++      minor = round(
++              libinput_event_touch_get_minor_transformed(tev, width, height));
++      ck_assert_int_eq(x, 128);
++      ck_assert_int_eq(y, 240);
++      ck_assert_int_eq(major, 5);
++      ck_assert_int_eq(minor, 4);
++      libinput_event_destroy(event);
++
++      event = libinput_get_event(li);
++      tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
++      libinput_event_destroy(event);
++
++      event = libinput_get_event(li);
++      tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_MOTION);
++      major = round(
++              libinput_event_touch_get_major_transformed(tev, width, height));
++      ck_assert_int_eq(major, 6);
++      libinput_event_destroy(event);
++
++      event = libinput_get_event(li);
++      tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
++      libinput_event_destroy(event);
++
++      event = libinput_get_event(li);
++      tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_UP);
++      libinput_event_destroy(event);
++
++      event = libinput_get_event(li);
++      tev = litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_FRAME);
++      libinput_event_destroy(event);
++
++      litest_assert_empty_queue(li);
++
++      libinput_device_unref(device);
++      libinput_unref(li);
++      libevdev_uinput_destroy(uinput);
++}
++END_TEST
++
+ void
+ litest_setup_tests(void)
+ {
+@@ -942,4 +1050,6 @@ litest_setup_tests(void)
+       litest_add_ranged("touch:state", touch_initial_state, LITEST_TOUCH, 
LITEST_PROTOCOL_A, &axes);
+ 
+       litest_add("touch:time", touch_time_usec, LITEST_TOUCH, 
LITEST_TOUCHPAD);
++
++      litest_add_no_device("touch:special events", 
touchscreen_with_btn_tool_finger_on_down);
+ }
+-- 2.5.0 _______________________________________________ wayland-devel mailing 
list [email protected] 
http://lists.freedesktop.org/mailman/listinfo/wayland-devel
+
diff --git a/debian/patches/series b/debian/patches/series
index db29c19..63b23e6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 touch-point-orientation-size.patch
+fix-premature-flushing-of-evdev-event-on-mx4.patch

commit 59bb703dcb06b531ae4241d1555e6909259fc450
Author: Timo Aaltonen <[email protected]>
Date:   Thu Nov 5 11:01:57 2015 +0200

    touch-point-orientation-size.patch: Updated to v8 from list, but use old 
version for symbols.

diff --git a/debian/changelog b/debian/changelog
index b88b1bc..55fa12a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+libinput (1.1.0-1ubuntu2) UNRELEASED; urgency=medium
+
+  * touch-point-orientation-size.patch: Updated to v8 from list, but use
+    old version for symbols.
+
+ -- Timo Aaltonen <[email protected]>  Thu, 05 Nov 2015 11:01:40 +0200
+
 libinput (1.1.0-1ubuntu1) xenial; urgency=medium
 
   * Merge from Debian unstable.
diff --git a/debian/patches/touch-point-orientation-size.patch 
b/debian/patches/touch-point-orientation-size.patch
index c6feacd..fedb5d5 100644
--- a/debian/patches/touch-point-orientation-size.patch
+++ b/debian/patches/touch-point-orientation-size.patch
@@ -1,3 +1,9 @@
+Subject: [PATCH libinput 1/2] libinput: add orientation and size of touch 
point and pressure to the API
+From: Andreas Pokorny <[email protected]>
+Date: 02.11.2015 17:56
+To: [email protected], [email protected]
+CC: Andreas Pokorny <[email protected]>
+
 This change adds four new properties to touch events:
 * major: diameter of the touch ellipse along the major axis
 * minor: diameter perpendicular to major axis
@@ -6,26 +12,26 @@ This change adds four new properties to touch events:
 
 Those values are optionally supported by multi-touch drivers, so default values
 are used if the information is missing. The existance of each of the properties
-can be querried at the event using another set of libinput_event_touch_has_*
+can be queried at the event using another set of libinput_event_touch_has_*
 functions.
 
 Explanation of those values was added to the touch screen page.
 
-Signed-off-by: Andreas Pokorny <andreas.pokorny at canonical.com>
+Signed-off-by: Andreas Pokorny <[email protected]>
 ---
  doc/Makefile.am                                |   2 +
  doc/page-hierarchy.dox                         |   1 +
  doc/svg/touchscreen-touch-event-properties.svg | 347 +++++++++++++++++++++++++
  doc/touch-event-properties.dox                 |  42 +++
- src/evdev.c                                    | 218 ++++++++++++++--
- src/evdev.h                                    |  25 ++
- src/libinput-private.h                         |  25 +-
+ src/evdev.c                                    | 224 ++++++++++++++--
+ src/evdev.h                                    |  24 ++
+ src/libinput-private.h                         |  13 +-
  src/libinput-util.h                            |   6 +
- src/libinput.c                                 | 205 ++++++++++++++-
+ src/libinput.c                                 | 212 ++++++++++++++-
  src/libinput.h                                 | 222 ++++++++++++++++
  src/libinput.sym                               |  13 +
- test/touch.c                                   | 239 +++++++++++++++++
- 12 files changed, 1313 insertions(+), 32 deletions(-)
+ test/touch.c                                   | 241 +++++++++++++++++
+ 12 files changed, 1315 insertions(+), 32 deletions(-)
  create mode 100644 doc/svg/touchscreen-touch-event-properties.svg
  create mode 100644 doc/touch-event-properties.dox
 
@@ -53,7 +59,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
  @page touchscreens Touchscreens
  
  - @subpage absolute_axes
-+- @subpage touch_event_properties 
++- @subpage touch_event_properties
  
  @page pointers Mice, Trackballs, etc.
  
@@ -411,17 +417,17 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +++ b/doc/touch-event-properties.dox
 @@ -0,0 +1,42 @@
 +/**
-+ at page touch_event_properties Properties of a touch event
++@page touch_event_properties Properties of a touch event
 +
 +This page gives some overview on touchscreen events. With libinput 
touchscreens
 +provide the event types @ref LIBINPUT_EVENT_TOUCH_DOWN, @ref 
LIBINPUT_EVENT_TOUCH_UP,
-+ at ref LIBINPUT_EVENT_TOUCH_MOTION and @ref LIBINPUT_EVENT_TOUCH_CANCEL. The
++@ref LIBINPUT_EVENT_TOUCH_MOTION and @ref LIBINPUT_EVENT_TOUCH_CANCEL. The
 +touchscreen events @ref LIBINPUT_EVENT_TOUCH_DOWN and
-+ at ref LIBINPUT_EVENT_TOUCH_MOTION provide alongside the actual state change 
and
++@ref LIBINPUT_EVENT_TOUCH_MOTION provide alongside the actual state change and
 +the absolute coordinates (@ref absolute_axes_handling) additional information
 +about the touch contact.
 +
-+ at image html touchscreen-touch-event-properties.svg "Properties of a touch 
screen contact"
++@image html touchscreen-touch-event-properties.svg "Properties of a touch 
screen contact"
 +
 +Assuming the interaction of fingers with a touch screen, touch contacts are
 +approximated with an ellipse. The major axis of the ellipse describes the
@@ -440,16 +446,16 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +If the orientation is not available libinput will return 0.0 degrees.
 +
 +For querying the touch properties see:
-+- @ref libinput_event_touch_get_major_transformed
-+- @ref libinput_event_touch_get_minor_transformed
-+- @ref libinput_event_touch_get_orientation
-+- @ref libinput_event_touch_get_pressure
++- libinput_event_touch_get_major_transformed()
++- libinput_event_touch_get_minor_transformed()
++- libinput_event_touch_get_orientation()
++- libinput_event_touch_get_pressure()
 +
 +For testing which of the touch properties are available see:
-+- @ref libinput_event_touch_has_major
-+- @ref libinput_event_touch_has_minor
-+- @ref libinput_event_touch_has_orientation
-+- @ref libinput_event_touch_has_pressure
++- libinput_event_touch_has_major()
++- libinput_event_touch_has_minor()
++- libinput_event_touch_has_orientation()
++- libinput_event_touch_has_pressure()
 +
 +*/
 --- a/src/evdev.c
@@ -458,10 +464,10 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
  
  #define DEFAULT_WHEEL_CLICK_ANGLE 15
  #define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT ms2us(200)
-+#define DEFAULT_TOUCH_PRESSURE 1
-+#define DEFAULT_TOUCH_ORIENTATION 0
-+#define DEFAULT_TOUCH_MAJOR 0
-+#define DEFAULT_TOUCH_MINOR 0
++#define DEFAULT_TOUCH_PRESSURE 1.0
++#define DEFAULT_TOUCH_ORIENTATION 0.0
++#define DEFAULT_TOUCH_MAJOR 0.0
++#define DEFAULT_TOUCH_MINOR 0.0
  
  enum evdev_key_type {
        EVDEV_KEY_TYPE_NONE,
@@ -491,8 +497,8 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +              double x_scaling_ratio = fabs(sin(deg2rad(axis_angle)));
 +              double y_scaling_ratio = fabs(cos(deg2rad(axis_angle)));
 +
-+              return diameter / (y_res * y_scaling_ratio +
-+                                 x_res * x_scaling_ratio);
++              return diameter / hypotf(y_res * y_scaling_ratio,
++                                       x_res * x_scaling_ratio);
 +      }
 +}
 +
@@ -591,7 +597,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
                        log_bug_kernel(libinput,
                                       "%s: Driver sent multiple touch down for 
the "
                                       "same slot",
-@@ -323,38 +428,52 @@ evdev_flush_pending_event(struct evdev_d
+@@ -323,38 +428,50 @@ evdev_flush_pending_event(struct evdev_d
                }
  
                seat_slot = ffs(~seat->slot_map) - 1;
@@ -613,7 +619,6 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +                                      slot,
 +                                      seat_slot,
 +                                      &point,
-+                                      slot_data->available_data,
 +                                      &slot_data->area,
 +                                      slot_data->pressure);
                break;
@@ -639,7 +644,6 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +                                        slot,
 +                                        seat_slot,
 +                                        &point,
-+                                        slot_data->available_data,
 +                                        &slot_data->area,
 +                                        slot_data->pressure);
                break;
@@ -654,7 +658,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
  
                if (seat_slot == -1)
                        break;
-@@ -386,7 +505,14 @@ evdev_flush_pending_event(struct evdev_d
+@@ -386,7 +503,13 @@ evdev_flush_pending_event(struct evdev_d
                point = device->abs.point;
                transform_absolute(device, &point);
  
@@ -664,13 +668,12 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +                                      -1,
 +                                      seat_slot,
 +                                      &point,
-+                                      TOUCH_SLOT_DATA_NONE,
 +                                      &default_touch,
 +                                      DEFAULT_TOUCH_PRESSURE);
                break;
        case EVDEV_ABSOLUTE_MOTION:
                point = device->abs.point;
-@@ -398,8 +524,14 @@ evdev_flush_pending_event(struct evdev_d
+@@ -398,8 +521,13 @@ evdev_flush_pending_event(struct evdev_d
                        if (seat_slot == -1)
                                break;
  
@@ -681,13 +684,12 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +                                                -1,
 +                                                seat_slot,
 +                                                &point,
-+                                                TOUCH_SLOT_DATA_NONE,
 +                                                &default_touch,
 +                                                DEFAULT_TOUCH_PRESSURE);
                } else if (device->seat_caps & EVDEV_DEVICE_POINTER) {
                        pointer_notify_motion_absolute(base, time, &point);
                }
-@@ -559,8 +691,9 @@ evdev_process_touch(struct evdev_device
+@@ -559,8 +687,9 @@ evdev_process_touch(struct evdev_device
                    struct input_event *e,
                    uint64_t time)
  {
@@ -699,7 +701,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
                if ((size_t)e->value >= device->mt.slots_len) {
                        log_bug_libinput(device->base.seat->libinput,
                                         "%s exceeds slots (%d of %zd)\n",
-@@ -571,8 +704,7 @@ evdev_process_touch(struct evdev_device
+@@ -571,8 +700,7 @@ evdev_process_touch(struct evdev_device
                }
                evdev_flush_pending_event(device, time);
                device->mt.slot = e->value;
@@ -709,7 +711,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
                if (device->pending_event != EVDEV_NONE &&
                    device->pending_event != EVDEV_ABSOLUTE_MT_MOTION)
                        evdev_flush_pending_event(device, time);
-@@ -580,17 +712,40 @@ evdev_process_touch(struct evdev_device
+@@ -580,17 +708,34 @@ evdev_process_touch(struct evdev_device
                        device->pending_event = EVDEV_ABSOLUTE_MT_DOWN;
                else
                        device->pending_event = EVDEV_ABSOLUTE_MT_UP;
@@ -733,21 +735,15 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +                      current_slot->point.y = e->value;
 +                      break;
 +              case ABS_MT_TOUCH_MAJOR:
-+                      current_slot->available_data |= TOUCH_SLOT_DATA_MAJOR;
 +                      current_slot->area.major = e->value;
 +                      break;
 +              case ABS_MT_TOUCH_MINOR:
-+                      current_slot->available_data |= TOUCH_SLOT_DATA_MINOR;
 +                      current_slot->area.minor = e->value;
 +                      break;
 +              case ABS_MT_ORIENTATION:
-+                      current_slot->available_data |=
-+                                              TOUCH_SLOT_DATA_ORIENTATION;
 +                      current_slot->area.orientation = e->value;
 +                      break;
 +              case ABS_MT_PRESSURE:
-+                      current_slot->available_data |=
-+                                              TOUCH_SLOT_DATA_PRESSURE;
 +                      current_slot->pressure = e->value;
 +                      break;
 +              default:
@@ -760,42 +756,64 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
        }
  }
  
-@@ -2014,6 +2169,13 @@ evdev_configure_device(struct evdev_devi
+@@ -1944,6 +2089,20 @@ evdev_configure_mt_device(struct evdev_d
+               slots[slot].point.y = libevdev_get_slot_value(evdev,
+                                                             slot,
+                                                             
ABS_MT_POSITION_Y);
++              slots[slot].area.major =
++                      libevdev_get_slot_value(evdev,
++                                              slot,
++                                              ABS_MT_TOUCH_MAJOR);
++              slots[slot].area.minor =
++                      libevdev_get_slot_value(evdev,
++                                              slot,
++                                              ABS_MT_TOUCH_MINOR);
++              slots[slot].area.orientation =
++                      libevdev_get_slot_value(evdev,
++                                              slot,
++                                              ABS_MT_ORIENTATION);
++              slots[slot].pressure =
++                      libevdev_get_slot_value(evdev, slot, ABS_MT_PRESSURE);
+       }
+       device->mt.slots = slots;
+       device->mt.slots_len = num_slots;
+@@ -2014,6 +2173,15 @@ evdev_configure_device(struct evdev_devi
                return -1;
        }
  
 +      device->abs.absinfo_orientation =
-+              libevdev_get_abs_info(evdev,
-+                                    ABS_MT_ORIENTATION);
++              libevdev_get_abs_info(evdev, ABS_MT_ORIENTATION);
 +      device->abs.absinfo_pressure =
-+              libevdev_get_abs_info(evdev,
-+                                    ABS_MT_PRESSURE);
++              libevdev_get_abs_info(evdev, ABS_MT_PRESSURE);
++      device->abs.absinfo_major =
++              libevdev_get_abs_info(evdev, ABS_MT_TOUCH_MAJOR);
++      device->abs.absinfo_minor =
++              libevdev_get_abs_info(evdev, ABS_MT_TOUCH_MINOR);
 +
        if (!evdev_is_fake_mt_device(device))
                evdev_fix_android_mt(device);
  
 --- a/src/evdev.h
 +++ b/src/evdev.h
-@@ -112,6 +112,9 @@ enum evdev_device_model {
+@@ -112,6 +112,8 @@ enum evdev_device_model {
  struct mt_slot {
        int32_t seat_slot;
        struct device_coords point;
-+      enum touch_slot_data available_data;
 +      struct ellipse area;
 +      int32_t pressure;
  };
  
  struct evdev_device {
-@@ -128,6 +131,8 @@ struct evdev_device {
+@@ -128,6 +130,8 @@ struct evdev_device {
        int fd;
        struct {
                const struct input_absinfo *absinfo_x, *absinfo_y;
-+              const struct input_absinfo *absinfo_pressure,
-+                                         *absinfo_orientation;
++              const struct input_absinfo *absinfo_major, *absinfo_minor,
++                    *absinfo_pressure, *absinfo_orientation;
                int fake_resolution;
  
                struct device_coords point;
-@@ -349,6 +354,26 @@ double
+@@ -349,6 +353,26 @@ double
  evdev_device_transform_y(struct evdev_device *device,
                         double y,
                         uint32_t height);
@@ -836,30 +854,12 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
  /*
   * A coordinate pair in device coordinates, capable of holding non discrete
   * values, this is necessary e.g. when device coordinates get averaged.
-@@ -58,6 +63,16 @@ struct discrete_coords {
-       int x, y;
- };
- 
-+enum touch_slot_data {
-+      TOUCH_SLOT_DATA_NONE = 0,
-+      TOUCH_SLOT_DATA_MAJOR = (1 << 1),
-+      TOUCH_SLOT_DATA_MINOR = (1 << 2),
-+      TOUCH_SLOT_DATA_ORIENTATION = (1 << 3),
-+      TOUCH_SLOT_DATA_PRESSURE = (1 << 4),
-+};
-+
-+
-+
- struct libinput_interface_backend {
-       int (*resume)(struct libinput *libinput);
-       void (*suspend)(struct libinput *libinput);
-@@ -396,14 +411,20 @@ touch_notify_touch_down(struct libinput_
+@@ -396,14 +401,18 @@ touch_notify_touch_down(struct libinput_
                        uint64_t time,
                        int32_t slot,
                        int32_t seat_slot,
 -                      const struct device_coords *point);
 +                      const struct device_coords *point,
-+                      enum touch_slot_data available_data,
 +                      const struct ellipse *area,
 +                      int32_t pressure);
  
@@ -870,7 +870,6 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
                          int32_t seat_slot,
 -                        const struct device_coords *point);
 +                        const struct device_coords *point,
-+                        enum touch_slot_data available_data,
 +                        const struct ellipse *area,
 +                        int32_t pressure);
  
@@ -893,17 +892,16 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
  {
 --- a/src/libinput.c
 +++ b/src/libinput.c
-@@ -112,6 +112,9 @@ struct libinput_event_touch {
+@@ -112,6 +112,8 @@ struct libinput_event_touch {
        int32_t slot;
        int32_t seat_slot;
        struct device_coords point;
-+      enum touch_slot_data available_data;
 +      struct ellipse area;
 +      int32_t pressure;
  };
  
  struct libinput_event_gesture {
-@@ -732,6 +735,192 @@ libinput_event_touch_get_y(struct libinp
+@@ -732,6 +734,204 @@ libinput_event_touch_get_y(struct libinp
        return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y);
  }
  
@@ -956,13 +954,16 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +LIBINPUT_EXPORT int
 +libinput_event_touch_has_major(struct libinput_event_touch *event)
 +{
++      struct evdev_device *device =
++              (struct evdev_device *) event->base.device;
++
 +      require_event_type(libinput_event_get_context(&event->base),
 +                         event->base.type,
 +                         0,
 +                         LIBINPUT_EVENT_TOUCH_DOWN,
 +                         LIBINPUT_EVENT_TOUCH_MOTION);
 +
-+      return event->available_data & TOUCH_SLOT_DATA_MAJOR;
++      return device->abs.absinfo_major != 0;
 +}
 +
 +LIBINPUT_EXPORT double
@@ -1011,7 +1012,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +      /* use major diameter if minor is not available, but if it is
 +       * add 90 since the minor diameter is perpendicular to the
 +       * major axis */
-+      if( event->available_data & TOUCH_SLOT_DATA_MINOR) {
++      if (device->abs.absinfo_minor) {
 +              diameter = event->area.minor,
 +              angle += 90.0;
 +      } else {
@@ -1028,13 +1029,16 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +LIBINPUT_EXPORT int
 +libinput_event_touch_has_minor(struct libinput_event_touch *event)
 +{
++      struct evdev_device *device =
++              (struct evdev_device *) event->base.device;
++
 +      require_event_type(libinput_event_get_context(&event->base),
 +                         event->base.type,
 +                         0,
 +                         LIBINPUT_EVENT_TOUCH_DOWN,
 +                         LIBINPUT_EVENT_TOUCH_MOTION);
 +
-+      return event->available_data & TOUCH_SLOT_DATA_MINOR;
++      return device->abs.absinfo_minor != 0;
 +}
 +
 +LIBINPUT_EXPORT double
@@ -1056,13 +1060,16 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +LIBINPUT_EXPORT int
 +libinput_event_touch_has_orientation(struct libinput_event_touch *event)
 +{
++      struct evdev_device *device =
++              (struct evdev_device *) event->base.device;
++
 +      require_event_type(libinput_event_get_context(&event->base),
 +                         event->base.type,
 +                         0,
 +                         LIBINPUT_EVENT_TOUCH_DOWN,
 +                         LIBINPUT_EVENT_TOUCH_MOTION);
 +
-+      return event->available_data & TOUCH_SLOT_DATA_ORIENTATION;
++      return device->abs.absinfo_orientation != 0;
 +}
 +
 +LIBINPUT_EXPORT double
@@ -1084,57 +1091,56 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +LIBINPUT_EXPORT int
 +libinput_event_touch_has_pressure(struct libinput_event_touch *event)
 +{
++      struct evdev_device *device =
++              (struct evdev_device *) event->base.device;
++
 +      require_event_type(libinput_event_get_context(&event->base),
 +                         event->base.type,
 +                         0,
 +                         LIBINPUT_EVENT_TOUCH_DOWN,
 +                         LIBINPUT_EVENT_TOUCH_MOTION);
 +
-+      return event->available_data & TOUCH_SLOT_DATA_PRESSURE;
++      return device->abs.absinfo_pressure != 0;
 +}
 +
  LIBINPUT_EXPORT uint32_t
  libinput_event_gesture_get_time(struct libinput_event_gesture *event)
  {
-@@ -1512,7 +1701,10 @@ touch_notify_touch_down(struct libinput_
+@@ -1512,7 +1712,9 @@ touch_notify_touch_down(struct libinput_
                        uint64_t time,
                        int32_t slot,
                        int32_t seat_slot,
 -                      const struct device_coords *point)
 +                      const struct device_coords *point,
-+                      enum touch_slot_data available_data,
 +                      const struct ellipse *area,
 +                      int32_t pressure)
  {
        struct libinput_event_touch *touch_event;
  
-@@ -1528,6 +1720,9 @@ touch_notify_touch_down(struct libinput_
+@@ -1528,6 +1730,8 @@ touch_notify_touch_down(struct libinput_
                .slot = slot,
                .seat_slot = seat_slot,
                .point = *point,
-+              .available_data = available_data,
 +              .area = *area,
 +              .pressure = pressure,
        };
  
        post_device_event(device, time,
-@@ -1540,7 +1735,10 @@ touch_notify_touch_motion(struct libinpu
+@@ -1540,7 +1744,9 @@ touch_notify_touch_motion(struct libinpu
                          uint64_t time,
                          int32_t slot,
                          int32_t seat_slot,
 -                        const struct device_coords *point)
 +                        const struct device_coords *point,
-+                        enum touch_slot_data available_data,
 +                        const struct ellipse *area,
 +                        int32_t pressure)
  {
        struct libinput_event_touch *touch_event;
  
-@@ -1556,6 +1754,9 @@ touch_notify_touch_motion(struct libinpu
+@@ -1556,6 +1762,8 @@ touch_notify_touch_motion(struct libinpu
                .slot = slot,
                .seat_slot = seat_slot,
                .point = *point,
-+              .available_data = available_data,
 +              .area = *area,
 +              .pressure = pressure,
        };
@@ -1206,7 +1212,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 + * LIBINPUT_EVENT_TOUCH_MOTION.
 + *
 + * @param event The libinput touch event
-+ * @return Whether a major diameter is available
++ * @return Non-zero when a major diameter is available
 + */
 +int
 +libinput_event_touch_has_major(struct libinput_event_touch *event);
@@ -1273,7 +1279,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 + * LIBINPUT_EVENT_TOUCH_MOTION.
 + *
 + * @param event The libinput touch event
-+ * @return Whether a minor diameter is available
++ * @return Non-zero when a minor diameter is available
 + */
 +int
 +libinput_event_touch_has_minor(struct libinput_event_touch *event);
@@ -1315,7 +1321,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 + * LIBINPUT_EVENT_TOUCH_MOTION.
 + *
 + * @param event The libinput touch event
-+ * @return Whether a pressure value is available
++ * @return Non-zero when a pressure value is available
 + */
 +int
 +libinput_event_touch_has_pressure(struct libinput_event_touch *event);
@@ -1360,7 +1366,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 + * LIBINPUT_EVENT_TOUCH_MOTION.
 + *
 + * @param event The libinput touch event
-+ * @return Whether a orientation value is available
++ * @return Non-zero when an orientation value is available
 + */
 +int
 +libinput_event_touch_has_orientation(struct libinput_event_touch *event);
@@ -1395,7 +1401,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
        libinput_device_config_accel_get_profiles;
 --- a/test/touch.c
 +++ b/test/touch.c
-@@ -673,6 +673,243 @@ START_TEST(touch_time_usec)
+@@ -673,6 +673,245 @@ START_TEST(touch_time_usec)
  }
  END_TEST
  
@@ -1407,8 +1413,8 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +      if (x_res == y_res)
 +              return x_res;
 +
-+      return y_res * fabs(cos(orientation_rad)) +
-+              x_res * fabs(sin(orientation_rad));
++      return hypotf(y_res * fabs(cos(orientation_rad)),
++                    x_res * fabs(sin(orientation_rad)));
 +}
 +
 +static inline bool exceeds_range(const struct input_absinfo *info,
@@ -1473,7 +1479,8 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +          exceeds_range(minor_info, input_minor) ||
 +          exceeds_range(orientation_info, input_orientation) ||
 +          exceeds_range(orientation_info, input_orientation_2)) {
-+              fprintf(stderr, "%s does not support the required value ranges",
++              fprintf(stderr,
++                      "%s does not support the required value ranges\n",
 +                      libinput_device_get_name(dev->libinput_device));
 +              return;
 +        }
@@ -1511,14 +1518,14 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +      ck_assert_double_eq(libinput_event_touch_get_minor(tev),
 +                          expected_minor);
 +
-+      libinput_event_destroy(ev);
-+
 +      litest_touch_move_extended(dev, 0, touch_x, touch_y, move_values);
 +
 +      do {
++              libinput_event_destroy(ev);
 +              litest_wait_for_event(li);
 +              ev = libinput_get_event(li);
 +      } while (libinput_event_get_type(ev) == LIBINPUT_EVENT_TOUCH_FRAME);
++
 +      tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_MOTION);
 +
 +      expected_orientation = 90.0 * input_orientation_2 /
@@ -1541,7 +1548,7 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +}
 +END_TEST
 +
-+START_TEST(touch_point_no_minor_or_orienation)
++START_TEST(touch_point_no_minor_or_orientation)
 +{
 +      struct litest_device *dev = litest_current_device();
 +      struct libinput *li = dev->libinput;
@@ -1586,7 +1593,8 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +      if (exceeds_range(pressure_info, input_pressure) ||
 +          exceeds_range(major_info, input_major) ||
 +          exceeds_range(major_info, input_major_2)) {
-+              fprintf(stderr, "%s does not support the required value ranges",
++              fprintf(stderr,
++                      "%s does not support the required value ranges\n",
 +                      libinput_device_get_name(dev->libinput_device));
 +              return;
 +        }
@@ -1614,17 +1622,17 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
 +      ck_assert_double_eq(libinput_event_touch_get_minor(tev),
 +                          expected_minor);
 +
-+      libinput_event_destroy(ev);
-+
 +      expected_major = input_major_2 / touch_major_scale;
 +      expected_minor = expected_major;
 +
 +      litest_touch_move_extended(dev, 0, touch_x, touch_y, move_values);
 +
 +      do {
++              libinput_event_destroy(ev);
 +              litest_wait_for_event(li);
 +              ev = libinput_get_event(li);
 +      } while (libinput_event_get_type(ev) == LIBINPUT_EVENT_TOUCH_FRAME);
++
 +      tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_MOTION);
 +
 +      ck_assert_double_eq(libinput_event_touch_get_major(tev),
@@ -1639,12 +1647,12 @@ Signed-off-by: Andreas Pokorny <andreas.pokorny at 
canonical.com>
  void
  litest_setup_tests(void)
  {
-@@ -697,6 +934,8 @@ litest_setup_tests(void)
+@@ -697,6 +936,8 @@ litest_setup_tests(void)
        litest_add("touch:protocol a", touch_protocol_a_init, 
LITEST_PROTOCOL_A, LITEST_ANY);
        litest_add("touch:protocol a", touch_protocol_a_touch, 
LITEST_PROTOCOL_A, LITEST_ANY);
        litest_add("touch:protocol a", touch_protocol_a_2fg_touch, 
LITEST_PROTOCOL_A, LITEST_ANY);
 +      litest_add("touch:properties", touch_point_properties, 
LITEST_TOUCH|LITEST_ELLIPSE, LITEST_ANY);
-+      litest_add("touch:properties", touch_point_no_minor_or_orienation, 
LITEST_TOUCH|LITEST_ELLIPSE, LITEST_ANY);
++      litest_add("touch:properties", touch_point_no_minor_or_orientation, 
LITEST_TOUCH|LITEST_ELLIPSE, LITEST_ANY);
  
        litest_add_ranged("touch:state", touch_initial_state, LITEST_TOUCH, 
LITEST_PROTOCOL_A, &axes);
  

Reply via email to