Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make system cursor optional #44

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
}

pub struct FusedCursor {
pub cursor: Cursor,
pub cursor: Option<Cursor>,
pub icon: SystemCursor,
}

impl FusedCursor {
pub fn new() -> Self {
Self {
cursor: Cursor::from_system(SystemCursor::Arrow).unwrap(),
cursor: Cursor::from_system(SystemCursor::Arrow).ok(),
icon: SystemCursor::Arrow,
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@
}
match event {
// handle when window Resized and SizeChanged.
Window { win_event, .. } => match win_event {

Check failure on line 174 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-latest, stable)

this `match` can be collapsed into the outer `match`

Check failure on line 174 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-latest, nightly)

this `match` can be collapsed into the outer `match`
WindowEvent::Resized(_, _) | sdl2::event::WindowEvent::SizeChanged(_, _) => {
painter.update_screen_rect(window.drawable_size());
state.input.screen_rect = Some(painter.screen_rect);
Expand Down Expand Up @@ -422,8 +422,10 @@
};

if tmp_icon != fused.icon {
fused.cursor = Cursor::from_system(tmp_icon).unwrap();
fused.cursor = Cursor::from_system(tmp_icon).ok();
fused.icon = tmp_icon;
fused.cursor.set();
if let Some(cursor) = &fused.cursor {
cursor.set();
}
}
}
Loading