termux / termux-x11

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

[Bug]: Android support cursor #533

Closed IntinteDAO closed 8 months ago

IntinteDAO commented 8 months ago

Problem description

Well - I've talked about this problem before - it's not easy to analyze for now.

It seems to me that the cursor in Termux X11 works with some delay. I know that you rewrote the code, but I have a strong impression that this is simply not fixable.

In short, if you plug in the mouse and start using Termux X11 it feels like it doesn't work smoothly, like there's a slight delay that you have to get used to.

My hypothesis is that we have (as in a remote desktop) a local cursor and a remote cursor. The local cursor is the native cursor supported by Android (or any other system). The remote one is the cursor that is "physically" on the remote machine.

My hypothesis is that Termux X11 supports only the remote cursor by default. That is, if I move the mouse, this information must be processed and the change occurs. So something that works at almost instantaneous speed locally takes longer in Termux X11.

Remote desktops (virtual machines, etc.) cheat by simply changing the cursor graphics on the fly. I don't know if such a change is possible from within Android. However, it seems to me that a good option (at least on a trial basis if possible) would be to disable (for testing) Android cursor hiding. Then it would be possible to record a video and see if there is a delay and maybe somehow offset it.

Another option is that mouse capture can change the mouse action in Termux X11. For example, the DPI or some other setting is inconsistent with the default cursor configuration.

What steps will reproduce the bug?

Just work on Android Termux like on real PC?

What is the expected behavior?

No response

twaik commented 8 months ago

Not going to be implemented. The reason is pretty simple: all cursor movements are processed in X server process, not in Activity.

IntinteDAO commented 8 months ago

@twaik I wonder then if the mouse configuration is automatically correct? I mean DPI and so on, does the cursor reflect the real configuration of the mouse.

Is there no other option to manage the mouse? Because I'm assuming Termux can't support USB Passthrough or similar technology?

RalfWerner commented 8 months ago

It seems to me that the cursor in Termux X11 works with some delay

@IntinteDAO What du you mean? There is the pointer (cross/arrow etc), the cursor (inside text), the mouse, fingers on touch-pads/screen and cursor buttons of extrakeys and keyboard. There are also three touchscreen input modes (TIM). Mouse and finger events are treated differently. Compared to older versions, TIM=Simulated touchscreen has to be a delay in the finger Touch+Move (gesture). Otherwise the whole gesture will be ignored. People with trembling fingers or who are used to rapid gestures like me, possibly have problems with it.

I have not yet understood the reason for this change. The pointer is always hidden under the finger at this TIM, in contrast to TIM=Trackpad, where the pointer moves gesture in parallel to the finger-gesture and a long tap leads to the interrupt/end of the gesture. Alternatively use TIM=Direct touch, which not all XClients support or they've own multi-touch gestures (pinch etc) and this TIM is a bit unstable.

I'm assuming Termux can't support USB Passthrough or similar technology?

The use of USB/BT mice is not a problem. I bought a USB hub with which I can move the pointer with 4 mice at the same time

IntinteDAO commented 8 months ago

@RalfWerner

I use Termux X11 with a monitor and mouse. I have the impression that there is some inconsistency in the operation of the cursor with reality. I don't know what it is due to. In my opinion, it's a bit like the cursor is a tank instead of a car. As if there is something wrong with it, it seems to me that there is some input lagg, which on regular computers does not occur (and on Android with a mouse), but it occurs in Termux X11 and does not use well. Maybe it's some other DPI value, I don't know.

I'm having trouble hitting items on the screen because of it. I can't feel that cursor.

twaik commented 8 months ago

Input lag is possible. Cursor is being drawn the same way as the rest of the GUI. It is restriction of technology.

IntinteDAO commented 8 months ago

@twaik

Is it possible to create overdrawing (like in KDE?). So your monitor can display 60 FPS, but the system (X Server) draws 120. In games it's the best option to decrease input lags

twaik commented 8 months ago

X server is configured to get system's native FPS to avoid wasting resources.

TomJo2000 commented 8 months ago

@twaik

Is it possible to create overdrawing (like in KDE?). So your monitor can display 60 FPS, but the system (X Server) draws 120. In games it's the best option to decrease input lags

And you're expecting software rendering on a phone to pull that off?

IntinteDAO commented 8 months ago

@TomJo2000

I don't know if I understand correctly.

Potentially in my opinion (I don't know how Termux X11 works), the problem is partially solvable

I can give various examples. If necessary, I can record (if I can get it working) aVNC on Android.

aVNC has an option to display both cursors at once - Remote and Local. Let's assume that the input lag is 10 seconds. This means that the desynchronization between the local cursor (Android) and the executed operation (Linux) takes so much. However, from the user's side it is less annoying, because he can see the position of the cursor in real time. Remote desktops or virtual machines work on this principle.

PS. Partially solution is to increase mouse acceleration on Android. I think it's much better

TomJo2000 commented 8 months ago

Unfortunately. Neither software nor hardware are in fact magic.

RalfWerner commented 8 months ago

@IntinteDAO What du you mean? (above)

Still unclear what you mean by cursor (green) or pointer (red). I try to make it clearer through a shot. image

The shot was made on a PC monitor with a mirrored Android pad, on which XClients: fluxbox, aterm and Hackers/ExtraKeys-KB. I cannot identify delays on both devices, except a very small one by USB-scrcpy.

Another (white) pointer is displayed on the PC (not in the shot), which is synchronized by press with the pad pointer (red/black). However, this is also done with the three other mice at the Pad USB Hub. The cursor position (green and Keys in yellow) can be changed on all three KB even without a mouse. Unfortunately, the ExtraKeys line covers the fluxbox task list. That was better in the ekeys-version. Hidden here with a three-finger-down image

aVNC is a viewer app for the Xvnc process in Termux. It runs on Android, but there are better once e.g. Real/Multi. Compared to X11, all VNC solutions are worse, slower and a lot that X-Server can do is not possible there.

IntinteDAO commented 8 months ago

@RalfWerner Pointer (red). I don't know if it can be shown on the computer using scrcpy, but I'll see.

RalfWerner commented 8 months ago

Ok :) To solve your delay problem, more information is necessary (devices, XClients, connections etc). The 10 seconds above should not be a real value, right? Differences between 30/60/120 fps cannot perceive "normal" people and scrcpy is not a termux topic. If you record the delay sequence and post here, I could try to repeat it.

IntinteDAO commented 8 months ago

@RalfWerner

scrcpy will not help me here.

I have an idea how to record it, however, it won't show the solution to the problem or the probable causes :D I'll try to do it by Saturday.

RalfWerner commented 8 months ago

You are partly right. scrcpy reflects an Android device via USB/WLAN, which also has a small/large delay compared to the source device. As I wrote above, fingers (more complex) and mouse events (faster) X11 interpreted differently. I like to use it to make records, since movements (yellow circle) and clicks/taps (red circle) are visible, but do not show the real pointer position see here.

At MTE/direct:10 it becomes more complicated and scrcpy interprets the mouse as a finger. In the four gestures: simple (PC mouse), two, three and six fingers (only pad). The more fingers are involved, the greater the delay.

The example movie draws circle = begin, line = movement and square = gesture end in new color for each gesture. Two is sometimes interpreted as "Pinch to Zoom". On a mobile with a small screen, all gestures can only be made of my grandchildren with small fingers.

I don't know - are you a "gamer"? My son is LOL professional and works on gaming PCs. The speed claim is very high. I don't know whether this is on pads or even mobile possible, most likely with USB mouse. However, the "Riot tool" (non-native) had to be installed, which is only possible via Proot, which is also delayed.

IntinteDAO commented 8 months ago

@RalfWerner

Well - I use a mouse (Logitech MX Master 2S) and an external screen usually, so the typical "lag" does not affect me (in theory). However, there is something strange with the mouse.

Maybe it's a DPI issue or a similar system. I don't know how this issue is solved in Termux X11. Maybe I'll find some USB mouse (but on a cable, instead of wireless) and evaluate how it looks.

Overall, I'm a fan of the Termux X11, as I'd like the Termux and the phone to become my little computers for traveling. I'm doing it anyway, however, I'd like it to be as "computer-like" an experience as possible.

RalfWerner commented 8 months ago

I still don't know if you are "a gamer" with high speed claim, how you connected the mouse and monitor to the mobile device and whether you work via Proot. I could not find out under difference between USB/Bluetooth mouse, but I'm not a gamer either. The bold items reduce the speed.

Except for the long-tap delay in gestures TIM= tracked:06 and simulated:11, I also have no problems. Therefore, mostly I usualy use the ekeys:19 version that allow normal gestures simulated=Emulated mouse:06.

DPI shouldn't have any influence. Native (hardware) is identical with 100% Scaled. ekeys only has this preference. I could not find out whether 30%/200% are differently in "non-gamer operation".

Computern für unterwegs

with monitor and mouse in your pocket:)? I'm also a fan of X11 and @twaik does a great job!

IntinteDAO commented 7 months ago

Am I a gamer? If so, a small one. Whereas this mouse is more of a gaming mouse, but I took it because you can switch between 3 devices.

I don't have a monitor simply, I have an HP Elite X3 Lapdock, which allows you to make a smartphone into a computer. It is connected via USB-C cable, and the mouse (wirelessly) via USB with Unifying protocol. I don't use proot, but pure Termux.

I know that Termux-X11 is a great design (although as if to switch to Wayland ... :P) and is crucial in the design of a laptop from a smartphone just like all Termux.

It seems to me that a partial solution to the problem is to increase the cursor speed in Android and decrease it in Xfce4. It seems to me that then it is reasonably acceptable.

RalfWerner commented 7 months ago

HP Elite X3 Lapdock, which allows you to make a smartphone into a computer. It is connected via USB-C cable

My research shows a Windows Lapdock with Android Mobiles via USB-C with expected delays. But you only use the smartphone in your pocket away from home. So far this is comparable to my devices and performance.

as if to switch to Wayland

The current X11 version has separated from Xwayland and Plugin technology (shared ID) and is a pure Xorg server, just as only this part was used - so no Wayland. From the Begin (2019) to the changeover, the Xwayland package was required, but no longer now.

twaik commented 6 months ago

It seems to me that the cursor in Termux X11 works with some delay

I am not sure if it helps or not but check the https://github.com/termux/termux-x11/actions/runs/7949739741 behaviour.

twaik commented 5 months ago

@IntinteDAO ?