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

Submitted by Quentin Glidic on Aug. 2, 2018, 8:29 a.m.

Details

Message ID 20180802082953.11780-1-sardemff7+wayland@sardemff7.net
State New
Series "libinput: Restore keyboard focus after VT switch"
Headers show

Commit Message

Quentin Glidic Aug. 2, 2018, 8:29 a.m.
From: Quentin Glidic <sardemff7+git@sardemff7.net>

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

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

Patch hide | download patch | download mbox

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