1From 5b237ccd52bd61121bcc7488538d5acf532dfbe1 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 21/79] 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 ec7e416..6438b52 100644
16--- a/libweston/input.c
17+++ b/libweston/input.c
18@@ -3342,8 +3342,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