Hi,

On 12-03-15 23:57, Peter Hutterer wrote:
On Wed, Mar 11, 2015 at 03:20:54PM +0100, Hans de Goede wrote:
Extend the touchpad gesture API with pinch gestures. Note that this
new API offers a single event stream for both pinch and rotate data, this
is deliberate as some applications may be interested in getting both at
the same time. Applications which are only interested in one or the other
can simply ignore the other.

Signed-off-by: Hans de Goede <[email protected]>
---
  src/libinput-private.h | 12 +++++++++
  src/libinput.c         | 51 +++++++++++++++++++++++++++++++++++--
  src/libinput.h         | 68 ++++++++++++++++++++++++++++++++++++++++++--------
  src/libinput.sym       |  2 ++
  test/litest.c          |  9 +++++++
  tools/event-debug.c    | 27 +++++++++++++++++++-
  6 files changed, 156 insertions(+), 13 deletions(-)

diff --git a/src/libinput-private.h b/src/libinput-private.h
index 86d1636..c0847bd 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -330,6 +330,18 @@ touch_notify_touch_up(struct libinput_device *device,
                      int32_t seat_slot);

  void
+gesture_notify_pinch(struct libinput_device *device,
+                    uint64_t time,
+                    enum libinput_event_type type,
+                    int finger_count,
+                    double dx,
+                    double dy,
+                    double dx_unaccel,
+                    double dy_unaccel,
+                    double distance,
+                    double angle);
+
+void
  gesture_notify_swipe(struct libinput_device *device,
                     uint64_t time,
                     enum libinput_event_type type,
diff --git a/src/libinput.c b/src/libinput.c
index f49e7fe..5fb0c65 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -87,6 +87,8 @@ struct libinput_event_gesture {
        double dy;
        double dx_unaccel;
        double dy_unaccel;
+       double distance;
+       double angle;
  };

  static void
@@ -196,6 +198,9 @@ libinput_event_get_pointer_event(struct libinput_event 
*event)
        case LIBINPUT_EVENT_GESTURE_SWIPE_START:
        case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
        case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+       case LIBINPUT_EVENT_GESTURE_PINCH_START:
+       case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+       case LIBINPUT_EVENT_GESTURE_PINCH_END:
                break;
        }

@@ -226,6 +231,9 @@ libinput_event_get_keyboard_event(struct libinput_event 
*event)
        case LIBINPUT_EVENT_GESTURE_SWIPE_START:
        case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
        case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+       case LIBINPUT_EVENT_GESTURE_PINCH_START:
+       case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+       case LIBINPUT_EVENT_GESTURE_PINCH_END:
                break;
        }

@@ -255,6 +263,9 @@ libinput_event_get_touch_event(struct libinput_event *event)
        case LIBINPUT_EVENT_GESTURE_SWIPE_START:
        case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
        case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+       case LIBINPUT_EVENT_GESTURE_PINCH_START:
+       case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+       case LIBINPUT_EVENT_GESTURE_PINCH_END:
                break;
        }

@@ -285,6 +296,9 @@ libinput_event_get_gesture_event(struct libinput_event 
*event)
        case LIBINPUT_EVENT_GESTURE_SWIPE_START:
        case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
        case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+       case LIBINPUT_EVENT_GESTURE_PINCH_START:
+       case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+       case LIBINPUT_EVENT_GESTURE_PINCH_END:
                return (struct libinput_event_gesture *) event;
        }

@@ -314,6 +328,9 @@ libinput_event_get_device_notify_event(struct 
libinput_event *event)
        case LIBINPUT_EVENT_GESTURE_SWIPE_START:
        case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
        case LIBINPUT_EVENT_GESTURE_SWIPE_END:
+       case LIBINPUT_EVENT_GESTURE_PINCH_START:
+       case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
+       case LIBINPUT_EVENT_GESTURE_PINCH_END:
                break;
        }

@@ -595,6 +612,18 @@ libinput_event_gesture_get_dy_unaccelerated(
        return event->dy_unaccel;
  }

+LIBINPUT_EXPORT double
+libinput_event_gesture_get_distance(struct libinput_event_gesture *event)
+{
+       return event->distance;
+}
+
+LIBINPUT_EXPORT double
+libinput_event_gesture_get_angle(struct libinput_event_gesture *event)
+{
+       return event->angle;
+}
+
  struct libinput_source *
  libinput_add_fd(struct libinput *libinput,
                int fd,
@@ -1257,14 +1286,16 @@ touch_notify_frame(struct libinput_device *device,
  }

  void
-gesture_notify_swipe(struct libinput_device *device,
+gesture_notify_pinch(struct libinput_device *device,
                     uint64_t time,
                     enum libinput_event_type type,
                     int finger_count,
                     double dx,
                     double dy,
                     double dx_unaccel,
-                    double dy_unaccel)
+                    double dy_unaccel,
+                    double distance,
+                    double angle)
  {
        struct libinput_event_gesture *gesture_event;

@@ -1279,12 +1310,28 @@ gesture_notify_swipe(struct libinput_device *device,
                .dy = dy,
                .dx_unaccel = dx_unaccel,
                .dy_unaccel = dy_unaccel,
+               .distance = distance,
+               .angle = angle,
        };

        post_device_event(device, time, type,
                          &gesture_event->base);
  }

+void
+gesture_notify_swipe(struct libinput_device *device,
+                    uint64_t time,
+                    enum libinput_event_type type,
+                    int finger_count,
+                    double dx,
+                    double dy,
+                    double dx_unaccel,
+                    double dy_unaccel)
+{
+       gesture_notify_pinch(device, time, type, finger_count,
+                            dx, dy, dx_unaccel, dy_unaccel, 0.0, 0.0);
+}
+

maybe more obvious to have a static void gesture_notify() and then call that
from gesture_notify_pinch and gesture_notify_swipe. Less confusing than
calling the notify_pinch from a notify_swipe.

Fixed for the first non RFC posting of this set.


  static void
  libinput_post_event(struct libinput *libinput,
                    struct libinput_event *event)
diff --git a/src/libinput.h b/src/libinput.h
index 1637a64..a005d66 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -178,6 +178,9 @@ enum libinput_event_type {
        LIBINPUT_EVENT_GESTURE_SWIPE_START = 800,
        LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
        LIBINPUT_EVENT_GESTURE_SWIPE_END,
+       LIBINPUT_EVENT_GESTURE_PINCH_START,
+       LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
+       LIBINPUT_EVENT_GESTURE_PINCH_END,
  };

  /**
@@ -957,7 +960,7 @@ libinput_event_gesture_get_finger_count(struct 
libinput_event_gesture *event);
   * @ingroup event_gesture
   *
   * Return the delta between the last event and the current event. For gesture
- * events that are not of type @ref LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, this
+ * events that are not of type LIBINPUT_EVENT_GESTURE_FOO_UPDATE, this

annoying as it is, I'd prefer this spelled out for all possibilities and
@ref'd accordingly.

Also fixed for the first non RFC posting of this set.

Reviewed-by: Peter Hutterer <[email protected]>
otherwise

Regards,

Hans
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to