Skip to content

Commit

Permalink
misc(view_port): only update cursor when it actually changed
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Mar 2, 2024
1 parent 9e78424 commit d616b07
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/area_selector/view_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum CursorType {
}

impl CursorType {
fn name(self) -> &'static str {
fn as_str(self) -> &'static str {
match self {
Self::Default => "default",
Self::Crosshair => "crosshair",
Expand Down Expand Up @@ -417,7 +417,15 @@ impl ViewPort {
}

fn set_cursor(&self, cursor_type: CursorType) {
self.set_cursor_from_name(Some(cursor_type.name()));
if self
.cursor()
.and_then(|cursor| cursor.name())
.is_some_and(|name| name == cursor_type.as_str())
{
return;
}

self.set_cursor_from_name(Some(cursor_type.as_str()));
}

fn compute_cursor_type(&self, x: f32, y: f32) -> CursorType {
Expand Down

0 comments on commit d616b07

Please sign in to comment.