Skip to content

Improve reliability of click detection in player window by adding minimum threshold for drag #4232

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

Merged
merged 4 commits into from
Mar 30, 2023

Conversation

svobs
Copy link
Contributor

@svobs svobs commented Feb 20, 2023


Description:

This updates the click detection in MainWindowController and adds a requirement that after mouseDown the user must drag the cursor at least 2pts distance for drag to start.

A given mouseDown/mouseUp pair is processed as either a click or a drag, but not both. The out-of-the-box behavior in Cocoa is unfortunately not very useful to take on its own: the mouseDragged callback is called with very high sensitivity (particularly with trackpad actions); mouseDragged will get called for drag distances of just a fraction of a pixel. This is both not very useful as a an actual drag distance, and actively harmful because it results in clicks/taps appearing to be ignored from the user's standpoint.

After some testing and tweaking, I concluded that a drag start threshold requirement of 2pts is all that's needed to ensure that clicks are registered reliably and there is no noticeable burden on actual drag attempts. Note that 2pts is all that's needed to start the drag, so if the user's goal is to move their player window by only 1pt, they will have to first drag it by 2 pts to register the drag, then drag it back by 1 pt to position it. I believe this behavior is similar to how CAD & layout software usually works, but as a video player it's expected to be very rare that any user will be making such fine adjustments anyway.

…ck that at least 2pts distance is moved in order to qualify as a drag instead of a click.
@low-batt
Copy link
Contributor

See my long comment in the issue. I'm thinking the user should be able to control this, but wait to see what others think.

@low-batt low-batt requested review from uiryuu and lhc70000 March 23, 2023 23:35
Copy link
Member

@uiryuu uiryuu left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -49,6 +49,8 @@ fileprivate extension NSStackView.VisibilityPriority {
static let detachEarliest = NSStackView.VisibilityPriority(rawValue: 750)
}

// The minimum distance that the user must drag before their click or tap gesture is interpreted as a drag gesture:
fileprivate let minimumInitialDragDistance: CGFloat = 4.0
Copy link
Member

Choose a reason for hiding this comment

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

Please add some comments to clarify that the intended distance is 2 instead of 4 since we are using spared distance.

@svobs
Copy link
Contributor Author

svobs commented Mar 29, 2023

Made another commit. The whole "squared" thing was due to copying an answer from StackOverflow, but it's silly to focus on avoiding a square root in this case because it won't affect performance in any meaningful way. Tweaked the drag distance so it is 3.0 pts instead of 4.0, but shouldn't make much difference.

@uiryuu uiryuu merged commit bb8f039 into iina:develop Mar 30, 2023
@uiryuu
Copy link
Member

uiryuu commented Mar 30, 2023

Thanks!

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.

Drag detection in main window is way too sensitive, causing some taps to be "ignored"
3 participants