Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undo touch gesture #5133

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

superenginegit
Copy link

This PR adds an undo gesture - tapping the touchscreen with two fingers. If motion is detected during the touch it is rejected to not interfere with zooming or scrolling.
I also added a checkbox in the settings' Touchscreen tab to toggle it on or off.
I suggested this feature in #5023

@tmoerschell
Copy link
Contributor

tmoerschell commented Sep 12, 2023

Great feature! Love to see this being implemented. It works well on my side.
A few little things:

  • Since touchscreens are quite fine-grained nowadays, intended taps can be interpreted as a motion. Would it be possible to allow minimal motion ?
  • With the current implementation, you can scroll with one finger and then tap with the second one and undo will be triggered. I think that case should be excluded as it is probably not an intentional tap.
  • The way you did your first commit, line 81 of https://github.com/superenginegit/xournalpp/blob/undo-gesture/src/core/gui/inputdevices/TouchInputHandler.cpp will never be executed.
  • You seem to be moving some settings around in your last commit. Was this intentional?

@superenginegit
Copy link
Author

Since touchscreens are quite fine-grained nowadays, intended taps can be interpreted as a motion. Would it be possible to allow minimal motion ?

I really like that idea. I think allowing a movement of a few pixels around the starting point of the tap would be a good way to do this.

With the current implementation, you can scroll with one finger and then tap with the second one and undo will be triggered. I think that case should be excluded as it is probably not an intentional tap.

I agree, that should be excluded.

You seem to be moving some settings around in your last commit. Was this intentional?

unintentional, I'll undo that.

@superenginegit
Copy link
Author

The gesture now only gets canceled if the distance between the starting point of a tap and the current position exceeds 5 pixels. This applies for each finger separately.

Also accidentally tapping the screen while actively scrolling should not trigger the undo. But if you stop scrolling and then tap it should undo.

@bhennion
Copy link
Contributor

This will conflict with #4861 (especially if you want to implement a 3 fingers redo gesture).

@superenginegit
Copy link
Author

I think I would be able to solve these conflicts if necessary.

A redo gesture generally sounds like a good idea to me, but I would rather use something other than a 3 finger tap to avoid conflict with system gestures. But I don't have any ideas for a gesture that would fit intuitively.
Also this would make any conflicts harder to resolve so I would rather do this in the future than now.

@tmoerschell
Copy link
Contributor

I have used this for some time now and have a few remarks:

The up-to-five-pixels-motion is good, but there is a delay between the tap and the actual undo, which can get really annoying. I ended up reverting to the simple version, which is instantaneous.

A three-finger tap will also trigger an undo (I know you've implemented an exception for this to be dropped, but it seemingly isn't caught). Pulling with three fingers, to to switch workspaces or other, triggers it as well. I guess the desktop environment takes over three-finger events, so xournal++ will see only a two-finger tap. I wonder how it would be possible to catch this. (I'm on KDE Wayland, maybe it's not consistent between different setups. )

I also have some issues with hand recognition not working quite properly, which did also cause some false positive undos. It's better with the simple (1px) version, but not 100% good either. I guess that's also a situation where xournal++ should probably receive more than 2 inputs and maybe it doesn't. So maybe a fix for the above issue will also solve this. Another workaround could be to set a maximum distance between the two fingers (but it's is not guaranteed to work and I don't really like limitations like this).

The touchscreen input code does indeed feel like it needs a good rework... It's probably wise to wait until #4861 is merged before putting too much work into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants