Documentation for <wlr/xcursor.h>

Back to index

Table of contents

struct wlr_xcursor

struct wlr_xcursor {
	unsigned int image_count;
	struct wlr_xcursor_image **images;
	char *name;
	uint32_t total_delay; /* total duration of the animation in ms */
};

A cursor.

If the cursor is animated, it may contain more than a single image.

wlr_xcursor_frame()

int wlr_xcursor_frame(​struct wlr_xcursor *cursor, uint32_t time);

Find the frame for a given elapsed time in a cursor animation.

This function converts a timestamp (in ms) to a cursor image index.

wlr_xcursor_get_resize_name()

const char *wlr_xcursor_get_resize_name(​enum wlr_edges edges);

Get the name of the resize cursor for the given edges.

struct wlr_xcursor_image

struct wlr_xcursor_image {
	uint32_t width; /* actual width */
	uint32_t height; /* actual height */
	uint32_t hotspot_x; /* hot-spot x (must be inside image) */
	uint32_t hotspot_y; /* hot-spot y (must be inside image) */
	uint32_t delay; /* animation delay to next frame (ms) */
	uint8_t *buffer; /* pixel data */
};

A still cursor image.

The buffer contains pixels layed out in a packed DRM_FORMAT_ARGB8888 format.

struct wlr_xcursor_theme

struct wlr_xcursor_theme {
	unsigned int cursor_count;
	struct wlr_xcursor **cursors;
	char *name;
	int size;
};

Container for an Xcursor theme.

wlr_xcursor_theme_destroy()

void wlr_xcursor_theme_destroy(​struct wlr_xcursor_theme *theme);

Destroy a cursor theme.

This implicitly destroys all child cursors and cursor images.

wlr_xcursor_theme_get_cursor()

struct wlr_xcursor *wlr_xcursor_theme_get_cursor(​struct wlr_xcursor_theme *theme, const char *name);

Obtain a cursor for the specified name (e.g. "left_ptr").

If the cursor could not be found, NULL is returned.

wlr_xcursor_theme_load()

struct wlr_xcursor_theme *wlr_xcursor_theme_load(​const char *name, int size);

Loads the named Xcursor theme.

This is useful if you need cursor images for your compositor to use when a client-side cursor is not available or you wish to override client-side cursors for a particular UI interaction (such as using a grab cursor when moving a window around).

The size is given in pixels.

If a cursor theme with the given name couldn't be loaded, a fallback theme is loaded.

On error, NULL is returned.