From 9a03b4a36cb38e79c3693f14212697114fc68747 Mon Sep 17 00:00:00 2001 From: Wynd Date: Thu, 7 Nov 2024 12:28:49 +0200 Subject: [PATCH] Automatically hide the cursor when the spotlight is activated --- src/spotlight.rs | 4 +++- src/state.rs | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/spotlight.rs b/src/spotlight.rs index 8a564d7..f521a72 100644 --- a/src/spotlight.rs +++ b/src/spotlight.rs @@ -101,7 +101,9 @@ impl Spotlight { } } - pub fn update(&mut self) {} + pub fn update(&mut self, window: &winit::window::Window) { + window.set_cursor_visible(!self.is_ctrl_pressed); + } } #[repr(C)] diff --git a/src/state.rs b/src/state.rs index 3da5927..7feabb3 100644 --- a/src/state.rs +++ b/src/state.rs @@ -233,10 +233,6 @@ impl<'a> State<'a> { if char == "r" { self.camera_controller.reset_camera(&mut self.camera); } - else if char == "h" { - self.hide_cursor = !self.hide_cursor; - self.window.set_cursor_visible(!self.hide_cursor); - } } return true; } @@ -256,7 +252,7 @@ impl<'a> State<'a> { bytemuck::cast_slice(&[self.camera_info.uniform]), ); - self.spotlight.update(); + self.spotlight.update(&self.window); self.spotlight_info .uniform .update(&self.spotlight, &self.camera_controller);