marsqing / libinput-three-finger-drag

Three-finger-drag support for libinput
MIT License
102 stars 15 forks source link
gestures gestures-recognition linux three-finger-drag touchpad trackpad

THREE FINGER DRAG

OSX users will miss the three-finger-drag feature when switch to Linux. With that feature, you can easily select text or drag something around. On Linux, there are two common options to achieve this:

  1. mtrack

set the following options in xorg.conf and you get three-finger-drag

Option "SwipeUpButton" "1"
Option "SwipeDownButton" "1"
Option "SwipeLeftButton" "1"
Option "SwipeRightButton" "1"

The problems of mtrack are:

  1. libinput-gestures

libinput-gestures do not natively support three-finger-drag. You need to use this fork three-finger-drag fork which is mentioned in this libinput-gestures three-finger-drag issue. As the author of libinput-gestures replied, libinput-gestures won't support three-finger-drag due to "To implement this would be messy, require significant processing overhead, and is discordant with the current design.".

so if you use the three-finger-drag fork of libinput-gestures:

INSTALLATION

So with this tool, you can use three-finger-drag with libinput(the underlying tool libinput-gestures based on). You probably will use it with libinput-gestures side by side to add three-finger-drag support.

From Source

1. clone the repo
2. install libinput(you probably have it already)
3. install xdotool(which includes libxdo)
4. cargo build --release
5. copy target/release/libinput-three-finger-drag to somewhere
6. disable 3 finger swipe gesture in libinput-gestures, see below
7. run libinput-three-finger-drag and check whether it works
8. make libinput-three-finger-drag auto-start

Download binary

1. download precompiled binary from release page
2. disable 3 finger swipe gesture in libinput-gestures, see below
3. run libinput-three-finger-drag and check whether it works
4. make libinput-three-finger-drag auto-start

Options

You can specify an acceleration value as a parameter, which will be multiplied with all 3-finger gesture movements:

libinput-three-finger-drag 1.4

Disable 3 finger swipe gesture in libinput-gestures

Modify libinput-gestures config file /etc/libinput-gestures.conf or ~/.config/libinput-gestures.conf. Add finger_count 4 to essentially disable 3 finger swipe.

change

gesture swipe up  xdotool key super+Page_Down 

to

gesture swipe up  4  xdotool key super+Page_Down

HOW IT WORKS

Just like libinput-gestures. Fork

libinput debug-events

and read the output, which is trackpad "raw events". Filter out events of GESTURE_SWIPE_BEGIN, GESTURE_SWIPE_UPDATE and GESTURE_SWIPE_END. Simulate mouse_down on BEGIN, mouse_relative_move on UPDATE and mouse_up on END with libxdo. These three mouse action simulate a three-finger-drag. Call libxdo is more efficient than fork xdotool like libinput-gestures does. Especially when processing GESTURE_SWIPE_UPDATE events which is more frequent than BEGIN and END.