Basic implementation of request_set_cursor

Requires moving wlr_seat initialization above cursor creation, so we can
add listeners to it. Currently does no verification that the client
actually has focus.
This commit is contained in:
Tadeo Kondrak 2019-12-29 01:00:35 -07:00
parent a25ff1957b
commit 7f9b9748ea
No known key found for this signature in database
GPG key ID: D41E092CA43F1D8B
3 changed files with 19 additions and 2 deletions

View file

@ -18,6 +18,7 @@ struct kiwmi_cursor {
struct wl_listener cursor_motion;
struct wl_listener cursor_motion_absolute;
struct wl_listener cursor_button;
struct wl_listener request_set_cursor;
};
struct kiwmi_cursor *cursor_create(

View file

@ -110,6 +110,17 @@ cursor_button_notify(struct wl_listener *listener, void *data)
}
}
static void
request_set_cursor_notify(struct wl_listener *listener, void *data)
{
struct kiwmi_cursor *cursor =
wl_container_of(listener, cursor, request_set_cursor);
struct wlr_seat_pointer_request_set_cursor_event *event = data;
// FIXME: this should verify if the window has focus
wlr_cursor_set_surface(
cursor->cursor, event->surface, event->hotspot_x, event->hotspot_y);
}
struct kiwmi_cursor *
cursor_create(
struct kiwmi_server *server,
@ -147,5 +158,10 @@ cursor_create(
cursor->cursor_button.notify = cursor_button_notify;
wl_signal_add(&cursor->cursor->events.button, &cursor->cursor_button);
cursor->request_set_cursor.notify = request_set_cursor_notify;
wl_signal_add(
&server->input.seat->events.request_set_cursor,
&cursor->request_set_cursor);
return cursor;
}

View file

@ -71,14 +71,14 @@ input_init(struct kiwmi_input *input)
{
struct kiwmi_server *server = wl_container_of(input, server, input);
input->seat = wlr_seat_create(server->wl_display, "seat-0");
input->cursor = cursor_create(server, server->desktop.output_layout);
if (!input->cursor) {
wlr_log(WLR_ERROR, "Failed to create cursor");
return false;
}
input->seat = wlr_seat_create(server->wl_display, "seat-0");
wl_list_init(&input->keyboards);
input->new_input.notify = new_input_notify;