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

Implement proper grabbing behavior on macOS #1093

Open
Osspial opened this issue Aug 5, 2019 · 5 comments
Open

Implement proper grabbing behavior on macOS #1093

Osspial opened this issue Aug 5, 2019 · 5 comments
Labels
D - average Likely as difficult as most tasks here DS - macos H - good first issue Ideal for new contributors P - normal Great to have S - platform parity Unintended platform differences

Comments

@Osspial
Copy link
Contributor

Osspial commented Aug 5, 2019

Right now on macOS, the cursor just gets locked to its current location, instead of getting locked to the area of the window. A proper solution that locks the cursor to the window exists and is documented, but hasn't been implemented yet.

See this comment:

pub fn set_cursor_grab(&self, grab: bool) -> Result<(), ExternalError> {
// TODO: Do this for real https://stackoverflow.com/a/40922095/5435443
CGDisplay::associate_mouse_and_mouse_cursor_position(!grab)
.map_err(|status| ExternalError::Os(os_error!(OsError::CGError(status))))
}

@panda2134
Copy link

Can anyone merge this PR? This feature is critical for developing cross-platform video games. If we cannot set mouse grab on macOS, then camera movement will become quite weird there.

@kchibisov
Copy link
Member

@panda2134 this is not a PR, it's an issue. macOS has locking, but not confining.

@panda2134
Copy link

Sorry for mistaking this as a PR. If it's the OS's fault, then that's acceptable limitation. Also I just found out that it works when locking is used after setting the cursor to somewhere in the window.

@kchibisov
Copy link
Member

Yes, the cursor should be in the window to lock it. that's how it works on most OSes.

@swiftcoder
Copy link
Contributor

You can simulate proper cursor grabbing with the cursor lock API, by only locking after the user first clicks in the window.

(I believe this is required for Web anyway, because you can only grab the cursor in response to user interaction?)

Indy2222 added a commit to Indy2222/de that referenced this issue Jan 27, 2023
Mouse grabbing does not work correctly on MacOS: the mouse is locked to
the initial position instead of being confined to the primary window.

Relates to DigitalExtinction#354.
Relates to rust-windowing/winit#1093.
Indy2222 added a commit to Indy2222/de that referenced this issue Jan 27, 2023
Mouse grabbing does not work correctly on MacOS: the mouse is locked to
the initial position instead of being confined to the primary window.

Relates to DigitalExtinction#354.
Relates to rust-windowing/winit#1093.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D - average Likely as difficult as most tasks here DS - macos H - good first issue Ideal for new contributors P - normal Great to have S - platform parity Unintended platform differences
Development

No branches or pull requests

4 participants