rust-windowing / winit

Window handling library in pure Rust

Home Page:https://docs.rs/winit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting cursor_grab every frame on wayland leads to issues

terrarier2111 opened this issue · comments

Calling set_cursor_grab every frame on wayland (even with the same Mode every time) leads to it not working properly, but setting it once works

That sounds like a bug in your compositor, works just fine in mine.

Could you test something like that

diff --git a/src/platform_impl/linux/wayland/window/state.rs b/src/platform_impl/linux/wayland/window/state.rs
index a00ddb52..85e4c48d 100644
--- a/src/platform_impl/linux/wayland/window/state.rs
+++ b/src/platform_impl/linux/wayland/window/state.rs
@@ -826,6 +826,10 @@ impl WindowState {

     /// Set the cursor grabbing state on the top-level.
     pub fn set_cursor_grab(&mut self, mode: CursorGrabMode) -> Result<(), ExternalError> {
+        if self.cursor_grab_mode.user_grab_mode == mode {
+            return Ok(());
+        }
+
         // Replace the user grabbing mode.
         self.cursor_grab_mode.user_grab_mode = mode;
         self.set_cursor_grab_inner(mode)

That sounds like a bug in your compositor, works just fine in mine.

Could you test something like that

diff --git a/src/platform_impl/linux/wayland/window/state.rs b/src/platform_impl/linux/wayland/window/state.rs
index a00ddb52..85e4c48d 100644
--- a/src/platform_impl/linux/wayland/window/state.rs
+++ b/src/platform_impl/linux/wayland/window/state.rs
@@ -826,6 +826,10 @@ impl WindowState {

     /// Set the cursor grabbing state on the top-level.
     pub fn set_cursor_grab(&mut self, mode: CursorGrabMode) -> Result<(), ExternalError> {
+        if self.cursor_grab_mode.user_grab_mode == mode {
+            return Ok(());
+        }
+
         // Replace the user grabbing mode.
         self.cursor_grab_mode.user_grab_mode = mode;
         self.set_cursor_grab_inner(mode)

Sadly i don't have a winit build environment set up but it does sound like a compositor bug