[PATCH weston 1/2] Reset focus on unknown seats when restoring focus state
Kristian Høgsberg
hoegsberg at gmail.com
Thu Apr 10 09:34:59 PDT 2014
On Wed, Apr 09, 2014 at 04:33:31PM +0100, Neil Roberts wrote:
> 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.
Yeah, that works, patch applied. It feels a little dirty to modify
compositor->seat_list, but it certainly works.
Kristian
> 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
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list