Skip to content

Add set_cursor_lock and distinguish between grabbing (confining) cursor and locking cursor #1677

@alvinhochun

Description

@alvinhochun

Currently there is a set_cursor_grab API which is supposed to confine the cursor movement to within the window client area, but sometimes the user may want to lock the cursor to the current position instead (e.g. for camera control). Also, the web platform does not support confining the cursor but does support locking the cursor with the Pointer Lock API. Therefore, I would suggest adding a new API set_cursor_lock to lock the cursor to the current position, and fixing the set_cursor_grab API to actually confine the cursor on all supported platforms.

A better alternative would be to change set_cursor_grab to take an enum CursorGrabState { Off, Confine, Lock } so that only one of the two cursor grabbing modes can be active at once.

set_cursor_grab / Confine set_cursor_lock / Lock
Windows Supported, already implemented Supported, unimplemented (could reuse cursor grab impl.)
Linux (X11) Supported, already implemented Unknown (could just move the mouse after mouse moved?)
Linux (Wayland) Supported, unimplemented (#1678) Supported, already implemented for set_cursor_grab
macOS Supported, unimplemented (#1093) Supported, already implemented for set_cursor_grab
iOS Not supported Not supported
Android Not supported Not supported
Web Not supported Supported, unimplemented (#1674)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions