-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(macos/input): incorrect mouse input for non-main display #2461
Conversation
…nitor to capture.
…product name corresponds to its display id)
fix: wrong abs mouse coordinates when capturing non-main display in macOS fix: wrong mouse coordinates correction when capturing non-main display in macOS
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## nightly #2461 +/- ##
==========================================
+ Coverage 6.17% 6.18% +0.01%
==========================================
Files 86 86
Lines 17546 17548 +2
Branches 8190 8186 -4
==========================================
+ Hits 1083 1085 +2
+ Misses 15410 14655 -755
- Partials 1053 1808 +755
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I don't have the ability to test these changes. Ideally unit tests would be added around the changed code, but I understand that's not always the easiest thing to do. Can you explain how you tested your changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's all i done here in order to get correct input coordinates after we support specific display capture.
src/platform/macos/display.mm
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this commit, there is a change that would require both env_width and env_height to have non-zero values, but these values are not properly set in that commit, which could break absolute mouse input on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we support change the display we need to capture in macOS, the location we get here according to Apple Document should be The current location of the specified mouse event in global display coordinates
, we can not just simply assuming the display's bounds to [0,display_width]
and [0,display_height]
. So we need to get the correspond display bounds for display we are capturing using CGDisplayBounds
which return The bounds of the display, expressed as a rectangle in the global display coordinate space (relative to the upper-left corner of the main display).
.
|
||
CGPoint location = CGPointMake(x * scaling, y * scaling); | ||
|
||
CGRect display_bounds = CGDisplayBounds(display); | ||
// in order to get the correct mouse location for capturing display , we need to add the display bounds to the location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The location we received are relative to the display we are capturing ,so we get the display bounds using CGDisplayBounds then add them up to get the right input coordinates.
Hi, just wanted to report that I tested the changes (by forking the homebrew tap repository and then pointing it to the right branch/commit) and confirm the issue is now gone, everything[1] works perfectly 👍 [1]: Well except the CTRL + ALT + SHIFT + N shortcut which still doesn't hide the cursor in anything but the main display, but that behavior is already present upstream so that would be a different issue |
Description
fix: abs mouse input not working in macOS
fix: wrong abs mouse coordinates when capturing non-main display in macOS
fix: wrong mouse coordinates correction when capturing non-main display in macOS
Screenshot
Issues Fixed or Closed
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.