Skip to content

Conversation

@gm-vm
Copy link

@gm-vm gm-vm commented Mar 30, 2025

Android O has added support for building gestures incrementally, allowing to send input events almost in real-time.

Older versions of Android will continue to wait for gestures to complete before dispatching them.

@gm-vm gm-vm mentioned this pull request Mar 30, 2025
Android O has added support for building gestures incrementally,
allowing to send input events almost in real-time.

Older versions of Android will continue to wait for gestures to
complete before dispatching them.
// down, was up
if ((buttonMask & (1 << 0)) != 0 && !inputContext.isButtonOneDown) {
inputContext.isButtonOneDown = true;
instance.startGesture(inputContext, x, y);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a regression regarding multi-client input. Please leave the logic client-specific.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I was so focused on getting gestures to work that I didn't even notice that there are multiple InputContext instances. Fixed this here.

void endGesture(InputContext inputContext, int x, int y);
}

private static class LegacyGestureHandler implements GestureHandler {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for these classes IMO, just do the Android version differentiation in the existing handlers .-)

Copy link
Author

@gm-vm gm-vm Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did you have in mind exactly? I'm trying to merge the two handlers, but the code is getting a lot more confusing and hard to follow.

Unrelated: I noticed that you were using System.currentTimeMillis(), which is not monotonic. This means that if the system time changes while there is an ongoing gesture the resulting duration will be wrong. SystemClock.elapsedRealtime() is better for measuring intervals.

gm-vm added 3 commits March 30, 2025 17:46
 - Pass InputContext to the constructor to make the GestureHandler
   interface independent.
 - Remove unnecessary instance methods.
 - Duplicate some comments.
@bk138 bk138 closed this in 6dde810 May 25, 2025
dustinmcafee pushed a commit to rustvnc/RustVNC that referenced this pull request Oct 15, 2025
This makes use of GestureDescription.StrokeDescription.continueStroke() to
be able to dispatch parts of a logical stroke to the OS while the stroke
is continuing.

Credit is due to https://github.com/gm-vm who came up with a first working
implementation I used as a basis for this one.

Co-authored-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>

Closes bk138#69
Closes bk138#285
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.

2 participants