Merge pull request #113 from acrisci/feature/rename-wlr-cursor

rename wlr_cursor to wlr_xcursor
master
Drew DeVault 7 years ago committed by GitHub
commit 3674085fae

@ -22,7 +22,7 @@
#include "cat.h"
struct sample_state {
struct wlr_cursor *cursor;
struct wlr_xcursor *cursor;
double cur_x, cur_y;
float default_color[4];
float clear_color[4];
@ -48,7 +48,7 @@ static void handle_pointer_motion(struct pointer_state *pstate,
state->cur_x += d_x;
state->cur_y += d_y;
struct wlr_cursor_image *image = state->cursor->images[0];
struct wlr_xcursor_image *image = state->cursor->images[0];
struct output_state *output;
wl_list_for_each(output, &pstate->compositor->outputs, link) {
@ -64,7 +64,7 @@ static void handle_pointer_motion_absolute(struct pointer_state *pstate,
state->cur_x = x;
state->cur_y = y;
struct wlr_cursor_image *image = state->cursor->images[0];
struct wlr_xcursor_image *image = state->cursor->images[0];
struct output_state *output;
wl_list_for_each(output, &pstate->compositor->outputs, link) {
@ -109,7 +109,7 @@ static void handle_pointer_axis(struct pointer_state *pstate,
static void handle_output_add(struct output_state *ostate) {
struct sample_state *state = ostate->compositor->data;
struct wlr_output *wlr_output = ostate->output;
struct wlr_cursor_image *image = state->cursor->images[0];
struct wlr_xcursor_image *image = state->cursor->images[0];
if (!wlr_output_set_cursor(wlr_output, image->buffer,
image->width, image->width, image->height)) {
wlr_log(L_DEBUG, "Failed to set hardware cursor");
@ -134,12 +134,12 @@ int main(int argc, char *argv[]) {
compositor.pointer_button_cb = handle_pointer_button;
compositor.pointer_axis_cb = handle_pointer_axis;
struct wlr_cursor_theme *theme = wlr_cursor_theme_load("default", 16);
struct wlr_xcursor_theme *theme = wlr_xcursor_theme_load("default", 16);
if (!theme) {
wlr_log(L_ERROR, "Failed to load cursor theme");
return 1;
}
state.cursor = wlr_cursor_theme_get_cursor(theme, "left_ptr");
state.cursor = wlr_xcursor_theme_get_cursor(theme, "left_ptr");
if (!state.cursor) {
wlr_log(L_ERROR, "Failed to load left_ptr cursor");
return 1;
@ -148,5 +148,5 @@ int main(int argc, char *argv[]) {
compositor_init(&compositor);
compositor_run(&compositor);
wlr_cursor_theme_destroy(theme);
wlr_xcursor_theme_destroy(theme);
}

@ -31,7 +31,7 @@
#define _WLR_XCURSOR_H
#include <stdint.h>
struct wlr_cursor_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) */
@ -40,27 +40,27 @@ struct wlr_cursor_image {
uint8_t *buffer;
};
struct wlr_cursor {
struct wlr_xcursor {
unsigned int image_count;
struct wlr_cursor_image **images;
struct wlr_xcursor_image **images;
char *name;
uint32_t total_delay; /* length of the animation in ms */
};
struct wlr_cursor_theme {
struct wlr_xcursor_theme {
unsigned int cursor_count;
struct wlr_cursor **cursors;
struct wlr_xcursor **cursors;
char *name;
int size;
};
struct wlr_cursor_theme *wlr_cursor_theme_load(const char *name, int size);
struct wlr_xcursor_theme *wlr_xcursor_theme_load(const char *name, int size);
void wlr_cursor_theme_destroy(struct wlr_cursor_theme *theme);
void wlr_xcursor_theme_destroy(struct wlr_xcursor_theme *theme);
struct wlr_cursor *wlr_cursor_theme_get_cursor(
struct wlr_cursor_theme *theme, const char *name);
struct wlr_xcursor *wlr_xcursor_theme_get_cursor(
struct wlr_xcursor_theme *theme, const char *name);
int wlr_cursor_frame(struct wlr_cursor *cursor, uint32_t time);
int wlr_xcursor_frame(struct wlr_xcursor *cursor, uint32_t time);
#endif

@ -1,5 +1,5 @@
lib_wlr_xcursor = static_library('wlr_xcursor', files(
'xcursor.c',
'wlr_cursor.c',
'wlr_xcursor.c',
),
include_directories: wlr_inc)

@ -33,7 +33,7 @@
#include <string.h>
#include "xcursor/xcursor.h"
static void wlr_cursor_destroy(struct wlr_cursor *cursor) {
static void wlr_xcursor_destroy(struct wlr_xcursor *cursor) {
for (size_t i = 0; i < cursor->image_count; i++) {
free(cursor->images[i]->buffer);
free(cursor->images[i]);
@ -46,10 +46,10 @@ static void wlr_cursor_destroy(struct wlr_cursor *cursor) {
#include "xcursor/cursor_data.h"
static struct wlr_cursor *wlr_cursor_create_from_data(
struct cursor_metadata *metadata, struct wlr_cursor_theme *theme) {
struct wlr_cursor *cursor;
struct wlr_cursor_image *image;
static struct wlr_xcursor *wlr_xcursor_create_from_data(
struct cursor_metadata *metadata, struct wlr_xcursor_theme *theme) {
struct wlr_xcursor *cursor;
struct wlr_xcursor_image *image;
int size;
cursor = malloc(sizeof(*cursor));
@ -102,7 +102,7 @@ err_free_cursor:
return NULL;
}
static void load_default_theme(struct wlr_cursor_theme *theme) {
static void load_default_theme(struct wlr_xcursor_theme *theme) {
uint32_t i;
free(theme->name);
@ -118,7 +118,7 @@ static void load_default_theme(struct wlr_cursor_theme *theme) {
for (i = 0; i < theme->cursor_count; ++i) {
theme->cursors[i] =
wlr_cursor_create_from_data(&cursor_metadata[i], theme);
wlr_xcursor_create_from_data(&cursor_metadata[i], theme);
if (theme->cursors[i] == NULL) {
break;
@ -127,10 +127,10 @@ static void load_default_theme(struct wlr_cursor_theme *theme) {
theme->cursor_count = i;
}
static struct wlr_cursor *wlr_cursor_create_from_xcursor_images(
XcursorImages *images, struct wlr_cursor_theme *theme) {
struct wlr_cursor *cursor;
struct wlr_cursor_image *image;
static struct wlr_xcursor *wlr_xcursor_create_from_xcursor_images(
XcursorImages *images, struct wlr_xcursor_theme *theme) {
struct wlr_xcursor *cursor;
struct wlr_xcursor_image *image;
int i, size;
cursor = malloc(sizeof(*cursor));
@ -186,15 +186,15 @@ static struct wlr_cursor *wlr_cursor_create_from_xcursor_images(
}
static void load_callback(XcursorImages *images, void *data) {
struct wlr_cursor_theme *theme = data;
struct wlr_cursor *cursor;
struct wlr_xcursor_theme *theme = data;
struct wlr_xcursor *cursor;
if (wlr_cursor_theme_get_cursor(theme, images->name)) {
if (wlr_xcursor_theme_get_cursor(theme, images->name)) {
XcursorImagesDestroy(images);
return;
}
cursor = wlr_cursor_create_from_xcursor_images(images, theme);
cursor = wlr_xcursor_create_from_xcursor_images(images, theme);
if (cursor) {
theme->cursor_count++;
@ -213,8 +213,8 @@ static void load_callback(XcursorImages *images, void *data) {
XcursorImagesDestroy(images);
}
struct wlr_cursor_theme *wlr_cursor_theme_load(const char *name, int size) {
struct wlr_cursor_theme *theme;
struct wlr_xcursor_theme *wlr_xcursor_theme_load(const char *name, int size) {
struct wlr_xcursor_theme *theme;
theme = malloc(sizeof(*theme));
if (!theme) {
@ -242,8 +242,8 @@ struct wlr_cursor_theme *wlr_cursor_theme_load(const char *name, int size) {
wlr_log(L_DEBUG, "Loaded cursor theme '%s', available cursors:",
theme->name);
for (size_t i = 0; i < theme->cursor_count; ++i) {
struct wlr_cursor *c = theme->cursors[i];
struct wlr_cursor_image *i = c->images[0];
struct wlr_xcursor *c = theme->cursors[i];
struct wlr_xcursor_image *i = c->images[0];
wlr_log(L_DEBUG, "%s (%u images) %dx%d+%d,%d",
c->name, c->image_count,
i->width, i->height, i->hotspot_x, i->hotspot_y);
@ -256,11 +256,11 @@ out_error_name:
return NULL;
}
void wlr_cursor_theme_destroy(struct wlr_cursor_theme *theme) {
void wlr_xcursor_theme_destroy(struct wlr_xcursor_theme *theme) {
unsigned int i;
for (i = 0; i < theme->cursor_count; i++) {
wlr_cursor_destroy(theme->cursors[i]);
wlr_xcursor_destroy(theme->cursors[i]);
}
free(theme->name);
@ -268,7 +268,7 @@ void wlr_cursor_theme_destroy(struct wlr_cursor_theme *theme) {
free(theme);
}
struct wlr_cursor *wlr_cursor_theme_get_cursor(struct wlr_cursor_theme *theme,
struct wlr_xcursor *wlr_xcursor_theme_get_cursor(struct wlr_xcursor_theme *theme,
const char *name) {
unsigned int i;
@ -281,7 +281,7 @@ struct wlr_cursor *wlr_cursor_theme_get_cursor(struct wlr_cursor_theme *theme,
return NULL;
}
static int wlr_cursor_frame_and_duration(struct wlr_cursor *cursor,
static int wlr_xcursor_frame_and_duration(struct wlr_xcursor *cursor,
uint32_t time, uint32_t *duration) {
uint32_t t;
int i;
@ -323,6 +323,6 @@ static int wlr_cursor_frame_and_duration(struct wlr_cursor *cursor,
return i;
}
int wlr_cursor_frame(struct wlr_cursor *_cursor, uint32_t time) {
return wlr_cursor_frame_and_duration(_cursor, time, NULL);
int wlr_xcursor_frame(struct wlr_xcursor *_cursor, uint32_t time) {
return wlr_xcursor_frame_and_duration(_cursor, time, NULL);
}
Loading…
Cancel
Save