summaryrefslogtreecommitdiff
path: root/client/src/window.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-07 16:50:44 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-07 16:50:44 +0100
commit0a0abfe7b093d91447fb7070820a0e6d56d6c22d (patch)
tree17cdfd63bce8d717cd35d4d88646b837fbffc594 /client/src/window.rs
parentd0d8c07e1915b47610bf91176d908c9b46a5ab54 (diff)
downloadweareserver-0a0abfe7b093d91447fb7070820a0e6d56d6c22d.tar
weareserver-0a0abfe7b093d91447fb7070820a0e6d56d6c22d.tar.bz2
weareserver-0a0abfe7b093d91447fb7070820a0e6d56d6c22d.tar.zst
normal texture
Diffstat (limited to 'client/src/window.rs')
-rw-r--r--client/src/window.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/client/src/window.rs b/client/src/window.rs
index 8b3ee9e..fb9f375 100644
--- a/client/src/window.rs
+++ b/client/src/window.rs
@@ -13,12 +13,14 @@ use winit::{
pub struct WindowState {
init: Option<TcpStream>,
window: Option<(Window, State<'static>)>,
+ lock: bool,
}
impl WindowState {
pub fn new(init: TcpStream) -> Self {
Self {
window: None,
init: Some(init),
+ lock: false,
}
}
}
@@ -56,7 +58,13 @@ impl ApplicationHandler for WindowState {
if event.state == ElementState::Pressed {
match event.physical_key {
PhysicalKey::Code(KeyCode::Escape) => {
- win.set_cursor_grab(CursorGrabMode::Locked).unwrap();
+ win.set_cursor_grab(if self.lock {
+ CursorGrabMode::None
+ } else {
+ CursorGrabMode::Locked
+ })
+ .unwrap();
+ self.lock = !self.lock;
}
_ => (),
}