From e9e5df5ff1e09356bf2ad0bcc82bbaee6a2acc0d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Jan 2025 00:24:12 +0100 Subject: things --- client/src/ui.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'client/src/ui.rs') diff --git a/client/src/ui.rs b/client/src/ui.rs index 13e58d0..ffd840d 100644 --- a/client/src/ui.rs +++ b/client/src/ui.rs @@ -14,6 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ +use crate::state::InputState; use egui::{ Context, Event, ImageData, TextureId, ViewportId, ViewportInfo, epaint::{ImageDelta, Primitive, Vertex}, @@ -43,8 +44,6 @@ use wgpu::{ vertex_attr_array, }; -use crate::state::InputState; - pub struct UiRenderer { device: Arc, queue: Arc, @@ -53,6 +52,8 @@ pub struct UiRenderer { bind_group_layout: BindGroupLayout, textures: RwLock>, surfaces: RwLock>, + + last_pointer: Vec2, } pub struct UiSurface { @@ -144,6 +145,7 @@ impl UiRenderer { device, queue, bind_group_layout, + last_pointer: Vec2::ZERO, textures: HashMap::new().into(), surfaces: HashMap::new().into(), } @@ -313,10 +315,13 @@ impl UiRenderer { ); let mut raw_input = egui::RawInput::default(); - raw_input.events.push(Event::PointerMoved(egui::Pos2::new( - input_state.cursor_pos.x, - input_state.cursor_pos.y, - ))); + if input_state.cursor_pos != self.last_pointer { + raw_input.events.push(Event::PointerMoved(egui::Pos2::new( + input_state.cursor_pos.x, + input_state.cursor_pos.y, + ))); + self.last_pointer = input_state.cursor_pos; + } raw_input .events .extend(input_state.egui_events.iter().cloned()); -- cgit v1.2.3-70-g09d2