[PATCH weston 1/2] Revert "input: Do not override keyboard focus on restore"

Quentin Glidic sardemff7+wayland at sardemff7.net
Thu Aug 2 08:29:52 UTC 2018


From: Quentin Glidic <sardemff7+git at sardemff7.net>

This reverts commit 85d55540cb64bf97a08b40f79dc66843f8295d3b.
It brought issues for proper VT switching focus handling.

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
 libweston/input.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index 04c114199..f1017dc1b 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1527,7 +1527,6 @@ WL_EXPORT void
 weston_keyboard_set_focus(struct weston_keyboard *keyboard,
 			  struct weston_surface *surface)
 {
-	struct weston_seat *seat = keyboard->seat;
 	struct wl_resource *resource;
 	struct wl_display *display = keyboard->seat->compositor->wl_display;
 	uint32_t serial;
@@ -1569,11 +1568,6 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
 		keyboard->focus_serial = serial;
 	}
 
-	if (seat->saved_kbd_focus) {
-		wl_list_remove(&seat->saved_kbd_focus_listener.link);
-		seat->saved_kbd_focus = NULL;
-	}
-
 	wl_list_remove(&keyboard->focus_resource_listener.link);
 	wl_list_init(&keyboard->focus_resource_listener.link);
 	if (surface)
@@ -2265,8 +2259,11 @@ notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
 	}
 
 	surface = seat->saved_kbd_focus;
+
 	if (surface) {
+		wl_list_remove(&seat->saved_kbd_focus_listener.link);
 		weston_keyboard_set_focus(keyboard, surface);
+		seat->saved_kbd_focus = NULL;
 	}
 }
 
@@ -2276,7 +2273,6 @@ notify_keyboard_focus_out(struct weston_seat *seat)
 	struct weston_compositor *compositor = seat->compositor;
 	struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
 	struct weston_pointer *pointer = weston_seat_get_pointer(seat);
-	struct weston_surface *focus = keyboard->focus;
 	uint32_t *k, serial;
 
 	serial = wl_display_next_serial(compositor->wl_display);
@@ -2288,18 +2284,18 @@ notify_keyboard_focus_out(struct weston_seat *seat)
 
 	seat->modifier_state = 0;
 
-	weston_keyboard_set_focus(keyboard, NULL);
-	weston_keyboard_cancel_grab(keyboard);
-	if (pointer)
-		weston_pointer_cancel_grab(pointer);
-
-	if (focus) {
-		seat->saved_kbd_focus = focus;
+	if (keyboard->focus) {
+		seat->saved_kbd_focus = keyboard->focus;
 		seat->saved_kbd_focus_listener.notify =
 			destroy_device_saved_kbd_focus;
-		wl_signal_add(&focus->destroy_signal,
+		wl_signal_add(&keyboard->focus->destroy_signal,
 			      &seat->saved_kbd_focus_listener);
 	}
+
+	weston_keyboard_set_focus(keyboard, NULL);
+	weston_keyboard_cancel_grab(keyboard);
+	if (pointer)
+		weston_pointer_cancel_grab(pointer);
 }
 
 WL_EXPORT void
-- 
2.18.0



More information about the wayland-devel mailing list