xcursor: sync with libwayland

xcursor.c was copied over from libwayland-cursor. A lot of
cosmetic imporvements have been merged upstream. Copy-paste the
new version.
Simon Ser 2 years ago committed by Alexander Orzechowski
parent 00489b11a0
commit 25d9055281

@ -28,37 +28,31 @@
#include <stdint.h> #include <stdint.h>
typedef int XcursorBool; struct xcursor_image {
typedef uint32_t XcursorUInt; uint32_t version; /* version of the image data */
uint32_t size; /* nominal size for matching */
typedef XcursorUInt XcursorDim; uint32_t width; /* actual width */
typedef XcursorUInt XcursorPixel; uint32_t height; /* actual height */
uint32_t xhot; /* hot spot x (must be inside image) */
typedef struct _XcursorImage { uint32_t yhot; /* hot spot y (must be inside image) */
XcursorUInt version; /* version of the image data */ uint32_t delay; /* animation delay to next frame (ms) */
XcursorDim size; /* nominal size for matching */ uint32_t *pixels; /* pointer to pixels */
XcursorDim width; /* actual width */ };
XcursorDim height; /* actual height */
XcursorDim xhot; /* hot spot x (must be inside image) */
XcursorDim yhot; /* hot spot y (must be inside image) */
XcursorUInt delay; /* animation delay to next frame (ms) */
XcursorPixel *pixels; /* pointer to pixels */
} XcursorImage;
/* /*
* Other data structures exposed by the library API * Other data structures exposed by the library API
*/ */
typedef struct _XcursorImages { struct xcursor_images {
int nimage; /* number of images */ int nimage; /* number of images */
XcursorImage **images; /* array of XcursorImage pointers */ struct xcursor_image **images; /* array of XcursorImage pointers */
char *name; /* name used to load images */ char *name; /* name used to load images */
} XcursorImages; };
void void
XcursorImagesDestroy (XcursorImages *images); xcursor_images_destroy(struct xcursor_images *images);
void void
xcursor_load_theme(const char *theme, int size, xcursor_load_theme(const char *theme, int size,
void (*load_callback)(XcursorImages *, void *), void (*load_callback)(struct xcursor_images *, void *),
void *user_data); void *user_data);
#endif #endif

@ -117,7 +117,7 @@ static void load_default_theme(struct wlr_xcursor_theme *theme) {
} }
static struct wlr_xcursor *xcursor_create_from_xcursor_images( static struct wlr_xcursor *xcursor_create_from_xcursor_images(
XcursorImages *images, struct wlr_xcursor_theme *theme) { struct xcursor_images *images, struct wlr_xcursor_theme *theme) {
struct wlr_xcursor *cursor = calloc(1, sizeof(*cursor)); struct wlr_xcursor *cursor = calloc(1, sizeof(*cursor));
if (!cursor) { if (!cursor) {
return NULL; return NULL;
@ -170,11 +170,11 @@ static struct wlr_xcursor *xcursor_create_from_xcursor_images(
return cursor; return cursor;
} }
static void load_callback(XcursorImages *images, void *data) { static void load_callback(struct xcursor_images *images, void *data) {
struct wlr_xcursor_theme *theme = data; struct wlr_xcursor_theme *theme = data;
if (wlr_xcursor_theme_get_cursor(theme, images->name)) { if (wlr_xcursor_theme_get_cursor(theme, images->name)) {
XcursorImagesDestroy(images); xcursor_images_destroy(images);
return; return;
} }
@ -192,7 +192,7 @@ static void load_callback(XcursorImages *images, void *data) {
} }
} }
XcursorImagesDestroy(images); xcursor_images_destroy(images);
} }
struct wlr_xcursor_theme *wlr_xcursor_theme_load(const char *name, int size) { struct wlr_xcursor_theme *wlr_xcursor_theme_load(const char *name, int size) {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save