From 0a0abfe7b093d91447fb7070820a0e6d56d6c22d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Jan 2025 16:50:44 +0100 Subject: normal texture --- client/src/window.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'client/src/window.rs') 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, 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; } _ => (), } -- cgit v1.2.3-70-g09d2