Locked Drags (Click Lock) in Ubuntu (Linux)

In Windows I was using "Click Lock" feature that allow me to select/drag comfortable using only one hand and touchpad.
For example I am clicking on a file and press the mouse button down (or tap and hold finger down) a little time, then the cursor became locked. Then, I can change my finger position with no need still pressing the touchpad. So, I can move the dragged file to far distances, easily.

I am searched for this feature in Ubuntu. It called "Locked Drags".
Here is how to activate it.

In terminal type the following command to see the devices. 

xinput list

Look for the trackpad and make a note of its id# (mine is id=12). Then filter options for locked drags,

xinput list-props 12 | grep Lock

Replace '12' with your id. Make a note of the options IDs (in parentheses) for easy access.
Now, need to set "Locked Drags" to 1, and timeout to whatever is comfortable for you.
I don't like auto drop. I prefer to click second time to finish the drag manually. So I set big value like 10000 ms.

xinput set-prop 12 278 1
xinput set-prop 12 279 10000

278 is my option ID for Locked Drags, and 279 is the option ID for Locked Drags Timeout.

And now, the click lock should be activated.

By the way, In Windows this click lock became active after a little time if the tap is continue. Windows allows to change this little time.
To activate click lock the mouse button or (finger on touchpad) should holded down during this little time.

In Ubuntu, drag starting with no delay. This is annoying.
I searched and tried somethings but no result. If you have an idea please comment.

 

Update: 2016-12-24

It's a pity that Ubuntu still doesn't have the "Click Lock" feature. :(

By the passed time, I am better in Ubuntu now.
Today I have spent about 6 hours to be able to trigger the drag with delay. I tried many things and finally achieved something! :)
I created bash script file and added it to the startup so that it works automatically.

The script will check for BUTTON 1 if it is DOWN on touchpad. If it is DOWN, there will be a short 1-2 seconds waiting. Then if BUTTON 1 still in DOWN state, the "Locked Drags" property will be enabled.
On the other hand, when a click completed (BUTTON 1 is not in DOWN mode anymore), "Locked Drags" property will be disabled again.

I tested it on XUbuntu 16.04.

Here is the script:

#! /bin/bash

loop_interval=1;

#touchpad device id
devid=$(xinput list | grep -ioP "touchpad.*id=\K\d+");

#Locked Drags property id... for enable / disable...
propid=$(xinput list-props $devid | grep -ioPz "Locked Drags \(\K\d+");

#to change drag timeout get the related property id:
# xinput list-props $devid | grep -ioPz "Locked Drags Timeout"

#if not found... exit
[ $propid -le 0 ] || [ $devid -le 0 ] && exit;

while  (true);
do
#button 1 state.. 
btn1_state=$(xinput query-state $devid | grep -oizP "button\[1\]=\K\b.*\b");

if [[ "$btn1_state" == "down" ]];
then
    echo down_duration: $down_duration;
    
    #if mouse button 1 pressed for the minimum time, make the button down 
    if [[ $down_duration -gt 0 ]] ; 
    then 
        #enable drag lock
        xinput set-prop $devid $propid 1 ;
        islocked=true;
        #xdotool mouseup 1;
        #start a new press
        #xdotool mousedown 1;
        echo Locked Drags enabled.
    fi;

    down_duration=$(( down_duration + loop_interval ));
else
    down_duration=0;
    if [[ "$islocked" == "true" ]];
    then
        xinput set-prop $devid $propid 0;
        islocked=false;
        echo Locked Drags disabled.
    fi
fi;

sleep $loop_interval ;
done;

#get mouse and buttons state..
#xinput query-state 12
#button[1]=up

 


Reference:

Share Share Editor: editor | Posted: 2012/07/23 | Views: 14398

Comments

9 + 20 =
Steven Shaw 06/28/2014 00:57:37
Thank you! Message
riuryK 10/21/2012 04:20:16
Thanks a lot. Thanks to posts like this one, people like me can find the solution years later. No need to alter the configuration file, no patches, nothing! Your solution is simply great! Thanks a lot!
Home | Search | Contact | Terms
Editor