Skip to content

Commit

Permalink
Slightly nicer error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
manpat committed Sep 30, 2024
1 parent bb47d2d commit 3ec4dcb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions toybox-input/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ impl System {

if capture {
if let Err(error) = self.window.set_cursor_grab(CursorGrabMode::Confined)
.or_else(|prev_error| match self.window.set_cursor_grab(CursorGrabMode::Locked) {
Err(winit::error::ExternalError::NotSupported(_)) => Err(prev_error),
x => x,
})
.inspect_err(|error| log::warn!("Failed to capture mouse with 'confined' mode - falling back to 'locked' mode. {error}"))
.or_else(|_| self.window.set_cursor_grab(CursorGrabMode::Locked))
{
log::error!("Failed to lock mouse: {error}");
return;
Expand Down

0 comments on commit 3ec4dcb

Please sign in to comment.