summaryrefslogtreecommitdiff
path: root/client/src/ui.rs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/ui.rs')
-rw-r--r--client/src/ui.rs17
1 files changed, 11 insertions, 6 deletions
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 <https://www.gnu.org/licenses/>.
*/
+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<Device>,
queue: Arc<Queue>,
@@ -53,6 +52,8 @@ pub struct UiRenderer {
bind_group_layout: BindGroupLayout,
textures: RwLock<HashMap<TextureId, (BindGroup, Texture, [u32; 2])>>,
surfaces: RwLock<HashMap<ViewportId, UiSurface>>,
+
+ 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());