From 9cccfe829aab45fd2ab8475127d62ff22c5fedee Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 31 May 2022 15:40:43 +0300 Subject: layout: Add a way common way activate views We install a common function which is being used to de-couple keyboard presence from input and xdg-shell activation. We also also use it at surface removal/destruction. Bug-AGL: SPEC-4413 Signed-off-by: Marius Vlad Change-Id: I2686e5a4aab3e95fbeaa4100faa2dc0051881f24 --- src/desktop.c | 37 +++++++++++++++++++++++++++++++++++++ src/ivi-compositor.h | 5 +++++ src/layout.c | 23 +++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/src/desktop.c b/src/desktop.c index 0e1a989..b2907fe 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -91,6 +91,34 @@ get_focused_output(struct weston_compositor *compositor) return output; } +void +ivi_shell_activate_surface(struct ivi_surface *ivi_surf, + struct ivi_shell_seat *ivi_seat, + uint32_t flags) +{ + struct weston_desktop_surface *dsurface = ivi_surf->dsurface; + struct weston_surface *surface = + weston_desktop_surface_get_surface(dsurface); + + weston_view_activate_input(ivi_surf->view, ivi_seat->seat, flags); + + if (ivi_seat->focused_surface) { + struct ivi_surface *current_focus = + get_ivi_shell_surface(ivi_seat->focused_surface); + struct weston_desktop_surface *dsurface_focus; + assert(current_focus); + + dsurface_focus = current_focus->dsurface; + if (--current_focus->focus_count == 0) + weston_desktop_surface_set_activated(dsurface_focus, false); + } + + ivi_seat->focused_surface = surface; + if (ivi_surf->focus_count++ == 0) + weston_desktop_surface_set_activated(dsurface, true); +} + + static void desktop_surface_added_configure(struct ivi_surface *surface, struct ivi_output *ivi_output) @@ -222,6 +250,8 @@ desktop_surface_removed(struct weston_desktop_surface *dsurface, void *userdata) struct weston_surface *wsurface = weston_desktop_surface_get_surface(dsurface); const char *app_id = NULL; + struct weston_seat *wseat = get_ivi_shell_weston_first_seat(surface->ivi); + struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat); struct ivi_output *output = ivi_layout_get_output_from_surface(surface); @@ -261,6 +291,13 @@ desktop_surface_removed(struct weston_desktop_surface *dsurface, void *userdata) output->active = NULL; } + /* clear out focused_surface to avoid a stale focused_surface. the + * client shell is responsible for keeping track and switch back to the + * last active surface so we don't get do anything at removal, just + * reset it */ + if (ivi_seat && ivi_seat->focused_surface == wsurface) + ivi_seat->focused_surface = NULL; + if (surface->role == IVI_SURFACE_ROLE_REMOTE && output->type == OUTPUT_REMOTE) ivi_destroy_waltham_destroy(surface); diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h index 6dbab99..5137d19 100644 --- a/src/ivi-compositor.h +++ b/src/ivi-compositor.h @@ -462,4 +462,9 @@ get_ivi_shell_seat(struct weston_seat *seat); struct weston_seat * get_ivi_shell_weston_first_seat(struct ivi_compositor *ivi); +void +ivi_shell_activate_surface(struct ivi_surface *ivi_surf, + struct ivi_shell_seat *ivi_seat, + uint32_t flags); + #endif diff --git a/src/layout.c b/src/layout.c index 829e1d5..dd4abb5 100644 --- a/src/layout.c +++ b/src/layout.c @@ -192,6 +192,8 @@ ivi_layout_activate_complete(struct ivi_output *output, struct ivi_compositor *ivi = output->ivi; struct weston_output *woutput = output->output; struct weston_view *view = surf->view; + struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi); + struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat); if (weston_view_is_mapped(view)) { weston_layer_entry_remove(&view->layer_link); @@ -221,6 +223,9 @@ ivi_layout_activate_complete(struct ivi_output *output, weston_view_geometry_dirty(view); weston_surface_damage(view->surface); + if (ivi_seat) + ivi_shell_activate_surface(surf, ivi_seat, WESTON_ACTIVATE_FLAG_NONE); + /* * the 'remote' role now makes use of this part so make sure we don't * trip the enum such that we might end up with a modified output for @@ -408,6 +413,9 @@ ivi_layout_fullscreen_committed(struct ivi_surface *surface) struct weston_geometry geom = weston_desktop_surface_get_geometry(dsurface); + struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi); + struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat); + bool is_fullscreen = weston_desktop_surface_get_fullscreen(dsurface); bool is_dim_same = geom.width == bg_output->output->width && @@ -470,6 +478,9 @@ ivi_layout_fullscreen_committed(struct ivi_surface *surface) weston_view_geometry_dirty(view); weston_surface_damage(view->surface); + if (ivi_seat) + ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE); + shell_advertise_app_state(ivi, app_id, NULL, AGL_SHELL_DESKTOP_APP_STATE_ACTIVATED); @@ -516,6 +527,9 @@ ivi_layout_split_committed(struct ivi_surface *surface) struct ivi_output *output = surface->split.output; struct weston_output *woutput = output->output; + struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi); + struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat); + struct weston_view *view = surface->view; struct weston_geometry geom; @@ -586,6 +600,9 @@ ivi_layout_split_committed(struct ivi_surface *surface) weston_view_geometry_dirty(view); weston_surface_damage(view->surface); + if (ivi_seat) + ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE); + wsurface->is_mapped = true; surface->view->is_mapped = true; @@ -621,6 +638,9 @@ ivi_layout_popup_committed(struct ivi_surface *surface) struct ivi_output *output = surface->popup.output; struct weston_output *woutput = output->output; + struct weston_seat *wseat = get_ivi_shell_weston_first_seat(ivi); + struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat); + struct weston_view *view = surface->view; if (policy && policy->api.surface_activate_by_default && @@ -651,6 +671,9 @@ ivi_layout_popup_committed(struct ivi_surface *surface) weston_view_geometry_dirty(view); weston_surface_damage(view->surface); + if (ivi_seat) + ivi_shell_activate_surface(surface, ivi_seat, WESTON_ACTIVATE_FLAG_NONE); + wsurface->is_mapped = true; surface->view->is_mapped = true; -- cgit 1.2.3-korg