aboutsummaryrefslogtreecommitdiff
path: root/xcursor
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-11-01 11:40:13 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2023-11-01 13:13:22 +0000
commitdbedcdb418f49090df6e7359e6d3e58c97db1a74 (patch)
treee6320c6b3682e4c1831a109ee289e23174394072 /xcursor
parent8ebfeffdc86c71f91f648d86da376c0851181c8c (diff)
xcursor: add fallbacks for legacy names
Some XCursor themes still use the legacy names instead of the newer cursor naming spec [1]. Fall back to the legacy name if the standard one could not be found. [1]: https://www.freedesktop.org/wiki/Specifications/cursor-spec/ Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3746
Diffstat (limited to 'xcursor')
-rw-r--r--xcursor/wlr_xcursor.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/xcursor/wlr_xcursor.c b/xcursor/wlr_xcursor.c
index 597a0b13..6c6e11df 100644
--- a/xcursor/wlr_xcursor.c
+++ b/xcursor/wlr_xcursor.c
@@ -239,7 +239,7 @@ void wlr_xcursor_theme_destroy(struct wlr_xcursor_theme *theme) {
free(theme);
}
-struct wlr_xcursor *wlr_xcursor_theme_get_cursor(struct wlr_xcursor_theme *theme,
+static struct wlr_xcursor *xcursor_theme_get_cursor(struct wlr_xcursor_theme *theme,
const char *name) {
for (unsigned int i = 0; i < theme->cursor_count; i++) {
if (strcmp(name, theme->cursors[i]->name) == 0) {
@@ -250,6 +250,47 @@ struct wlr_xcursor *wlr_xcursor_theme_get_cursor(struct wlr_xcursor_theme *theme
return NULL;
}
+struct wlr_xcursor *wlr_xcursor_theme_get_cursor(struct wlr_xcursor_theme *theme,
+ const char *name) {
+ struct wlr_xcursor *xcursor = xcursor_theme_get_cursor(theme, name);
+ if (xcursor) {
+ return xcursor;
+ }
+
+ // Try the legacy name as a fallback
+ const char *fallback;
+ if (strcmp(name, "default") == 0) {
+ fallback = "left_ptr";
+ } else if (strcmp(name, "text") == 0) {
+ fallback = "xterm";
+ } else if (strcmp(name, "pointer") == 0) {
+ fallback = "hand1";
+ } else if (strcmp(name, "wait") == 0) {
+ fallback = "watch";
+ } else if (strcmp(name, "all-scroll") == 0) {
+ fallback = "grabbing";
+ } else if (strcmp(name, "sw-resize") == 0) {
+ fallback = "bottom_left_corner";
+ } else if (strcmp(name, "se-resize") == 0) {
+ fallback = "bottom_right_corner";
+ } else if (strcmp(name, "s-resize") == 0) {
+ fallback = "bottom_side";
+ } else if (strcmp(name, "w-resize") == 0) {
+ fallback = "left_side";
+ } else if (strcmp(name, "e-resize") == 0) {
+ fallback = "right_side";
+ } else if (strcmp(name, "nw-resize") == 0) {
+ fallback = "top_left_corner";
+ } else if (strcmp(name, "ne-resize") == 0) {
+ fallback = "top_right_corner";
+ } else if (strcmp(name, "n-resize") == 0) {
+ fallback = "top_side";
+ } else {
+ return NULL;
+ }
+ return xcursor_theme_get_cursor(theme, fallback);
+}
+
static int xcursor_frame_and_duration(struct wlr_xcursor *cursor,
uint32_t time, uint32_t *duration) {
if (cursor->image_count == 1) {