marsqing / libinput-three-finger-drag

Three-finger-drag support for libinput
MIT License
87 stars 11 forks source link

FR : Allow to continue drag after repositioning fingers #7

Open fatg3erman opened 2 years ago

fatg3erman commented 2 years ago

First, thank you so much for this project, three finger drag is almost the only thing I miss from macOS. And I miss it a lot :)

I have a feature request. On the mac, it's possible to 'continue' a drag. It's hard to explain so suppose you're selecting a large block of text in an editor by dragging over it. You reach the bottom of the trackpad. On macOS, if you quickly lift your fingers off, and then carry on three-finger-dragging from the top of the pad, the drag action will continue from where it left off - so you carry on growing the block of text you're selecting.

Currently with libinput-three-finger-drag, as soon as you lift your 3 fingers off the touchpad the drag action stops, so it's not possible to select a block of text larger than the area you can drag your fingers over. I think it needs some kind of timer so that when you lift your fingers off it doesn't terminate the drag action immediately, and then ignores the next drag start and just continues dragging.

I did have a quick look at the code but I don't know what language that is :)

fatg3erman commented 2 years ago

I just built the latest version from source and I notice it does now have this feature!

However, for me at least, the 600ms delay is too quick. I hacked it up to 900 which is much more comfortable. Would be nice if it was a command line parameter, like acceleration, perhaps?

fatg3erman commented 2 years ago

Something like this perhaps:

libinput-three-finger-drag 1.6 900

diff --git a/src/main.rs b/src/main.rs
index f235815..77bdee1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,6 +16,12 @@ fn main() {
     } else {
         acceleration = 1.0;
     }
+    let mouseupdelay: i64;
+    if args.len() > 2 {
+        mouseupdelay = args[2].parse::<i64>().unwrap_or(600);
+    } else {
+        mouseupdelay = 600;
+    }

     let output = Command::new("stdbuf")
         .arg("-o0")
@@ -68,7 +74,7 @@ fn main() {
                     if cancelled {
                         xdo_handler.mouse_up(1);
                     } else {
-                        xdo_handler.mouse_up_delay(1, 600);
+                        xdo_handler.mouse_up_delay(1, mouseupdelay);
                     }
                 }
                 "GESTURE_HOLD_BEGIN" => {
@@ -89,4 +95,4 @@ fn main() {
             xdo_handler.mouse_up(1);
         }
     }
-}
\ No newline at end of file
+}

(Immediately acquired a liking for whatever language this is. Rust?)

ferstar commented 1 year ago

@fatg3erman I have implemented this feature in another way which is much more efficient: https://github.com/ferstar/gestures have a try pls:-)