[PATCH weston 1/2] Reset focus on unknown seats when restoring focus state
Neil Roberts
neil at linux.intel.com
Wed Apr 9 08:33:31 PDT 2014
The focus_state list on a workspace only contains entries for seats
which have a keyboard focus on that workspace. For workspaces that
have no surfaces the list will be empty. That means that when a
workspace with no surfaces is switched to it would previously leave
the keyboard focus unaffected and you could still type in the surface
on the old workspace.
This patch makes it instead reset the keyboard focus to NULL for seats
without a focus_state. It does this by temporarily stealing the
compositor's list of seats while it iterates the focus_states. After
all of the focus states have been processed any seats remaining in
this temporary list have their focus reset.
https://bugs.freedesktop.org/show_bug.cgi?id=73905
---
desktop-shell/shell.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 466ea93..fa081f3 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -694,8 +694,20 @@ restore_focus_state(struct desktop_shell *shell, struct workspace *ws)
{
struct focus_state *state, *next;
struct weston_surface *surface;
+ struct wl_list pending_seat_list;
+ struct weston_seat *seat, *next_seat;
+
+ /* Temporarily steal the list of seats so that we can keep
+ * track of the seats we've already processed */
+ wl_list_init(&pending_seat_list);
+ wl_list_insert_list(&pending_seat_list, &shell->compositor->seat_list);
+ wl_list_init(&shell->compositor->seat_list);
wl_list_for_each_safe(state, next, &ws->focus_list, link) {
+ wl_list_remove(&state->seat->link);
+ wl_list_insert(&shell->compositor->seat_list,
+ &state->seat->link);
+
if (state->seat->keyboard == NULL)
continue;
@@ -703,6 +715,17 @@ restore_focus_state(struct desktop_shell *shell, struct workspace *ws)
weston_keyboard_set_focus(state->seat->keyboard, surface);
}
+
+ /* For any remaining seats that we don't have a focus state
+ * for we'll reset the keyboard focus to NULL */
+ wl_list_for_each_safe(seat, next_seat, &pending_seat_list, link) {
+ wl_list_insert(&shell->compositor->seat_list, &seat->link);
+
+ if (state->seat->keyboard == NULL)
+ continue;
+
+ weston_keyboard_set_focus(seat->keyboard, NULL);
+ }
}
static void
--
1.8.5.3
More information about the wayland-devel
mailing list