From 0cc58db8e6e226cf669a7481c7742e3dd6bfba90 Mon Sep 17 00:00:00 2001 From: Friz64 Date: Mon, 30 Oct 2023 10:11:26 +0100 Subject: [PATCH 1/4] Add alternative names for cursor icons --- CHANGELOG.md | 6 +++++- src/lib.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a7b9dd..4db9ae4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,8 @@ The sections should follow the order `Packaging`, `Added`, `Changed`, `Fixed` an The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -# Unreleased +## Unreleased + +### Added + +- Access to alternative names for cursor icons through the `CursorIcon::alt_names` method. diff --git a/src/lib.rs b/src/lib.rs index 93f26af..e1afe5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,6 +321,50 @@ impl CursorIcon { CursorIcon::ZoomOut => "zoom-out", } } + + /// A list of alternative names for the cursor icon as commonly found in + /// legacy Xcursor themes. + /// + /// This should only be used as a fallback in case the cursor theme does not + /// adhere to the w3c standard. + pub fn alt_names(&self) -> &[&'static str] { + match self { + CursorIcon::Default => &["left_ptr", "arrow"], + CursorIcon::ContextMenu => &[], + CursorIcon::Help => &["question_arrow"], + CursorIcon::Pointer => &["hand2", "hand1"], + CursorIcon::Progress => &[], + CursorIcon::Wait => &["watch"], + CursorIcon::Cell => &["plus"], + CursorIcon::Crosshair => &[], + CursorIcon::Text => &["xterm"], + CursorIcon::VerticalText => &[], + CursorIcon::Alias => &["link"], + CursorIcon::Copy => &[], + CursorIcon::Move => &[], + CursorIcon::NoDrop => &["circle"], + CursorIcon::NotAllowed => &["crossed_circle"], + CursorIcon::Grab => &["openhand"], + CursorIcon::Grabbing => &["closedhand"], + CursorIcon::EResize => &["right_side"], + CursorIcon::NResize => &["top_side"], + CursorIcon::NeResize => &["top_right_corner"], + CursorIcon::NwResize => &["top_left_corner"], + CursorIcon::SResize => &["bottom_side"], + CursorIcon::SeResize => &["bottom_right_corner"], + CursorIcon::SwResize => &["bottom_left_corner"], + CursorIcon::WResize => &["left_side"], + CursorIcon::EwResize => &["h_double_arrow"], + CursorIcon::NsResize => &["v_double_arrow"], + CursorIcon::NeswResize => &["fd_double_arrow", "size_bdiag"], + CursorIcon::NwseResize => &["bd_double_arrow", "size_fdiag"], + CursorIcon::ColResize => &["split_h", "h_double_arrow"], + CursorIcon::RowResize => &["split_v", "v_double_arrow"], + CursorIcon::AllScroll => &[], + CursorIcon::ZoomIn => &[], + CursorIcon::ZoomOut => &[], + } + } } impl core::fmt::Display for CursorIcon { From 23f41de54729e1e94b873b24c8e2a86e340c041a Mon Sep 17 00:00:00 2001 From: Friz64 Date: Mon, 30 Oct 2023 12:03:19 +0100 Subject: [PATCH 2/4] Add more alternative names from GTK and Qt Sources below. GTK: https://gitlab.gnome.org/GNOME/gtk/-/blob/020ef51cb00fdf0e4a440468d41ed8256881da17/gdk/wayland/gdkcursor-wayland.c#L64-102 Qt: https://github.com/qt/qtwayland/blob/077073671f262c51791d27e273e9b8971af087fa/src/client/qwaylandcursor.cpp#L45-L166 --- src/lib.rs | 75 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e1afe5a..4552045 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -329,23 +329,42 @@ impl CursorIcon { /// adhere to the w3c standard. pub fn alt_names(&self) -> &[&'static str] { match self { - CursorIcon::Default => &["left_ptr", "arrow"], + CursorIcon::Default => &["left_ptr", "arrow", "top_left_arrow", "left_arrow"], CursorIcon::ContextMenu => &[], - CursorIcon::Help => &["question_arrow"], - CursorIcon::Pointer => &["hand2", "hand1"], - CursorIcon::Progress => &[], + CursorIcon::Help => &[ + "question_arrow", + "whats_this", + "5c6cd98b3f3ebcb1f9c7f1c204630408", + "d9ce0ab605698f320427677b458ad60b", + ], + CursorIcon::Pointer => { + &["hand2", "hand1", "hand", "pointing_hand", "e29285e634086352946a0e7090d73106"] + }, + CursorIcon::Progress => &[ + "left_ptr_watch", + "half-busy", + "00000000000000020006000e7e9ffc3f", + "08e8e1c95fe2fc01f976f1e063a24ccd", + ], CursorIcon::Wait => &["watch"], CursorIcon::Cell => &["plus"], - CursorIcon::Crosshair => &[], - CursorIcon::Text => &["xterm"], + CursorIcon::Crosshair => &["cross"], + CursorIcon::Text => &["xterm", "ibeam"], CursorIcon::VerticalText => &[], CursorIcon::Alias => &["link"], CursorIcon::Copy => &[], CursorIcon::Move => &[], CursorIcon::NoDrop => &["circle"], - CursorIcon::NotAllowed => &["crossed_circle"], - CursorIcon::Grab => &["openhand"], - CursorIcon::Grabbing => &["closedhand"], + CursorIcon::NotAllowed => { + &["crossed_circle", "forbidden", "03b6e0fcb3499374a867c041f52298f0"] + }, + CursorIcon::Grab => &[ + "openhand", + "fleur", + "5aca4d189052212118709018842178c0", + "9d800788f1b08800ae810202380a0822", + ], + CursorIcon::Grabbing => &["closedhand", "208530c400c041818281048008011002"], CursorIcon::EResize => &["right_side"], CursorIcon::NResize => &["top_side"], CursorIcon::NeResize => &["top_right_corner"], @@ -354,12 +373,38 @@ impl CursorIcon { CursorIcon::SeResize => &["bottom_right_corner"], CursorIcon::SwResize => &["bottom_left_corner"], CursorIcon::WResize => &["left_side"], - CursorIcon::EwResize => &["h_double_arrow"], - CursorIcon::NsResize => &["v_double_arrow"], - CursorIcon::NeswResize => &["fd_double_arrow", "size_bdiag"], - CursorIcon::NwseResize => &["bd_double_arrow", "size_fdiag"], - CursorIcon::ColResize => &["split_h", "h_double_arrow"], - CursorIcon::RowResize => &["split_v", "v_double_arrow"], + CursorIcon::EwResize => { + &["h_double_arrow", "size_hor", "028006030e0e7ebffc7f7070c0600140"] + }, + CursorIcon::NsResize => { + &["v_double_arrow", "size_ver", "00008160000006810000408080010102"] + }, + CursorIcon::NeswResize => &[ + "fd_double_arrow", + "size_bdiag", + "50585d75b494802d0151028115016902", + "fcf1c3c7cd4491d801f1e1c78f100000", + ], + CursorIcon::NwseResize => &[ + "bd_double_arrow", + "size_fdiag", + "38c5dff7c7b8962045400281044508d2", + "c7088f0f3e6c8088236ef8e1e3e70000", + ], + CursorIcon::ColResize => &[ + "split_h", + "h_double_arrow", + "sb_h_double_arrow", + "043a9f68147c53184671403ffa811cc5", + "14fef782d02440884392942c11205230", + ], + CursorIcon::RowResize => &[ + "split_v", + "v_double_arrow", + "sb_v_double_arrow", + "2870a09082c103050810ffdffffe0204", + "c07385c7190e701020ff7ffffd08103c", + ], CursorIcon::AllScroll => &[], CursorIcon::ZoomIn => &[], CursorIcon::ZoomOut => &[], From 2c0d0621ee291edfbb5b8fbb14afabc29e0ed36e Mon Sep 17 00:00:00 2001 From: Friz64 Date: Thu, 2 Nov 2023 06:00:05 +0100 Subject: [PATCH 3/4] Remove hashes --- src/lib.rs | 69 ++++++++++-------------------------------------------- 1 file changed, 12 insertions(+), 57 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4552045..155b16c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -331,21 +331,9 @@ impl CursorIcon { match self { CursorIcon::Default => &["left_ptr", "arrow", "top_left_arrow", "left_arrow"], CursorIcon::ContextMenu => &[], - CursorIcon::Help => &[ - "question_arrow", - "whats_this", - "5c6cd98b3f3ebcb1f9c7f1c204630408", - "d9ce0ab605698f320427677b458ad60b", - ], - CursorIcon::Pointer => { - &["hand2", "hand1", "hand", "pointing_hand", "e29285e634086352946a0e7090d73106"] - }, - CursorIcon::Progress => &[ - "left_ptr_watch", - "half-busy", - "00000000000000020006000e7e9ffc3f", - "08e8e1c95fe2fc01f976f1e063a24ccd", - ], + CursorIcon::Help => &["question_arrow", "whats_this"], + CursorIcon::Pointer => &["hand2", "hand1", "hand", "pointing_hand"], + CursorIcon::Progress => &["left_ptr_watch", "half-busy"], CursorIcon::Wait => &["watch"], CursorIcon::Cell => &["plus"], CursorIcon::Crosshair => &["cross"], @@ -355,16 +343,9 @@ impl CursorIcon { CursorIcon::Copy => &[], CursorIcon::Move => &[], CursorIcon::NoDrop => &["circle"], - CursorIcon::NotAllowed => { - &["crossed_circle", "forbidden", "03b6e0fcb3499374a867c041f52298f0"] - }, - CursorIcon::Grab => &[ - "openhand", - "fleur", - "5aca4d189052212118709018842178c0", - "9d800788f1b08800ae810202380a0822", - ], - CursorIcon::Grabbing => &["closedhand", "208530c400c041818281048008011002"], + CursorIcon::NotAllowed => &["crossed_circle", "forbidden"], + CursorIcon::Grab => &["openhand", "fleur"], + CursorIcon::Grabbing => &["closedhand"], CursorIcon::EResize => &["right_side"], CursorIcon::NResize => &["top_side"], CursorIcon::NeResize => &["top_right_corner"], @@ -373,38 +354,12 @@ impl CursorIcon { CursorIcon::SeResize => &["bottom_right_corner"], CursorIcon::SwResize => &["bottom_left_corner"], CursorIcon::WResize => &["left_side"], - CursorIcon::EwResize => { - &["h_double_arrow", "size_hor", "028006030e0e7ebffc7f7070c0600140"] - }, - CursorIcon::NsResize => { - &["v_double_arrow", "size_ver", "00008160000006810000408080010102"] - }, - CursorIcon::NeswResize => &[ - "fd_double_arrow", - "size_bdiag", - "50585d75b494802d0151028115016902", - "fcf1c3c7cd4491d801f1e1c78f100000", - ], - CursorIcon::NwseResize => &[ - "bd_double_arrow", - "size_fdiag", - "38c5dff7c7b8962045400281044508d2", - "c7088f0f3e6c8088236ef8e1e3e70000", - ], - CursorIcon::ColResize => &[ - "split_h", - "h_double_arrow", - "sb_h_double_arrow", - "043a9f68147c53184671403ffa811cc5", - "14fef782d02440884392942c11205230", - ], - CursorIcon::RowResize => &[ - "split_v", - "v_double_arrow", - "sb_v_double_arrow", - "2870a09082c103050810ffdffffe0204", - "c07385c7190e701020ff7ffffd08103c", - ], + CursorIcon::EwResize => &["h_double_arrow", "size_hor"], + CursorIcon::NsResize => &["v_double_arrow", "size_ver"], + CursorIcon::NeswResize => &["fd_double_arrow", "size_bdiag"], + CursorIcon::NwseResize => &["bd_double_arrow", "size_fdiag"], + CursorIcon::ColResize => &["split_h", "h_double_arrow", "sb_h_double_arrow"], + CursorIcon::RowResize => &["split_v", "v_double_arrow", "sb_v_double_arrow"], CursorIcon::AllScroll => &[], CursorIcon::ZoomIn => &[], CursorIcon::ZoomOut => &[], From 4baa20fb4799538a79d3a89d35923407ba6f34b5 Mon Sep 17 00:00:00 2001 From: Friz64 Date: Thu, 2 Nov 2023 06:01:09 +0100 Subject: [PATCH 4/4] Add size_all cursor From Qt, previously overlooked --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 155b16c..68a407f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -360,7 +360,7 @@ impl CursorIcon { CursorIcon::NwseResize => &["bd_double_arrow", "size_fdiag"], CursorIcon::ColResize => &["split_h", "h_double_arrow", "sb_h_double_arrow"], CursorIcon::RowResize => &["split_v", "v_double_arrow", "sb_v_double_arrow"], - CursorIcon::AllScroll => &[], + CursorIcon::AllScroll => &["size_all"], CursorIcon::ZoomIn => &[], CursorIcon::ZoomOut => &[], }