From e27eff8a29abd74448322ae78baa99a489e43620 Mon Sep 17 00:00:00 2001
From: Tony Crisci <tony@dubstepdish.com>
Date: Sun, 17 Dec 2017 08:30:20 -0500
Subject: send keyboard enter on keyboard configuration

---
 sway/input/input-manager.c | 2 ++
 sway/input/seat.c          | 9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

(limited to 'sway/input')

diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 6a49b13b..fa8e4b49 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -145,6 +145,7 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
 
 	struct sway_seat *seat = NULL;
 	if (!input_has_seat_configuration(input)) {
+		sway_log(L_DEBUG, "no seat configuration, using default seat");
 		seat = input_manager_get_seat(input, default_seat);
 		sway_seat_add_device(seat, input_device);
 		return;
@@ -245,6 +246,7 @@ void sway_input_manager_apply_input_config(struct sway_input_manager *input,
 
 void sway_input_manager_apply_seat_config(struct sway_input_manager *input,
 		struct seat_config *seat_config) {
+	sway_log(L_DEBUG, "applying new seat config for seat %s", seat_config->name);
 	struct sway_seat *seat = input_manager_get_seat(input, seat_config->name);
 	// the old config is invalid so clear it
 	sway_seat_set_config(seat, NULL);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 1e62efa1..8fe82b46 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -68,6 +68,13 @@ static void seat_configure_keyboard(struct sway_seat *seat,
 		sway_keyboard_create(seat, seat_device);
 	}
 	sway_keyboard_configure(seat_device->keyboard);
+	wlr_seat_set_keyboard(seat->wlr_seat,
+		seat_device->input_device->wlr_device);
+	if (seat->focus) {
+		// force notify reenter to pick up the new configuration
+		wlr_seat_keyboard_clear_focus(seat->wlr_seat);
+		wlr_seat_keyboard_notify_enter(seat->wlr_seat, seat->focus->sway_view->surface);
+	}
 }
 
 static struct sway_seat_device *sway_seat_get_device(struct sway_seat *seat,
@@ -101,8 +108,6 @@ void sway_seat_configure_device(struct sway_seat *seat,
 			break;
 		case WLR_INPUT_DEVICE_KEYBOARD:
 			seat_configure_keyboard(seat, seat_device);
-			wlr_seat_set_keyboard(seat->wlr_seat,
-				seat_device->input_device->wlr_device);
 			break;
 		case WLR_INPUT_DEVICE_TOUCH:
 		case WLR_INPUT_DEVICE_TABLET_PAD:
-- 
cgit v1.2.3