On Thu, Aug 02, 2018 at 10:29:53AM +0200, Quentin Glidic wrote:
> From: Quentin Glidic <[email protected]>
> 
> If we start a special (grabbing) client when Weston is unfocused, it
> would lose focus when coming back to Weston.
> 
> A first attempt to fix this was 85d55540cb64bf97a08b40f79dc66843f8295d3b
> but it messed with VT switching.
> 
> This fix just updates the saved focus, so when Weston gets focused back,
> it will focus the correct client.
> 
> Signed-off-by: Quentin Glidic <[email protected]>
> ---
> 
> Sorry for the delay, I hoped I could make a Gitlab MR but sadly it
> didn’t happen yet. :-)
> 
> I think this patch won’t conflict with VT switching, and it does fix the
> issue I had initially.

this seems like it should do the thing, thanks.

Acked-by: Peter Hutterer <[email protected]>

Cheers,
   Peter

>  libweston/input.c | 38 +++++++++++++++++++++++++-------------
>  1 file changed, 25 insertions(+), 13 deletions(-)
> 
> diff --git a/libweston/input.c b/libweston/input.c
> index f1017dc1b..6a7f584fd 100644
> --- a/libweston/input.c
> +++ b/libweston/input.c
> @@ -1507,6 +1507,17 @@ weston_pointer_set_focus(struct weston_pointer 
> *pointer,
>       wl_signal_emit(&pointer->focus_signal, pointer);
>  }
>  
> +static void
> +destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
> +{
> +     struct weston_seat *ws;
> +
> +     ws = container_of(listener, struct weston_seat,
> +                       saved_kbd_focus_listener);
> +
> +     ws->saved_kbd_focus = NULL;
> +}
> +
>  static void
>  send_enter_to_resource_list(struct wl_list *list,
>                           struct weston_keyboard *keyboard,
> @@ -1528,7 +1539,8 @@ weston_keyboard_set_focus(struct weston_keyboard 
> *keyboard,
>                         struct weston_surface *surface)
>  {
>       struct wl_resource *resource;
> -     struct wl_display *display = keyboard->seat->compositor->wl_display;
> +     struct weston_seat *seat = keyboard->seat;
> +     struct wl_display *display = seat->compositor->wl_display;
>       uint32_t serial;
>       struct wl_list *focus_resource_list;
>  
> @@ -1540,6 +1552,17 @@ weston_keyboard_set_focus(struct weston_keyboard 
> *keyboard,
>       if (surface && !surface->resource)
>               surface = NULL;
>  
> +     /* If we have a saved focus, this means Weston itself is unfocused.
> +      * In this case, we just want to update our to-be-restored focus.
> +      */
> +     if (seat->saved_kbd_focus != NULL && surface != NULL) {
> +             wl_list_remove(&seat->saved_kbd_focus_listener.link);
> +             seat->saved_kbd_focus = surface;
> +             wl_signal_add(&surface->destroy_signal,
> +                           &seat->saved_kbd_focus_listener);
> +             return;
> +     }
> +
>       focus_resource_list = &keyboard->focus_resource_list;
>  
>       if (!wl_list_empty(focus_resource_list) && keyboard->focus != surface) {
> @@ -2229,17 +2252,6 @@ notify_pointer_focus(struct weston_seat *seat, struct 
> weston_output *output,
>       }
>  }
>  
> -static void
> -destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
> -{
> -     struct weston_seat *ws;
> -
> -     ws = container_of(listener, struct weston_seat,
> -                       saved_kbd_focus_listener);
> -
> -     ws->saved_kbd_focus = NULL;
> -}
> -
>  WL_EXPORT void
>  notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
>                        enum weston_key_state_update update_state)
> @@ -2262,8 +2274,8 @@ notify_keyboard_focus_in(struct weston_seat *seat, 
> struct wl_array *keys,
>  
>       if (surface) {
>               wl_list_remove(&seat->saved_kbd_focus_listener.link);
> -             weston_keyboard_set_focus(keyboard, surface);
>               seat->saved_kbd_focus = NULL;
> +             weston_keyboard_set_focus(keyboard, surface);
>       }
>  }
>  
> -- 
> 2.18.0
> 
> _______________________________________________
> wayland-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 
_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to