From ecc63e2e5d4938049f9bd36ba70deb379315c3ea Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 1 Aug 2021 13:45:10 -0700 Subject: [PATCH] wayland: improve mouse cursor resolution and diagnostics Switch to using `xterm` rather than `text` for the name of the xterm style I-beam mouse cursor, as that appears to be more compatible across themes; the gnome theme aliases text -> xterm via a symlink. Improve error diagnostics in the case that no cursor is found. refs: https://github.com/wez/wezterm/issues/532 --- window/src/os/wayland/frame.rs | 4 ++-- window/src/os/wayland/pointer.rs | 4 +++- window/src/os/wayland/window.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/window/src/os/wayland/frame.rs b/window/src/os/wayland/frame.rs index 14ba73d5a..4cba453f6 100644 --- a/window/src/os/wayland/frame.rs +++ b/window/src/os/wayland/frame.rs @@ -1117,8 +1117,8 @@ fn change_pointer(pointer: &ThemedPointer, inner: &Inner, location: Location, se _ => "left_ptr", }; - if pointer.set_cursor(name, serial).is_err() { - log::error!("Failed to set cursor"); + if let Err(err) = pointer.set_cursor(name, serial) { + log::error!("Unable to set cursor to {}: {:#}", name, err); } } diff --git a/window/src/os/wayland/pointer.rs b/window/src/os/wayland/pointer.rs index 0eec25f79..8acb93c13 100644 --- a/window/src/os/wayland/pointer.rs +++ b/window/src/os/wayland/pointer.rs @@ -250,7 +250,9 @@ impl PointerDispatcher { pub fn set_cursor(&self, name: &str, serial: Option) { let inner = self.inner.lock().unwrap(); let serial = serial.unwrap_or(inner.serial); - self.auto_pointer.set_cursor(name, Some(serial)).ok(); + if let Err(err) = self.auto_pointer.set_cursor(name, Some(serial)) { + log::error!("Unable to set cursor to {}: {:#}", name, err); + } } } diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 111006dc3..7d6a87684 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -897,7 +897,7 @@ impl WaylandWindowInner { Some(MouseCursor::Hand) => "hand", Some(MouseCursor::SizeUpDown) => "ns-resize", Some(MouseCursor::SizeLeftRight) => "ew-resize", - Some(MouseCursor::Text) => "text", + Some(MouseCursor::Text) => "xterm", None => return, }; let conn = Connection::get().unwrap().wayland();