From 8c945c9832f94835cd6482a6525217cd21da08af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 21 Nov 2019 18:17:02 +0100 Subject: [PATCH] input: may get keyboard_exit() event with no focused terminal This happens on Sway when exiting a screen locker. Or at least that's when we see the problem; it's unclear if the event occurs when starting the screen locker, or when exiting it. Or maybe its both. Anyway, don't try to unfocus a NULL-terminal. --- input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/input.c b/input.c index 40cfa613..d47cf889 100644 --- a/input.c +++ b/input.c @@ -138,8 +138,12 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, { struct wayland *wayl = data; + assert(wayl->focused == NULL || + wayl_terminal_from_surface(wayl, surface) == wayl->focused); + stop_repeater(wayl, -1); - term_focus_out(wayl->focused); + if (wayl->focused != NULL) + term_focus_out(wayl->focused); wayl->focused = NULL; }