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
This commit is contained in:
Simon Ser 2023-06-05 15:31:57 +02:00
parent 58a2f8bd5c
commit da04b066ea
4 changed files with 40 additions and 4 deletions

View file

@ -14,6 +14,7 @@
#include <wlr/types/wlr_output.h>
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

View file

@ -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);