aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-08 21:21:06 +0200
committeremersion <contact@emersion.fr>2017-10-08 21:21:06 +0200
commit9b83caa658de2b51e36266beac048c96a556037c (patch)
tree095fbf13db83522e05a1a4d96992cedc62615c8a
parent65d57920e534acb231bb04964b257b2186c7ce73 (diff)
Add wlr_output_set_cursor_surface
-rw-r--r--backend/wayland/output.c8
-rw-r--r--include/wlr/types/wlr_output.h14
-rw-r--r--rootston/cursor.c14
-rw-r--r--types/wlr_output.c26
4 files changed, 50 insertions, 12 deletions
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 062a91a1..03b43b35 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -55,9 +55,15 @@ static void wlr_wl_output_transform(struct wlr_output *_output,
static bool wlr_wl_output_set_cursor(struct wlr_output *_output,
const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y) {
-
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
struct wlr_wl_backend *backend = output->backend;
+
+ if (!buf) {
+ wl_pointer_set_cursor(output->backend->pointer, output->enter_serial,
+ NULL, 0, 0);
+ return true;
+ }
+
stride *= 4; // stride is given in pixels, we need it in bytes
if (!backend->shm || !backend->pointer) {
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 52d377e3..c25e2fb8 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -54,18 +54,22 @@ struct wlr_output {
void *data;
};
+struct wlr_surface;
+
void wlr_output_enable(struct wlr_output *output, bool enable);
bool wlr_output_set_mode(struct wlr_output *output,
- struct wlr_output_mode *mode);
+ struct wlr_output_mode *mode);
void wlr_output_transform(struct wlr_output *output,
- enum wl_output_transform transform);
+ enum wl_output_transform transform);
bool wlr_output_set_cursor(struct wlr_output *output,
- const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
- int32_t hotspot_x, int32_t hotspot_y);
+ const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
+ int32_t hotspot_x, int32_t hotspot_y);
+bool wlr_output_set_cursor_surface(struct wlr_output *output,
+ struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y);
void wlr_output_destroy(struct wlr_output *output);
void wlr_output_effective_resolution(struct wlr_output *output,
- int *width, int *height);
+ int *width, int *height);
void wlr_output_make_current(struct wlr_output *output);
void wlr_output_swap_buffers(struct wlr_output *output);
void wlr_output_set_gamma(struct wlr_output *output,
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 3423d33b..f9372f7f 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -278,14 +278,18 @@ static void handle_request_set_cursor(struct wl_listener *listener,
void *data) {
struct roots_input *input = wl_container_of(listener, input,
request_set_cursor);
- //struct wlr_seat_pointer_request_set_cursor_event *event = data;
+ struct wlr_seat_pointer_request_set_cursor_event *event = data;
+ if (event->surface == NULL) {
+ wlr_log(L_DEBUG, "handle_request_set_cursor with NULL surface");
+ return;
+ }
+
+ wlr_log(L_DEBUG, "handle_request_set_cursor");
- struct wlr_xcursor_image *image = input->xcursor->images[0];
struct roots_output *output;
wl_list_for_each(output, &input->server->desktop->outputs, link) {
- if (!wlr_output_set_cursor(output->wlr_output, image->buffer,
- image->width, image->width, image->height,
- image->hotspot_x, image->hotspot_y)) {
+ if (!wlr_output_set_cursor_surface(output->wlr_output,
+ event->surface, event->hotspot_x, event->hotspot_y)) {
wlr_log(L_DEBUG, "Failed to set hardware cursor");
return;
}
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 64f67f2d..67bd826f 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -4,6 +4,7 @@
#include <tgmath.h>
#include <wayland-server.h>
#include <wlr/types/wlr_output.h>
+#include <wlr/types/wlr_surface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/util/list.h>
#include <wlr/util/log.h>
@@ -158,7 +159,8 @@ bool wlr_output_set_cursor(struct wlr_output *output,
}
if (!output->cursor.texture) {
- output->cursor.texture = wlr_render_texture_create(output->cursor.renderer);
+ output->cursor.texture =
+ wlr_render_texture_create(output->cursor.renderer);
if (!output->cursor.texture) {
return false;
}
@@ -168,6 +170,28 @@ bool wlr_output_set_cursor(struct wlr_output *output,
WL_SHM_FORMAT_ARGB8888, stride, width, height, buf);
}
+bool wlr_output_set_cursor_surface(struct wlr_output *output,
+ struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
+ if (output->impl->set_cursor) {
+ output->impl->set_cursor(output, NULL, 0, 0, 0, 0, 0);
+ wlr_log(L_INFO, "TODO: wlr_output_set_cursor_surface for hw cursors");
+ }
+
+ output->cursor.is_sw = true;
+ output->cursor.width = surface->current->width;
+ output->cursor.height = surface->current->height;
+ output->cursor.hotspot_x = hotspot_x;
+ output->cursor.hotspot_y = hotspot_y;
+
+ wlr_texture_destroy(output->cursor.texture);
+ output->cursor.texture = surface->texture;
+
+ wlr_renderer_destroy(output->cursor.renderer);
+ output->cursor.renderer = surface->renderer;
+
+ return true;
+}
+
bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) {
output->cursor.x = x;
output->cursor.y = y;