Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three finger drag #173

Closed
buzuddha opened this issue May 13, 2020 · 27 comments
Closed

Three finger drag #173

buzuddha opened this issue May 13, 2020 · 27 comments

Comments

@buzuddha
Copy link

buzuddha commented May 13, 2020

First, let me say: WOW! What a wonderful piece of software you've written! This truly makes ubuntu feel closer to the mac trackpad experience and I really value what you've done here.

Two mac trackpad features that I use constantly are the three-finger select and the three-finger drag. Perhaps you are aware, but if not, they work as follows:

hold down three fingers on text and swipe -> selects text as if left click was held during swipe
hold down three fingers on the top of a window or a file icon -> drags file/window as if left click was held during swipe

I have considered this program:
https://martys.typepad.com/blog/2015/08/3-finger-drag-on-linux.html
However I really want to start using two touchpad programs at the same time. That sound like it will just cause problems, plus this page looks old anyhow and may not be compatible with ubuntu 20.04.

I'm sure you're quite busy, and I don't know how widely used the three-finger finger drag/select is. Mac took it out of the main touchpad settings and hid it deeper in the preferences, so perhaps I'm alone in liking this one. My wife doesn't use it on her work computer so perhaps it's not popular.

I just sent $10 your way for fusuma as is!

Thanks!

@iberianpig
Copy link
Owner

Hi @buzuddha,
I was surprised to find PayPal and this issue 10 minutes ago. Thank you, I'm very happy.

I'm thinking of implementing a three-finger scrolling feature. #170

I believe this is closer to the drag function you describe.
Simply put, the idea is for a feature that detects slow swipes.

@iberianpig
Copy link
Owner

iberianpig commented May 13, 2020

Assume that I add a new parser plugin to Fusuma for a scrolling event.
It generates events like "scroll begin", "scroll update", "scroll end".
By assigning actions to these, the 3 or 4 finger scrolling function can be achieved.

I think there is another issue with the create the Drag function.
The libinput that Fusuma depends on will stop moving the cursor when it detects a 3,4 finger gesture. I think that It's hard to unlock this.

But, I noticed that external touchpad or mouse can also moves cursor.
Moving the cursor on the uinput virtual device should emulate the cursor's movement.
The cursor follows even with three fingers, so it should look like it's behaving like a real drag function.

@buzuddha
Copy link
Author

buzuddha commented May 14, 2020 via email

@iberianpig
Copy link
Owner

Yes, that's right!
It's going to take some time, but I believe this can be implemented.

@buzuddha
Copy link
Author

buzuddha commented May 14, 2020 via email

@stale
Copy link

stale bot commented Jul 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 13, 2020
@stale stale bot closed this as completed Jul 20, 2020
@pgiraud
Copy link

pgiraud commented Nov 25, 2020

so perhaps I'm alone in liking this one.

No you're not! I use it a lot on my mac as well.
It works for anything that can be dragged: for example (window) resize handles.
I'd love to see something implemented.

@iberianpig iberianpig reopened this Nov 26, 2020
@stale stale bot removed the wontfix label Nov 26, 2020
@ggrrll
Copy link

ggrrll commented Dec 8, 2020

Thanks also from my side for the nice tool! -- it really helps me transitioning back to Ubuntu 😅

btw, I would also appreciate very much the 3-fingers text selection -- happy to help testing of course
(unfortunately I don't have experience with ruby :/ )

@andrenbrandao
Copy link

@ggrrll I also would want to have the 3-fingers text selection. Anyway, I am already happy by having the 3-finger and 4-finger movements!

@v-ko
Copy link

v-ko commented Jan 1, 2021

Here's a workaround https://github.com/daveriedstra/draggy written in python, using evdev (not mine). It can work alongside fusuma, but mind you there's no conditional suppression of the three finger gestures by draggy (so both the drag event - if you have one configured - and the fusuma gesture are activated). The other option I saw was a fork of libinput-gestures by the same dev, but I had trouble testing it. Draggy seems like the best available option until this functionality is integrated in fusuma, since the libinput-gesture devs will not be integrating such functionality.

@iberianpig
Copy link
Owner

iberianpig commented Feb 24, 2021

I'm implementing real-time, high-frequency updating gestures right now.

109084863-ec8f5100-774b-11eb-930f-b2c73f96ac0b.mp4

@v-ko
Copy link

v-ko commented Mar 1, 2021

Given the timing I'll guess you're using the implementation in the new libinput release? https://www.phoronix.com/scan.php?page=news_item&px=Libinput-1.17-Released

@iberianpig
Copy link
Owner

iberianpig commented Mar 1, 2021

I was very surprised as I did not know about the new 1.17 release.

My implementation works with the old libinput so far. It's just a simple hack to bind the start, update, and end of swipe and pinch events to YAML.

However, I'm curious about the API update for libinput 1.17. Thanks for letting me know!

@buzuddha
Copy link
Author

buzuddha commented Mar 5, 2021

That looks just like what I'm hoping for! Please let us know when you release this and also how to implement it on our own computers!

@iberianpig
Copy link
Owner

I'm planning to release fusuma v2 soon. Then 3-finger dragging will be available, so please wait a bit👍
@buzuddha
I'll let you know in this thread😊

@buzuddha
Copy link
Author

buzuddha commented Mar 6, 2021 via email

@iberianpig
Copy link
Owner

@buzuddha

Thanks for your patience. fusuma v2 has been released.
Now you can support continuous gestures and contexts.

see: #224

Please update fusuma and plugins

sudo gem update fusuma
sudo gem update fusuma-plugin-XXXX

Three-finger drag can be configured with the following config.

swipe:
  3:
    begin:
      command: xdotool mousedown 1
    update:
      command: xdotool mousemove_relative -- $move_x, $move_y
      interval: 0.01
      accel: 2
    end:
      command: xdotool mouseup 1

@v-ko
Copy link

v-ko commented Apr 12, 2021

Thanks for implementing that @iberianpig , it works great.

@carlespibernat
Copy link

Amazing! I've been looking for this a lot of time!
Just one question, on MacOS, when releasing the three fingers, it waits for a while so that, if I swipe again with the three fingers, it remains in drag and drop mode.
Would there be a way to simulate the same behavior with Fusuma?

@iberianpig
Copy link
Owner

I get the need for this feature.

We must change the swipe detector or create an another detector to keep dragging gesture mode. It could be tough. It might need to ignore when fingers reduce to one or lift off to keep in drag mode.

@jncsotk30
Copy link

jncsotk30 commented Apr 16, 2024

For anyone looking for additional help with this on wayland, you have to use ydotool instead of xdotool. The syntax is a little bit different, but it still works. Note, I'm using Fedora 39 | 6.8.5 Kernel. Shouldn't matter too much, but just letting you know.

First install ydotool via dnf or yum...

sudo dnf install ydotool

Once installed, if you try to run it, it may complain about permissions and be started as root which won't work for this purpose. You need to modify the ydotool service to start as your user as well as set the socket path for the tool. To do that, modify the ydotool.service file under /usr/lib/systemd/system.

You can use...
sudo vim /usr/lib/systemd/system/ydotool.service

In the ExecStart line, you'll need to add two parameters for ydotool...

  1. --socket-own=[UID]:[GID]
  2. --socket-path=/home/[your-username]/.ydotool_socket

By default, I think the socket-path is set to /tmp/ydotool_socket, but because we're running ydotool as our user in the service, it instead looks under home dir. I think you can set this to wherever, but I did my home dir.

To get the UID & GID, you can use a terminal to echo those environmental variables.

echo $UID
echo $GID

Those two numbers will be put in place in the --socket-own parameter separated by colon(:).

Once the ExecStart line is edited, it should look like this...

ExecStart=/usr/bin/ydotool --socket-own=1000:1000 --socket-path=/home/[your-username]/.ydotool_socket

Of course, replace [your-username] with your actual username

After that, you can save and exit vim, then enable & start your ydotool service.

sudo systemctl enable ydotool
sudo systemctl start ydotool

Check the status of the service to ensure startup was okay.


After ydotool is configured properly, follow the instructions in the fusuma documentation for adding your user to the input group in fusuma docs (best to logout after adding so the change sticks). After that, setup your fusuma config file with the following to enable three finger drag.

swipe:
  3:
    begin:
      command: ydotool click 40
      interval: 0.00
    update:
      command: ydotool mousemove -- $move_x, $move_y
      interval: 0.01
      accel: 1.70
    end:
      command: ydotool click 80

NOTE 1
The 40 and 80 numbers seen above correspond to the click event numbers. I don't actually remember how I got them, but that's what they mean.

40 should mean three fingers place on trackpad
80 should mean three fingers lifted off trackpad

I'll try to update with more details for the events if I can find.

NOTE 2
I updated the config with interval: 0.00 on the begin command. I noticed there was a half second or so delay between when I put three fingers on trackpad and when activity happened (movement of window, highlight etc). Adding the interval as 0.00 seems to fix that so it's immediate recognition of fingers on trackpad (like MacOS)

NOTE 3
If you update ydotool, this service file will get overwritten. I'm not quite sure if you can setup a local service file or not, but you will need to update the service ExecStart line after update back to the above docs.

Resources / Credit...

#173 (comment)
https://askubuntu.com/a/1413830
ReimuNotMoe/ydotool#161 (comment)

@tomyrseth
Copy link

tomyrseth commented May 5, 2024

Sorry not sure where to ask, but is fusuma supported on ubuntu 24.04 LTS? 3 finger text select works somewhat, had to disable multiple workspaces (desktops), but when I do 3 finger swipe up it does the same as pressing windows button (super button) which is annoying I havent found a way to disable it in settings.

3 finger swipe to move windows around does not work, the mouse stays still in place while output in terminal is:

I, [2024-05-05T20:54:12.079851 #13107]  INFO -- : ---------------------------------------------
I, [2024-05-05T20:54:13.103969 #13107]  INFO -- : {:command=>"xdotool mousedown 1", :args=>{:move_x=>-0.28, :move_y=>0.0, :unaccelerated_x=>-0.79, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.206849 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.75, :move_y=>0.11, :unaccelerated_x=>-0.79, :unaccelerated_y=>0.11, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.217047 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.91, :move_y=>0.0, :unaccelerated_x=>-0.91, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.226204 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.68, :move_y=>0.11, :unaccelerated_x=>-0.68, :unaccelerated_y=>0.11, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.235859 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-1.02, :move_y=>0.23, :unaccelerated_x=>-1.02, :unaccelerated_y=>0.23, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.246088 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-1.02, :move_y=>0.0, :unaccelerated_x=>-1.02, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.256070 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.32, :move_y=>0.0, :unaccelerated_x=>-0.34, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.266945 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.58, :move_y=>0.19, :unaccelerated_x=>-0.68, :unaccelerated_y=>0.23, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.276380 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.79, :move_y=>0.11, :unaccelerated_x=>-0.79, :unaccelerated_y=>0.11, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.285719 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.31, :move_y=>0.0, :unaccelerated_x=>-0.34, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.296124 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.59, :move_y=>0.0, :unaccelerated_x=>-0.68, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.316449 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.58, :move_y=>0.0, :unaccelerated_x=>-0.68, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.325870 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.91, :move_y=>0.0, :unaccelerated_x=>-0.91, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.335743 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.32, :move_y=>0.11, :unaccelerated_x=>-0.34, :unaccelerated_y=>0.11, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.368031 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.57, :move_y=>-0.1, :unaccelerated_x=>-0.68, :unaccelerated_y=>-0.11, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.416986 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.43, :move_y=>0.0, :unaccelerated_x=>-0.68, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.435950 #13107]  INFO -- : {:command=>"xdotool mousemove_relative -- $move_x, $move_y", :args=>{:move_x=>-0.43, :move_y=>0.0, :unaccelerated_x=>-0.68, :unaccelerated_y=>0.0, :zoom=>0.0, :rotate=>0.0}}
I, [2024-05-05T20:54:13.662855 #13107]  INFO -- : {:command=>"xdotool mouseup 1", :args=>{:move_x=>0.0, :move_y=>-0.04, :unaccelerated_x=>0.0, :unaccelerated_y=>-0.11, :zoom=>0.0, :rotate=>0.0}}

I followed this https://github.com/iberianpig/fusuma/wiki/3-fingers-Drag-(OS-X-Style)

@iberianpig
Copy link
Owner

Are you using Wayland?
The three-finger swipe is controlled by the compositor on GNOME wayland and cannot change it, so on the fusuma side, you could assign the swipe to a different number of fingers, or create a Gnome override like this https://gist.github.com/iberianpig/6e7049a02489950f570b4a27cff8df5e to change the default swipe tracker from 3 fingers to 4, or to 5 to disable it.

@lVentus
Copy link

lVentus commented May 16, 2024

I get the need for this feature.

We must change the swipe detector or create an another detector to keep dragging gesture mode. It could be tough. It might need to ignore when fingers reduce to one or lift off to keep in drag mode.

I''m thinking, can we do it like this. give 'end' event a property 'delay', for example 500 ms. when 'end' event happen, it delay to run the command. if before the time finish, 'begin' happened again, then do not run 'end' command, and keep 'update' command.

@Kaeen
Copy link

Kaeen commented Oct 18, 2024

I get the need for this feature.
We must change the swipe detector or create an another detector to keep dragging gesture mode. It could be tough. It might need to ignore when fingers reduce to one or lift off to keep in drag mode.

I''m thinking, can we do it like this. give 'end' event a property 'delay', for example 500 ms. when 'end' event happen, it delay to run the command. if before the time finish, 'begin' happened again, then do not run 'end' command, and keep 'update' command.

Yes, currently the only difference between native MacOS behavior and the three-finger-drag-n-drop one is that using fusuma I can't quickly resume to drag-n-drop action after I put fingers off my touchpad (e.g. if I need longer drag while my fingers met touchpad border).

Maybe there could be a hack like delayed command launch (I mean launching script with delayed 'end' command and cancelling that delayed 'end' command in 'begin' command). Have strong concern on performance. :)

@Nashenas88
Copy link

@Kaeen I got it working with the following configuration:

swipe:
  3:
    begin:
      command: 'rm "$HOME/.config/fusuma/delay"; ydotool click 40'
      interval: 0.00
    update:
      command: ydotool mousemove -- $move_x, $move_y
      interval: 0.01
      accel: 2.00
    end:
      command: 'touch "$HOME/.config/fusuma/delay"; sleep 1; if [ -f "$HOME/.config/fusuma/delay" ]; then ydotool click 80; fi'
      interval: 0.0

The only issue I'm seeing is that moving the mouse (even with just one finger) will still move the highlighted area until the timer is done. It's not perfect but definitely lets you lift up and continue the drag where you left off.

@leonardorifeli
Copy link

tks @iberianpig, it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests