From 48dad8939717c3bbb932694c548970f5437c92c9 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Mon, 25 Jul 2022 09:17:53 +0200 Subject: [PATCH 1/2] overview: Focus the activity on carousel page change Without this, we may end up scrolling back to some previously focused activity on carousel focus if the active activity has changed while the carousel wasn't focused. Part-of: --- src/overview.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/overview.c b/src/overview.c index d89f9c0fc..e95d0cc23 100644 --- a/src/overview.c +++ b/src/overview.c @@ -430,6 +430,7 @@ page_changed_cb (PhoshOverview *self, activity = PHOSH_ACTIVITY (g_list_nth_data (list, index)); toplevel = get_toplevel_from_activity (activity); phosh_toplevel_activate (toplevel, phosh_wayland_get_wl_seat (phosh_wayland_get_default ())); + gtk_widget_grab_focus (GTK_WIDGET (activity)); } -- GitLab From dcb3ed8ac1191ff2870d8f02cf1c3a8e944a0646 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Tue, 26 Jul 2022 06:18:28 +0200 Subject: [PATCH 2/2] overview: Focus the activity right away when scrolling to it This fixes the same issue as the previous commit, but in cases where scrolling has been invoked programmatically by phosh and the animation hasn't finished before PhoshHome gained focus. Part-of: --- src/overview.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/overview.c b/src/overview.c index e95d0cc23..9f217e7e4 100644 --- a/src/overview.c +++ b/src/overview.c @@ -129,6 +129,14 @@ find_activity_by_toplevel (PhoshOverview *self, } +static void +scroll_to_activity (PhoshOverview *self, PhoshActivity *activity) +{ + PhoshOverviewPrivate *priv = phosh_overview_get_instance_private (self); + hdy_carousel_scroll_to (HDY_CAROUSEL (priv->carousel_running_activities), GTK_WIDGET (activity)); + gtk_widget_grab_focus (GTK_WIDGET (activity)); +} + static void on_activity_clicked (PhoshOverview *self, PhoshActivity *activity) { @@ -200,7 +208,7 @@ on_toplevel_activated_changed (PhoshToplevel *toplevel, GParamSpec *pspec, Phosh if (phosh_toplevel_is_activated (toplevel)) { activity = find_activity_by_toplevel (overview, toplevel); priv->activity = activity; - hdy_carousel_scroll_to (HDY_CAROUSEL (priv->carousel_running_activities), GTK_WIDGET (activity)); + scroll_to_activity (overview, activity); } } @@ -294,7 +302,7 @@ add_activity (PhoshOverview *self, PhoshToplevel *toplevel) phosh_connect_feedback (activity); if (phosh_toplevel_is_activated (toplevel)) { - hdy_carousel_scroll_to (HDY_CAROUSEL (priv->carousel_running_activities), activity); + scroll_to_activity (self, PHOSH_ACTIVITY (activity)); priv->activity = PHOSH_ACTIVITY (activity); } } -- GitLab