Merge branch 'tadeokondrak-cursor-image-handling'
This commit is contained in:
commit
7fd2f1fb29
3 changed files with 33 additions and 2 deletions
|
@ -20,6 +20,7 @@ struct kiwmi_cursor {
|
||||||
struct wl_listener cursor_button;
|
struct wl_listener cursor_button;
|
||||||
struct wl_listener cursor_axis;
|
struct wl_listener cursor_axis;
|
||||||
struct wl_listener cursor_frame;
|
struct wl_listener cursor_frame;
|
||||||
|
struct wl_listener request_set_cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kiwmi_cursor *cursor_create(
|
struct kiwmi_cursor *cursor_create(
|
||||||
|
|
|
@ -139,6 +139,31 @@ cursor_frame_notify(struct wl_listener *listener, void *UNUSED(data))
|
||||||
wlr_seat_pointer_notify_frame(input->seat);
|
wlr_seat_pointer_notify_frame(input->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
struct wlr_surface *focused_surface =
|
||||||
|
event->seat_client->seat->pointer_state.focused_surface;
|
||||||
|
struct wl_client *focused_client = NULL;
|
||||||
|
|
||||||
|
if (focused_surface && focused_surface->resource) {
|
||||||
|
focused_client = wl_resource_get_client(focused_surface->resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event->seat_client->client != focused_client) {
|
||||||
|
wlr_log(
|
||||||
|
WLR_DEBUG, "Ignoring request to set cursor on unfocused client");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_cursor_set_surface(
|
||||||
|
cursor->cursor, event->surface, event->hotspot_x, event->hotspot_y);
|
||||||
|
}
|
||||||
|
|
||||||
struct kiwmi_cursor *
|
struct kiwmi_cursor *
|
||||||
cursor_create(
|
cursor_create(
|
||||||
struct kiwmi_server *server,
|
struct kiwmi_server *server,
|
||||||
|
@ -182,5 +207,10 @@ cursor_create(
|
||||||
cursor->cursor_frame.notify = cursor_frame_notify;
|
cursor->cursor_frame.notify = cursor_frame_notify;
|
||||||
wl_signal_add(&cursor->cursor->events.frame, &cursor->cursor_frame);
|
wl_signal_add(&cursor->cursor->events.frame, &cursor->cursor_frame);
|
||||||
|
|
||||||
|
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;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,14 +71,14 @@ input_init(struct kiwmi_input *input)
|
||||||
{
|
{
|
||||||
struct kiwmi_server *server = wl_container_of(input, server, 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);
|
input->cursor = cursor_create(server, server->desktop.output_layout);
|
||||||
if (!input->cursor) {
|
if (!input->cursor) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create cursor");
|
wlr_log(WLR_ERROR, "Failed to create cursor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
input->seat = wlr_seat_create(server->wl_display, "seat-0");
|
|
||||||
|
|
||||||
wl_list_init(&input->keyboards);
|
wl_list_init(&input->keyboards);
|
||||||
|
|
||||||
input->new_input.notify = new_input_notify;
|
input->new_input.notify = new_input_notify;
|
||||||
|
|
Loading…
Reference in a new issue