termux / termux-x11

Termux X11 add-on application.
https://termux.dev
GNU General Public License v3.0
1.85k stars 290 forks source link

Trackpad variable speed issue (with display scale 150%) #554

Closed jeroen256 closed 5 months ago

jeroen256 commented 6 months ago

Trackpad variable speed (with display scale 100%) I find a nice feature and works well.

But when I use a higher display scale, for example 150%, it becomes increasingly difficult to move the cursor at low speed. Try moving the cursor slowly using trackpad at display scale 200%, it almost gets stuck.

I think this is a bug, otherwise an option to disable the variable speed of the cursor I would appreciate.

If I may propose a possible solution: maybe a condition that the cursor never gets slow down (to lower than the actual finger speed). Only potentially accelerated when the finger moves fast.

twaik commented 5 months ago

I think I can make touchpad pointer use the same scale factor as applied to screen. I'll try it later.

twaik commented 5 months ago

Ok. For some reason Android's GestureDetector has some other scale factor or I failed to find the place where my code applies some other factor to distance. You can disable scale factor at all after https://github.com/termux/termux-x11/commit/6db747577fa45f5c2b9ca3bdfdc14e0fa88d51c7 .

jeroen256 commented 5 months ago

Thank you so much for taking the effort to troubleshoot this and adding the option "Apply display scale factor to touchpad".

I have tested the option both selected and unselected but unfortunately in my case it doesn't appear to make a difference.

When I move my finger very slowly in touchpad mode (with high display scaling factor applied) the mouse cursor is still almost stuck and hardly moves at all.

For now setting display scale to 100% fixes it, but on small phone screen I would prefer 150%. Maybe it is Motorola Edge 30 Ultra specific issue...

ewt45 commented 5 months ago

is this a mistake in the fix? https://github.com/termux/termux-x11/blob/master/app/src/main/java/com/termux/x11/input/TouchInputHandler.java#L350 where distanceX and Y has been multiplied optionally, but when sending them as params to moveCursorByOffset, they are multiplied again unconditionally.

after adjust this part of code i made some tests.

  1. disable scale factor:
    • 100% scale: cursor doesn't follow exactly the location of finger, some distance are lost
    • 150% scale: the cursor can merely catch up with the finger.

https://github.com/termux/termux-x11/assets/79033456/1cd99987-9d92-4bc5-966b-fda52598aef6


  1. enable scale factor
    • 100% scale: cursor moves slower
    • 150% scale: cursor moves slower than slower
    • 200% scale: cursor can hardly move

https://github.com/termux/termux-x11/assets/79033456/057237f9-c4b7-4f67-92a4-4ffcc060ccbd


I'm not sure if this is a device specific problem

twaik commented 5 months ago

Thank you, fixed this. There is no multiplying twice in the latest build.

ewt45 commented 5 months ago

got it. also i find out the reason why the cursor moves slower than finger when scaling is 100% in Trackpad mode., the method moveCursorByOffset floors the position from float value to int value. so every offset is shrinked a little bit. https://github.com/termux/termux-x11/blob/master/app/src/main/java/com/termux/x11/input/TouchInputHandler.java#L275

the sub processes of pointer location support float value, and after removing the (int) conversion, now cursor moves at the same speed with finger on my device. could you please fix this too?

twaik commented 5 months ago

You are right. It seems like that int conversion was there since I was experimenting with mouse modes. I'll remove it right now.

jeroen256 commented 5 months ago

Super, it works very well now!

In my opinion the newly added option "Apply display scale factor to touchpad" could be removed again, if you so desire. The default value "true" works very well for me. The value "false" currently makes my cursor move way too fast for my taste (but this could maybe differ for others).

Thank you all twaik and ewt45 very much! :-)