Skip to content

Commit

Permalink
Fix(gui event processor): remove double clicks, handle all res when t…
Browse files Browse the repository at this point in the history
…racking still finger, instant clicks (#5635)
  • Loading branch information
Mathias-Boulay authored Jun 20, 2024
1 parent 856bace commit d23bdb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public InGUIEventProcessor(float scaleFactor) {

@Override
public boolean processTouchEvent(MotionEvent motionEvent) {
boolean singleTap = mSingleTapDetector.onTouchEvent(motionEvent);

switch (motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mTracker.startTracking(motionEvent);
Expand Down Expand Up @@ -66,13 +68,17 @@ public boolean processTouchEvent(MotionEvent motionEvent) {
case MotionEvent.ACTION_UP:
mScroller.resetScrollOvershoot();
mTracker.cancelTracking();

// Handle single tap on gestures
if((!LauncherPreferences.PREF_DISABLE_GESTURES || touchpadDisplayed()) && !mIsMouseDown && singleTap) {
CallbackBridge.putMouseEventWithCoords(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, CallbackBridge.mouseX, CallbackBridge.mouseY);
}

if(mIsMouseDown) disableMouse();
resetGesture();
}

if((!LauncherPreferences.PREF_DISABLE_GESTURES || touchpadDisplayed()) && mSingleTapDetector.onTouchEvent(motionEvent)) {
clickMouse();
}

return true;
}

Expand All @@ -98,14 +104,9 @@ private void disableMouse() {
mIsMouseDown = false;
}

private void clickMouse() {
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, true);
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, false);
}

private void setGestureStart(MotionEvent event) {
mStartX = event.getX();
mStartY = event.getY();
mStartX = event.getX() * mScaleFactor;
mStartY = event.getY() * mScaleFactor;
}

private void resetGesture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TapDetector {
public final static int DETECTION_METHOD_UP = 0x2;
public final static int DETECTION_METHOD_BOTH = 0x3; //Unused for now

private final static int TAP_MIN_DELTA_MS = 10;
private final static int TAP_MIN_DELTA_MS = -1;
private final static int TAP_MAX_DELTA_MS = 300;
private final static int TAP_SLOP_SQUARE_PX = (int) Tools.dpToPx(2500);

Expand Down

0 comments on commit d23bdb9

Please sign in to comment.