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

Setting cursor_grab every frame on wayland leads to issues #3566

Closed
terrarier2111 opened this issue Mar 5, 2024 · 2 comments · Fixed by #3567
Closed

Setting cursor_grab every frame on wayland leads to issues #3566

terrarier2111 opened this issue Mar 5, 2024 · 2 comments · Fixed by #3567

Comments

@terrarier2111
Copy link

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

@daxpedda daxpedda added DS - wayland B - bug Dang, that shouldn't have happened labels Mar 5, 2024
@kchibisov kchibisov removed the B - bug Dang, that shouldn't have happened label Mar 5, 2024
@kchibisov
Copy link
Member

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)

@terrarier2111
Copy link
Author

terrarier2111 commented Mar 5, 2024

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

kchibisov added a commit that referenced this issue Mar 5, 2024
Some compositors break when re-taking the same grab.

Closes: #3566
kchibisov added a commit that referenced this issue Mar 5, 2024
Some compositors break when re-taking the same grab.

Closes: #3566
kchibisov added a commit that referenced this issue Mar 5, 2024
Some compositors break when re-taking the same grab.

Closes: #3566
kchibisov added a commit that referenced this issue Mar 5, 2024
Some compositors break when re-taking the same grab.

Closes: #3566
kchibisov added a commit that referenced this issue Mar 6, 2024
Some compositors break when re-taking the same grab.

Closes: #3566
notgull pushed a commit that referenced this issue Mar 7, 2024
Some compositors break when re-taking the same grab.

Closes: #3566
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants