[PATCH weston v2] input: Do not override keyboard focus on restore
Quentin Glidic
sardemff7+wayland at sardemff7.net
Fri Jul 21 12:02:40 UTC 2017
From: Quentin Glidic <sardemff7+git at sardemff7.net>
If we start a special (grabbing) client when Weston is unfocused, it
would lose focus when coming back to Weston.
Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
v2:
Reset saved focus in weston_keybord_set_focus()
Shuffled the focus saving code (since it calls set_focus() to NULLify it)
libweston/input.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/libweston/input.c b/libweston/input.c
index 4fedc558..d506623a 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1317,6 +1317,7 @@ 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;
@@ -1350,6 +1351,11 @@ 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 && surface->resource)
@@ -2067,11 +2073,8 @@ 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;
}
}
@@ -2081,6 +2084,7 @@ 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);
@@ -2092,18 +2096,18 @@ notify_keyboard_focus_out(struct weston_seat *seat)
seat->modifier_state = 0;
- if (keyboard->focus) {
- seat->saved_kbd_focus = keyboard->focus;
- seat->saved_kbd_focus_listener.notify =
- destroy_device_saved_kbd_focus;
- 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);
+
+ if (focus) {
+ seat->saved_kbd_focus = focus;
+ seat->saved_kbd_focus_listener.notify =
+ destroy_device_saved_kbd_focus;
+ wl_signal_add(&focus->destroy_signal,
+ &seat->saved_kbd_focus_listener);
+ }
}
WL_EXPORT void
--
2.13.3
More information about the wayland-devel
mailing list