summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/windowing.rs19
-rw-r--r--engine/src/windowing/window.rs3
2 files changed, 22 insertions, 0 deletions
diff --git a/engine/src/windowing.rs b/engine/src/windowing.rs
index 54947eb..d81b57c 100644
--- a/engine/src/windowing.rs
+++ b/engine/src/windowing.rs
@@ -1266,6 +1266,24 @@ impl ApplicationHandler for App
),
));
}
+ WindowEvent::Focused(is_window_focused) => {
+ let Some((winit_window, window_settings)) =
+ self.windows.get(WindowId::from_inner(window_id))
+ else {
+ cold_path();
+ return;
+ };
+
+ // For some reason, on X11 (XFCE and AwesomeWM, might be more) the cursor
+ // is confined even after the window loses focus.
+ if window_settings.cursor_grab_mode == CursorGrabMode::Confined {
+ let _ = winit_window.set_cursor_grab(if is_window_focused {
+ winit::window::CursorGrabMode::Confined
+ } else {
+ winit::window::CursorGrabMode::None
+ });
+ }
+ }
_ => {}
}
}
@@ -1330,6 +1348,7 @@ impl WindowSettings
winit::window::CursorGrabMode::None
}
CursorGrabMode::Locked => winit::window::CursorGrabMode::Locked,
+ CursorGrabMode::Confined => winit::window::CursorGrabMode::Confined,
});
if let Err(err) = res {
diff --git a/engine/src/windowing/window.rs b/engine/src/windowing/window.rs
index c601487..b935657 100644
--- a/engine/src/windowing/window.rs
+++ b/engine/src/windowing/window.rs
@@ -288,6 +288,9 @@ pub enum CursorGrabMode
/// The cursor is locked to a specific position in the window.
Locked,
+
+ /// The cursor is confined to the inside of the window
+ Confined,
}
/// A unique identifier for an X11 visual.