rootston: handle request_set_cursor

This commit is contained in:
emersion 2017-10-07 10:55:17 +02:00
parent 78d3582b70
commit 65d57920e5
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 29 additions and 1 deletions

View file

@ -107,6 +107,8 @@ struct roots_input {
struct wl_listener cursor_tool_tip;
struct wl_listener pointer_grab_end;
struct wl_listener request_set_cursor;
};
struct roots_input *input_create(struct roots_server *server,

View file

@ -274,6 +274,24 @@ static void handle_pointer_grab_end(struct wl_listener *listener, void *data) {
cursor_update_position(input, 0);
}
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_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)) {
wlr_log(L_DEBUG, "Failed to set hardware cursor");
return;
}
}
}
void cursor_initialize(struct roots_input *input) {
struct wlr_cursor *cursor = input->cursor;
@ -304,6 +322,11 @@ void cursor_initialize(struct roots_input *input) {
wl_signal_add(&input->wl_seat->events.pointer_grab_end, &input->pointer_grab_end);
input->pointer_grab_end.notify = handle_pointer_grab_end;
wl_list_init(&input->request_set_cursor.link);
wl_signal_add(&input->wl_seat->events.request_set_cursor,
&input->request_set_cursor);
input->request_set_cursor.notify = handle_request_set_cursor;
}
static void reset_device_mappings(struct roots_config *config,

View file

@ -24,7 +24,10 @@ static void wl_pointer_set_cursor(struct wl_client *client,
struct wl_resource *surface_resource,
int32_t hotspot_x, int32_t hotspot_y) {
struct wlr_seat_handle *handle = wl_resource_get_user_data(resource);
struct wlr_surface *surface = wl_resource_get_user_data(surface_resource);
struct wlr_surface *surface = NULL;
if (surface_resource != NULL) {
surface = wl_resource_get_user_data(surface_resource);
}
struct wlr_seat_pointer_request_set_cursor_event *event =
calloc(1, sizeof(struct wlr_seat_pointer_request_set_cursor_event));