summary history branches tags files
commit:6850cf1f72162f5a5b49c901556ef4cbcd1a09a0
author:Trevor Bentley
committer:GitHub
date:Thu Jul 27 17:06:56 2017 +0200
parents:b56ccf5ddc4de61dcff892a61ba8de5cc92c5539, 4e510c241859e40a7f73310f722b6ba9dc65a044
Merge pull request #10 from mrmekon/swipe_failure_detection

Add swipe states for cancelled and failed swipes.
diff --git a/src/interface.rs b/src/interface.rs
line changes: +7/-0
index f60eb50..ce0fe2f
--- a/src/interface.rs
+++ b/src/interface.rs
@@ -88,6 +88,13 @@ pub enum SwipeState {
     Changed,
     /// Swipe gesture has ended (finger lifted)
     Ended,
+    /// Swipe was cancelled by user
+    ///
+    /// Happens when interrupted, such as when doing a single-finger swipe and
+    /// then putting down a second finger.
+    Cancelled,
+    /// Swipe failed... I dunno, ask Apple.
+    Failed,
     /// Invalid state.  Never sent to callbacks.
     Unknown,
 }

diff --git a/src/touchbar.rs b/src/touchbar.rs
line changes: +3/-1
index de41d95..b26ddd1
--- a/src/touchbar.rs
+++ b/src/touchbar.rs
@@ -1163,9 +1163,11 @@ impl INSObject for ObjcAppDelegate {
                         2 => SwipeState::Changed,
                         // NSGestureRecognizerStateEnded
                         3 => SwipeState::Ended,
-                        // NSGestureRecognizerStatePossible,
                         // NSGestureRecognizerStateCancelled,
+                        4 => SwipeState::Cancelled,
                         // NSGestureRecognizerStateFailed
+                        5 => SwipeState::Failed,
+                        // NSGestureRecognizerStatePossible,
                         _ => SwipeState::Unknown,
                     };
                     if state != SwipeState::Unknown {