Refine Window::set_cursor_grab API

This commit renames `Window::set_cursor_grab` to
`Window::set_cursor_grab_mode`. The new API now accepts enumeration
to control the way cursor grab is performed. The value could be: `lock`,
`confine`, or `none`.

This commit also implements `Window::set_cursor_position` for Wayland,
since it's tied to locked cursor.

Implements API from #1677.
This commit is contained in:
Kirill Chibisov 2022-06-13 09:43:14 +03:00 committed by GitHub
parent 8ef9fe44c7
commit 9e6f666616
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 359 additions and 131 deletions

View file

@ -89,8 +89,8 @@ impl Canvas {
})
}
pub fn set_cursor_grab(&self, grab: bool) -> Result<(), RootOE> {
if grab {
pub fn set_cursor_lock(&self, lock: bool) -> Result<(), RootOE> {
if lock {
self.raw().request_pointer_lock();
} else {
let window = web_sys::window()