1From b9389e19424edf3f44f1f1c886377c61b612e850 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Tue, 12 May 2020 15:35:40 +0800
4Subject: [PATCH 24/93] input: Fix losing focus during re-attaching keyboard
5
6Call notify_keyboard_focus_out() when releasing the last keyboard to
7pair with the notify_keyboard_focus_in().
8
9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
10---
11 libweston/input.c | 7 +++++--
12 1 file changed, 5 insertions(+), 2 deletions(-)
13
14diff --git a/libweston/input.c b/libweston/input.c
15index 8c9cabc..352aab6 100644
16--- a/libweston/input.c
17+++ b/libweston/input.c
18@@ -3400,8 +3400,11 @@ weston_seat_release_keyboard(struct weston_seat *seat)
19 	seat->keyboard_device_count--;
20 	assert(seat->keyboard_device_count >= 0);
21 	if (seat->keyboard_device_count == 0) {
22-		weston_keyboard_set_focus(seat->keyboard_state, NULL);
23-		weston_keyboard_cancel_grab(seat->keyboard_state);
24+		/* Pair with notify_keyboard_focus_in() */
25+		seat->keyboard_device_count = 1;
26+		notify_keyboard_focus_out(seat);
27+		seat->keyboard_device_count = 0;
28+
29 		weston_keyboard_reset_state(seat->keyboard_state);
30 		seat_send_updated_caps(seat);
31 	}
32--
332.20.1
34
35