Skip to content

Commit

Permalink
chore(wayland): don't reapply same cursor grab
Browse files Browse the repository at this point in the history
Some compositors break when re-taking the same grab.

Closes: #3566
  • Loading branch information
kchibisov committed Mar 5, 2024
1 parent f6f1c45 commit fc8a008
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Unreleased` header.

# Unreleased

- On Wayland, don't reapply cursor grab when unchanged.
- Move `dpi` types to its own crate, and re-export it from the root crate.
- Implement `Sync` for `EventLoopProxy<T: Send>`.
- **Breaking:** Move `Window::new` to `ActiveEventLoop::create_window` and `EventLoop::create_window` (with the latter being deprecated).
Expand Down
9 changes: 7 additions & 2 deletions src/platform_impl/linux/wayland/window/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,14 @@ impl WindowState {

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

self.set_cursor_grab_inner(mode)?;
// Update user grab on success.
self.cursor_grab_mode.user_grab_mode = mode;
self.set_cursor_grab_inner(mode)
Ok(())
}

/// Reload the hints for minimum and maximum sizes.
Expand Down

0 comments on commit fc8a008

Please sign in to comment.