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

Add window::Action::CursorGrab and mouse::Event::MouseMotion #2614

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bbb651
Copy link
Contributor

@bbb651 bbb651 commented Sep 29, 2024

Together they allow you to confine or lock the cursor, and still recive mouse events.
Corresponds to winit::window::CursorGrabMode and winit::event::DeviceEvent::MouseMotion respectively.

Some use cases they allow are panning in viewports and inputs that can be dragged like sliders without a range, these can be implemented using the cursor position but lead to bad UX from the cursor exiting the window or hitting the edge of the monitor, making you have to stop the interaction and reposition the cursor. Blender is a good example of both of these behaviors.

Unfortunately, there are currently some pretty big limitations, stemming from winit (and potentially platform limitations):

  • winit::event::DeviceEvent::MouseMotion uses raw (unaccelerated) mouse input. This really hurts usability and the reason this is a draft PR. I'm looking into solving this in winit, probably by adding a winit::event::WindowEvent::MouseMotion counterpart that is accelerated (and will also be specific to a window instead of being sent to all windows), this is very straight forward on wayland (the event is on a toplevel (window), and gives both accelerated and unaccelerated), but I'm not sure about other platforms.
  • Platform support is not great for CursorGrab, it works out that there's exactly one mode that is guaranteed to work for each platform (on linux CursorGrab::Confined works for both wayland and x11).
  • There's no ability to set a region in CursorGrab::Confined, which happens to be particularly useful for GUIs.

Together they allow you to confine or lock the cursor,
and still recive mouse events.
Corresponds to `winit::window::CursorGrabMode` and
`winit::event::DeviceEvent::MouseMotion` respectively.
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.

1 participant