diff --git a/CHANGELOG.md b/CHANGELOG.md index fe149600..66fa7c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ * `16-bit` to `tweak.surface-bit-depth`. Makes foot use 16-bit image buffers. They provide the necessary color precision required by `gamma-correct-blending=yes`. +* New cursor shapes, from `cursor-shape-v1` version 2. [2025]: https://codeberg.org/dnkl/foot/issues/2025 [1975]: https://codeberg.org/dnkl/foot/issues/1975 diff --git a/cursor-shape.c b/cursor-shape.c index bbf75ab8..6e859259 100644 --- a/cursor-shape.c +++ b/cursor-shape.c @@ -54,7 +54,7 @@ cursor_shape_to_server_shape(enum cursor_shape shape) } enum wp_cursor_shape_device_v1_shape -cursor_string_to_server_shape(const char *xcursor) +cursor_string_to_server_shape(const char *xcursor, int bound_version) { if (xcursor == NULL) return 0; @@ -94,9 +94,29 @@ cursor_string_to_server_shape(const char *xcursor) [WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL] = {"all-scroll", "fleur"}, [WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_IN] = {"zoom-in"}, [WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_OUT] = {"zoom-out"}, +#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION) /* 1.42 */ + [WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK] = {"dnd-ask"}, +#endif +#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION) /* 1.42 */ + [WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE] = {"all-resize"}, +#endif }; for (size_t i = 0; i < ALEN(table); i++) { +#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION) + if (i == WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK && + bound_version < WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION) + { + continue; + } +#endif +#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION) + if (i == WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE && + bound_version < WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION) + { + continue; + } +#endif for (size_t j = 0; j < ALEN(table[i]); j++) { if (table[i][j] != NULL && streq(xcursor, table[i][j])) { return i; diff --git a/cursor-shape.h b/cursor-shape.h index 110dbd2e..13690588 100644 --- a/cursor-shape.h +++ b/cursor-shape.h @@ -26,4 +26,4 @@ const char *const *cursor_shape_to_string(enum cursor_shape shape); enum wp_cursor_shape_device_v1_shape cursor_shape_to_server_shape( enum cursor_shape shape); enum wp_cursor_shape_device_v1_shape cursor_string_to_server_shape( - const char *xcursor); + const char *xcursor, int bound_version); diff --git a/render.c b/render.c index e0f32575..a41eee0c 100644 --- a/render.c +++ b/render.c @@ -4929,8 +4929,9 @@ render_xcursor_update(struct seat *seat) const enum wp_cursor_shape_device_v1_shape custom_shape = (shape == CURSOR_SHAPE_CUSTOM && xcursor != NULL - ? cursor_string_to_server_shape(xcursor) - : 0); + ? cursor_string_to_server_shape( + xcursor, seat->wayl->shape_manager_version) + : 0); if (shape != CURSOR_SHAPE_CUSTOM || custom_shape != 0) { xassert(custom_shape == 0 || shape == CURSOR_SHAPE_CUSTOM); diff --git a/terminal.c b/terminal.c index 18f3bc9f..6f66f65b 100644 --- a/terminal.c +++ b/terminal.c @@ -3571,7 +3571,9 @@ term_xcursor_update_for_seat(struct terminal *term, struct seat *seat) if (seat->pointer.hidden) shape = CURSOR_SHAPE_HIDDEN; - else if (cursor_string_to_server_shape(term->mouse_user_cursor) != 0 || + else if (cursor_string_to_server_shape( + term->mouse_user_cursor, + term->wl->shape_manager_version) != 0 || render_xcursor_is_valid(seat, term->mouse_user_cursor)) { shape = CURSOR_SHAPE_CUSTOM; diff --git a/wayland.c b/wayland.c index 37fefb29..7d3c7c67 100644 --- a/wayland.c +++ b/wayland.c @@ -1480,8 +1480,16 @@ handle_global(void *data, struct wl_registry *registry, if (!verify_iface_version(interface, version, required)) return; +#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION) /* 1.42 */ + const uint32_t preferred = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION; +#else + const uint32_t preferred = required; +#endif + + wayl->shape_manager_version = min(required, preferred); wayl->cursor_shape_manager = wl_registry_bind( - wayl->registry, name, &wp_cursor_shape_manager_v1_interface, required); + wayl->registry, name, &wp_cursor_shape_manager_v1_interface, + min(required, preferred)); } else if (streq(interface, wp_single_pixel_buffer_manager_v1_interface.name)) { diff --git a/wayland.h b/wayland.h index b7e8e79f..eb1c35a3 100644 --- a/wayland.h +++ b/wayland.h @@ -460,6 +460,7 @@ struct wayland { struct wp_fractional_scale_manager_v1 *fractional_scale_manager; struct wp_cursor_shape_manager_v1 *cursor_shape_manager; + int shape_manager_version; struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;