Skip to content

Commit

Permalink
fix(client): respect hidden cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed May 3, 2024
1 parent d7658cd commit 003fe97
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions mm-client/src/bin/mmclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,23 +580,22 @@ impl App {
hotspot_x,
hotspot_y,
}) => {
let cursor: anyhow::Result<winit::window::Cursor> = if !image.is_empty() {
load_cursor_image(&image, hotspot_x, hotspot_y)
.map(|src| event_loop.create_custom_cursor(src).into())
} else {
icon.try_into()
.map(cursor_icon_from_proto)
.map_err(anyhow::Error::new)
.map(Into::into)
};

match cursor {
Ok(cursor) => {
if !image.is_empty() {
if let Ok(cursor) = load_cursor_image(&image, hotspot_x, hotspot_y)
.map(|src| event_loop.create_custom_cursor(src))
{
self.window.set_cursor(cursor);
self.window.set_cursor_visible(true);
} else {
error!(image_len = image.len(), "custom cursor image update failed");
}
Err(err) => {
debug!(?err, ?icon, image_len = image.len(), "cursor update failed");
}
} else if icon.try_into() == Ok(protocol::update_cursor::CursorIcon::None) {
self.window.set_cursor_visible(false);
} else if let Ok(icon) = icon.try_into().map(cursor_icon_from_proto) {
self.window.set_cursor(icon);
self.window.set_cursor_visible(true);
} else {
error!(icon, "cursor shape update failed");
}
}
protocol::MessageType::Error(e) => {
Expand Down

0 comments on commit 003fe97

Please sign in to comment.