From 9dfbb462ca96007b42dc69dfd2c5ee6b10c12c6c Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Sun, 29 Dec 2019 01:16:56 -0700 Subject: [PATCH] Verify focus on cursor image changes --- kiwmi/input/cursor.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kiwmi/input/cursor.c b/kiwmi/input/cursor.c index e63e518..b532426 100644 --- a/kiwmi/input/cursor.c +++ b/kiwmi/input/cursor.c @@ -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); }