Commit 009177fa authored by Guido Gunther's avatar Guido Gunther Committed by Guido Gunther
Browse files

overview: Focus current activity



This allows to keyboard navigate on the home screen
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 9528dfe2
......@@ -52,6 +52,7 @@ typedef struct
/* Running activities */
GtkWidget *carousel_running_activities;
GtkWidget *app_grid;
GtkWidget *activity;
} PhoshOverviewPrivate;
......@@ -157,8 +158,10 @@ on_toplevel_activated_changed (PhoshToplevel *toplevel, GParamSpec *pspec, Phosh
priv = phosh_overview_get_instance_private (overview);
activity = find_activity_by_toplevel (overview, toplevel);
if (phosh_toplevel_is_activated (toplevel))
if (phosh_toplevel_is_activated (toplevel)) {
priv->activity = GTK_WIDGET (activity);
hdy_carousel_scroll_to (HDY_CAROUSEL (priv->carousel_running_activities), GTK_WIDGET (activity));
}
}
......@@ -194,6 +197,20 @@ on_activity_size_allocated (PhoshActivity *activity, GtkAllocation *alloc, Phosh
}
static void
on_activity_has_focus_changed (PhoshOverview *self, GParamSpec *pspec, PhoshActivity *activity)
{
PhoshOverviewPrivate *priv;
g_return_if_fail (PHOSH_IS_ACTIVITY (activity));
g_return_if_fail (PHOSH_IS_OVERVIEW (self));
priv = phosh_overview_get_instance_private (self);
if (gtk_widget_has_focus (GTK_WIDGET (activity)))
hdy_carousel_scroll_to (HDY_CAROUSEL (priv->carousel_running_activities), GTK_WIDGET (activity));
}
static void
add_activity (PhoshOverview *self, PhoshToplevel *toplevel)
{
......@@ -229,11 +246,14 @@ add_activity (PhoshOverview *self, PhoshToplevel *toplevel)
g_object_bind_property (toplevel, "maximized", activity, "maximized", G_BINDING_DEFAULT);
g_signal_connect (activity, "size-allocate", G_CALLBACK (on_activity_size_allocated), toplevel);
g_signal_connect_swapped (activity, "notify::has-focus", G_CALLBACK (on_activity_has_focus_changed), self);
phosh_connect_button_feedback (GTK_BUTTON (activity));
if (phosh_toplevel_is_activated (toplevel))
if (phosh_toplevel_is_activated (toplevel)) {
hdy_carousel_scroll_to (HDY_CAROUSEL (priv->carousel_running_activities), activity);
priv->activity = GTK_WIDGET (activity);
}
}
......@@ -422,6 +442,9 @@ phosh_overview_reset (PhoshOverview *self)
g_return_if_fail(PHOSH_IS_OVERVIEW (self));
priv = phosh_overview_get_instance_private (self);
phosh_app_grid_reset (PHOSH_APP_GRID (priv->app_grid));
if (priv->activity)
gtk_widget_grab_focus (GTK_WIDGET (priv->activity));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment