diff --git a/include/input/cursor.h b/include/input/cursor.h index df06f1f..e3452f9 100644 --- a/include/input/cursor.h +++ b/include/input/cursor.h @@ -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( diff --git a/kiwmi/input/cursor.c b/kiwmi/input/cursor.c index 91fc8df..fa834db 100644 --- a/kiwmi/input/cursor.c +++ b/kiwmi/input/cursor.c @@ -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; } diff --git a/kiwmi/input/input.c b/kiwmi/input/input.c index 1af7f78..860c6ec 100644 --- a/kiwmi/input/input.c +++ b/kiwmi/input/input.c @@ -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;