JoseExposito / touchegg

Linux multi-touch gesture recognizer
GNU General Public License v3.0
3.61k stars 167 forks source link

Is there any way to emulate a keypress along with touchpad gestures? #652

Closed niraularohan closed 6 months ago

niraularohan commented 7 months ago

Is your feature request related to a problem? Please describe

As pinch to zoom is not natively supported by chromium/chrome in X11, a chrome extension comes in really handy. This is my fork to the extension: https://github.com/niraularohan/x11-chrome-pinch-to-zoom. This extension offers a smooth pinch to zoom in webpages but it doesn't work on pinch but rather on the holding of shift key and using two finger touchpad gesture to zoom in and zoom out of webpages in a smooth way (not ctrl +- zoom).

Describe the solution you'd like

I'm trying to trigger this extension's action of the shift keypress along with two finger vertical touchpad gesture in touchegg/touche, but was unable to do that, as we can either only execute a command or simulate keypresses on pinching and not simulate both keypresses and touchpad gesture together.

A clear and concise description of what you want to happen.

I want to trigger this extension's action on pinching the touchpad with two fingers. I actually want touchegg to trigger/execute both shift key press and the vertical two finger touchpad gesture to ensure smooth pinch to zoom like in windows/mac/wayland where chromium supports it natively.

A clear and concise description of any alternative solutions or features you've considered.

I actually modified the extension to be triggered on Shift + Numpad plus and minus keys for zoom in/out respectively, and incorporated those combined shortcuts in touchegg, but it was just not as smooth as the shift+touchpad option with any kind of changes made to the code. I even added css to make it look smooth even with just keypresses but wasn't able to incorporate how I wanted it, and the shift plus touchpad method is just too smooth, and I ended up undoing changes to the extension.

Screencast from 2024-01-27 11-29-27.webm

Here is the screenrecording of the extension's functionality on chrome with X11, when scrolling on the touchpad with two fingers vertically while holding down the shift key for smoothly zooming in/out webpages.

JoseExposito commented 6 months ago

If I understood correctly, the extension requires pressing Shift and then it reads the scroll events from the touchpad to zoom in and out.

It won't be possible to use Touchégg to emulate this in a smooth way.

You can use the run command action: https://github.com/JoseExposito/touchegg?tab=readme-ov-file#execute-a-command-run_command

To run a custom bash script that uses 'xdotool' to emulate everything, but it won't be as smooth as using the touchpad scroll.

niraularohan commented 6 months ago

I eventually used xdotool and executed the command as you suggested shortly after opening this issue. However, as you mentioned, it was not smooth at all. Is there any other way to ensure smoothness? If not through touchegg directly, is it at least theoretically possible? If so, how do you think it can be implemented?

JoseExposito commented 6 months ago

Honestly, the only right place to implement this functionality is in Chrome. Any other option is just a workaround.

In theory, you could do something similar to what Touchégg does reading libinput events directly and, when pinch events are received, start emulating scroll events with similar deltas.

niraularohan commented 6 months ago

Thanks for the answer!