PeterCxy / evdev-right-click-emulation

Implement Long-Press-to-Right-Click on Touchscreen Linux Devices with Xorg or Wayland
Do What The F*ck You Want To Public License
90 stars 32 forks source link

Menu not opened at the touch location on Wayland #9

Open groszdaniel opened 3 years ago

groszdaniel commented 3 years ago

On Wayland (unlike on XOrg) touch input does not move the mouse pointer to the location of the touch. When a right-click is simulated, the popup menu opens at the current location of the cursor, not at the place of the touch. This may open a different menu than the intended one. (I don't know what happens on devices without a mouse at all.)

Is there a way to fix this? I'm afraid not without interacting more directly with Wayland, unless there is a way to simulate an absolute pointer device event that does cause Wayland to move the the cursor.

groszdaniel commented 3 years ago

Actually it should be possible: ydotool can move the cursor to an absolute location. It looks like the trick is to first do a move to (-INT32_MAX, -INT32_MAX) which in reality moves the mouse cursor to (0,0), and then a relative move to the specified location. However, we would need to know how the touchscreen is mapped to the X11/Wayland coordinate system.

nintendoeats commented 7 months ago

I know it's a bit late but... I have a local build without this problem. The solution is to speciy ABS_X and ABS_Y events just before submitting the right click.

The only reason I haven't submitted a PR is that my fquick ix requires the first whitelisted touch device to be the ONLY touch device, since the virtual device has to have the same minimum/maximum/resolution as the real touch device.

I think the long term solutions are either:

  1. Maintain one "Shadow" virtual device for each touch device, with the appropriate settings.
  2. Figure out how to calculate the "screen" ABS_X and ABS_Y from those settings and send adjusted coordinates to the right click function.

Not really sure which is best, open to suggestions.