Verify focus on cursor image changes

This commit is contained in:
Tadeo Kondrak 2019-12-29 01:16:56 -07:00
parent 0bdfdde29b
commit 9dfbb462ca

View file

@ -116,7 +116,21 @@ 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
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);
}