aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-11-11 17:27:44 +0100
committeremersion <contact@emersion.fr>2017-11-11 17:27:44 +0100
commitac1573b0e7b0b08413e115bb88682ebedbfbf39a (patch)
tree4cdbbf78956950066c65c6c5885a0d07bc881fe0
parent2bee288090d930a09be5f9176a519c1ec02c63de (diff)
Add scale parameter to wlr_cursor_set_image
-rw-r--r--examples/multi-pointer.c4
-rw-r--r--examples/pointer.c4
-rw-r--r--include/wlr/types/wlr_cursor.h15
-rw-r--r--rootston/cursor.c2
-rw-r--r--rootston/seat.c21
-rw-r--r--types/wlr_cursor.c7
6 files changed, 35 insertions, 18 deletions
diff --git a/examples/multi-pointer.c b/examples/multi-pointer.c
index e29a69db..f1bcebc7 100644
--- a/examples/multi-pointer.c
+++ b/examples/multi-pointer.c
@@ -86,7 +86,7 @@ static void handle_output_add(struct output_state *ostate) {
struct wlr_xcursor_image *image = sample->xcursor->images[0];
wlr_cursor_set_image(cursor->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ image->width, image->height, image->hotspot_x, image->hotspot_y, 0);
wlr_cursor_warp(cursor->cursor, NULL, cursor->cursor->x,
cursor->cursor->y);
@@ -150,7 +150,7 @@ static void handle_input_add(struct compositor_state *state,
struct wlr_xcursor_image *image = sample->xcursor->images[0];
wlr_cursor_set_image(cursor->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ image->width, image->height, image->hotspot_x, image->hotspot_y, 0);
wl_list_insert(&sample->cursors, &cursor->link);
}
diff --git a/examples/pointer.c b/examples/pointer.c
index 1bcd7349..476cc617 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -110,7 +110,7 @@ static void handle_output_add(struct output_state *ostate) {
struct wlr_xcursor_image *image = sample->xcursor->images[0];
wlr_cursor_set_image(sample->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ image->width, image->height, image->hotspot_x, image->hotspot_y, 0);
wlr_cursor_warp(sample->cursor, NULL, sample->cursor->x, sample->cursor->y);
}
@@ -321,7 +321,7 @@ int main(int argc, char *argv[]) {
struct wlr_xcursor_image *image = state.xcursor->images[0];
wlr_cursor_set_image(state.cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ image->width, image->height, image->hotspot_x, image->hotspot_y, 0);
compositor_init(&compositor);
if (!wlr_backend_start(compositor.backend)) {
diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h
index 1aac2b94..3df74d28 100644
--- a/include/wlr/types/wlr_cursor.h
+++ b/include/wlr/types/wlr_cursor.h
@@ -60,9 +60,22 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
double delta_x, double delta_y);
+/**
+ * Set the cursor image. stride is given in bytes. If pixels is NULL, hides the
+ * cursor.
+ *
+ * If scale isn't zero, the image is only set on outputs having the provided
+ * scale.
+ */
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);
+ int32_t hotspot_y, uint32_t scale);
+
+/**
+ * Set the cursor surface. The surface can be committed to update the cursor
+ * image. The surface position is substracted from the hotspot. A NULL surface
+ * commit hides the cursor.
+ */
void wlr_cursor_set_surface(struct wlr_cursor *cur, struct wlr_surface *surface,
int32_t hotspot_x, int32_t hotspot_y);
diff --git a/rootston/cursor.c b/rootston/cursor.c
index cba9e782..c3982e0e 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -30,7 +30,7 @@ void roots_cursor_destroy(struct roots_cursor *cursor) {
static void cursor_set_xcursor_image(struct roots_cursor *cursor,
struct wlr_xcursor_image *image) {
wlr_cursor_set_image(cursor->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ image->width, image->height, image->hotspot_x, image->hotspot_y, 0);
}
static void roots_cursor_update_position(struct roots_cursor *cursor, uint32_t time) {
diff --git a/rootston/seat.c b/rootston/seat.c
index 4602aad5..280443ac 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -176,6 +176,12 @@ void roots_seat_configure_cursor(struct roots_seat *seat) {
}
}
+static void seat_set_xcursor_image(struct roots_seat *seat, struct
+ wlr_xcursor_image *image) {
+ wlr_cursor_set_image(seat->cursor->cursor, image->buffer, image->width,
+ image->width, image->height, image->hotspot_x, image->hotspot_y, 0);
+}
+
static void roots_seat_init_cursor(struct roots_seat *seat) {
seat->cursor = roots_cursor_create(seat);
if (!seat->cursor) {
@@ -204,8 +210,7 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
}
struct wlr_xcursor_image *image = xcursor->images[0];
- wlr_cursor_set_image(seat->cursor->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ seat_set_xcursor_image(seat, image);
// XXX: xwayland will always have the theme of the last created seat
if (seat->input->server->desktop->xwayland != NULL) {
@@ -471,10 +476,10 @@ void roots_seat_remove_device(struct roots_seat *seat,
}
void roots_seat_configure_xcursor(struct roots_seat *seat) {
- struct wlr_xcursor *xcursor = get_default_xcursor(seat->cursor->xcursor_theme);
+ struct wlr_xcursor *xcursor =
+ get_default_xcursor(seat->cursor->xcursor_theme);
struct wlr_xcursor_image *image = xcursor->images[0];
- wlr_cursor_set_image(seat->cursor->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
+ seat_set_xcursor_image(seat, image);
wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x,
seat->cursor->cursor->y);
@@ -537,12 +542,6 @@ void roots_seat_focus_view(struct roots_seat *seat, struct roots_view *view) {
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface);
}
-static void seat_set_xcursor_image(struct roots_seat *seat, struct
- wlr_xcursor_image *image) {
- wlr_cursor_set_image(seat->cursor->cursor, image->buffer, image->width,
- image->width, image->height, image->hotspot_x, image->hotspot_y);
-}
-
void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {
struct roots_cursor *cursor = seat->cursor;
cursor->mode = ROOTS_CURSOR_MOVE;
diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c
index dfaccb53..e8965b68 100644
--- a/types/wlr_cursor.c
+++ b/types/wlr_cursor.c
@@ -299,9 +299,14 @@ void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
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) {
+ int32_t hotspot_y, uint32_t scale) {
struct wlr_cursor_output_cursor *output_cursor;
wl_list_for_each(output_cursor, &cur->state->output_cursors, link) {
+ if (scale != 0 &&
+ output_cursor->output_cursor->output->scale != scale) {
+ continue;
+ }
+
wlr_output_cursor_set_image(output_cursor->output_cursor, pixels,
stride, width, height, hotspot_x, hotspot_y);
}