From da04b066ea037be0fdc5d79ac6b214fea6f2d3c5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 5 Jun 2023 15:31:57 +0200 Subject: cursor: add wlr_cursor_set_xcursor() This keeps track of the last set XCursor. If it hasn't changed, skip the texture upload. In the future, support for animated XCursors can be added. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3436 --- include/wlr/types/wlr_cursor.h | 9 +++++++++ include/wlr/types/wlr_xcursor_manager.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'include') diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 06ae2f1f..f3c7e970 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -14,6 +14,7 @@ #include struct wlr_input_device; +struct wlr_xcursor_manager; /** * wlr_cursor implements the behavior of the "cursor", that is, the image on the @@ -146,6 +147,14 @@ void wlr_cursor_set_image(struct wlr_cursor *cur, const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y, float scale); +/** + * Set the cursor image from an XCursor theme. + * + * The image will be loaded from the struct wlr_xcursor_manager. + */ +void wlr_cursor_set_xcursor(struct wlr_cursor *cur, + struct wlr_xcursor_manager *manager, const char *name); + /** * Set the cursor surface. The surface can be committed to update the cursor * image. The surface position is subtracted from the hotspot. A NULL surface diff --git a/include/wlr/types/wlr_xcursor_manager.h b/include/wlr/types/wlr_xcursor_manager.h index f7781ca6..7d7b19ab 100644 --- a/include/wlr/types/wlr_xcursor_manager.h +++ b/include/wlr/types/wlr_xcursor_manager.h @@ -62,6 +62,8 @@ struct wlr_xcursor *wlr_xcursor_manager_get_xcursor( * scale factors. struct wlr_cursor will take over from this point and ensure * the correct cursor is used on each output, assuming a * struct wlr_output_layout is attached to it. + * + * Deprecated: wlr_cursor_set_xcursor() should be used instead. */ void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager, const char *name, struct wlr_cursor *cursor); -- cgit v1.2.3