evdev: plug memory leak on libevdev_new_from_fd failure
[platform/upstream/libinput.git] / src / evdev-mt-touchpad.h
index 1749a55..83edf4f 100644 (file)
@@ -33,6 +33,8 @@
 #define TOUCHPAD_HISTORY_LENGTH 4
 #define TOUCHPAD_MIN_SAMPLES 4
 
+#define VENDOR_ID_APPLE 0x5ac
+
 enum touchpad_event {
        TOUCHPAD_EVENT_NONE             = 0,
        TOUCHPAD_EVENT_MOTION           = (1 << 0),
@@ -64,19 +66,12 @@ enum button_state {
        BUTTON_STATE_NONE,
        BUTTON_STATE_AREA,
        BUTTON_STATE_BOTTOM,
-       BUTTON_STATE_BOTTOM_NEW,
-       BUTTON_STATE_BOTTOM_TO_AREA,
        BUTTON_STATE_TOP,
        BUTTON_STATE_TOP_NEW,
        BUTTON_STATE_TOP_TO_IGNORE,
        BUTTON_STATE_IGNORE,
 };
 
-enum scroll_state {
-       SCROLL_STATE_NONE,
-       SCROLL_STATE_SCROLLING
-};
-
 enum tp_tap_state {
        TAP_STATE_IDLE = 4,
        TAP_STATE_TOUCH,
@@ -93,6 +88,12 @@ enum tp_tap_state {
        TAP_STATE_DEAD, /**< finger count exceeded */
 };
 
+enum tp_tap_touch_state {
+       TAP_TOUCH_STATE_IDLE = 16,      /**< not in touch */
+       TAP_TOUCH_STATE_TOUCH,          /**< touching, may tap */
+       TAP_TOUCH_STATE_DEAD,           /**< exceeded motion/timeout */
+};
+
 struct tp_motion {
        int32_t x;
        int32_t y;
@@ -102,7 +103,6 @@ struct tp_touch {
        struct tp_dispatch *tp;
        enum touch_state state;
        bool dirty;
-       bool fake;                              /* a fake touch */
        bool is_pointer;                        /* the pointer-controlling touch */
        int32_t x;
        int32_t y;
@@ -136,16 +136,29 @@ struct tp_touch {
                enum button_event curr;
                struct libinput_timer timer;
        } button;
+
+       struct {
+               enum tp_tap_touch_state state;
+       } tap;
+
+       struct {
+               bool is_palm;
+               int32_t x, y;  /* first coordinates if is_palm == true */
+               uint32_t time; /* first timestamp if is_palm == true */
+       } palm;
 };
 
 struct tp_dispatch {
        struct evdev_dispatch base;
        struct evdev_device *device;
        unsigned int nfingers_down;             /* number of fingers down */
+       unsigned int old_nfingers_down;         /* previous no fingers down */
        unsigned int slot;                      /* current slot */
        bool has_mt;
+       bool semi_mt;
 
-       unsigned int ntouches;                  /* number of slots */
+       unsigned int real_touches;              /* number of slots */
+       unsigned int ntouches;                  /* no slots inc. fakes */
        struct tp_touch *touches;               /* len == ntouches */
        unsigned int fake_touches;              /* fake touch mask */
 
@@ -157,10 +170,6 @@ struct tp_dispatch {
        struct motion_filter *filter;
 
        struct {
-               double constant_factor;
-               double min_factor;
-               double max_factor;
-
                double x_scale_coeff;
                double y_scale_coeff;
        } accel;
@@ -192,19 +201,22 @@ struct tp_dispatch {
        } buttons;                              /* physical buttons */
 
        struct {
-               enum scroll_state state;
                enum libinput_pointer_axis direction;
        } scroll;
 
        enum touchpad_event queued;
 
        struct {
+               struct libinput_device_config_tap config;
                bool enabled;
-               int timer_fd;
-               struct libinput_source *source;
-               unsigned int timeout;
+               struct libinput_timer timer;
                enum tp_tap_state state;
        } tap;
+
+       struct {
+               int32_t right_edge;
+               int32_t left_edge;
+       } palm;
 };
 
 #define tp_for_each_touch(_tp, _t) \
@@ -219,9 +231,6 @@ tp_set_pointer(struct tp_dispatch *tp, struct tp_touch *t);
 int
 tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time);
 
-unsigned int
-tp_tap_handle_timeout(struct tp_dispatch *tp, uint64_t time);
-
 int
 tp_init_tap(struct tp_dispatch *tp);
 
@@ -248,4 +257,7 @@ tp_button_handle_state(struct tp_dispatch *tp, uint64_t time);
 int
 tp_button_touch_active(struct tp_dispatch *tp, struct tp_touch *t);
 
+bool
+tp_button_is_inside_softbutton_area(struct tp_dispatch *tp, struct tp_touch *t);
+
 #endif