From d3a2ea33e5308f46d4c148cc1de7c428de782536 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sat, 16 Apr 2022 18:59:22 +0200 Subject: [PATCH] types/seat/wlr_seat.c: fix focused_client being null after seat_client recreation --- types/seat/wlr_seat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index f2fd04c1..5280bc46 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "types/wlr_seat.h" #include "util/global.h" @@ -142,6 +143,20 @@ static void seat_handle_bind(struct wl_client *client, void *_wlr_seat, wl_signal_init(&seat_client->events.destroy); wl_list_insert(&wlr_seat->clients, &seat_client->link); + + struct wlr_surface *pointer_focus = + wlr_seat->pointer_state.focused_surface; + if (pointer_focus != NULL && + wl_resource_get_client(pointer_focus->resource) == client) { + wlr_seat->pointer_state.focused_client = seat_client; + } + + struct wlr_surface *keyboard_focus = + wlr_seat->keyboard_state.focused_surface; + if (keyboard_focus != NULL && + wl_resource_get_client(keyboard_focus->resource) == client) { + wlr_seat->keyboard_state.focused_client = seat_client; + } } wl_resource_set_implementation(wl_resource, &seat_impl,