From 003fe97034cbbd71a8845841cf9d26e592c27696 Mon Sep 17 00:00:00 2001 From: Colin Marc Date: Fri, 3 May 2024 09:01:12 +0200 Subject: [PATCH] fix(client): respect hidden cursors --- mm-client/src/bin/mmclient.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/mm-client/src/bin/mmclient.rs b/mm-client/src/bin/mmclient.rs index d46997f..bed077d 100644 --- a/mm-client/src/bin/mmclient.rs +++ b/mm-client/src/bin/mmclient.rs @@ -580,23 +580,22 @@ impl App { hotspot_x, hotspot_y, }) => { - let cursor: anyhow::Result = 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) => {