St: don't focus hidden actors

If an actors is not mapped (visible and all parents visible), then don't
allow navigating focus to it.
This fixes a regression in the keyboard navigation of the panel with
invisibile items.

https://bugzilla.gnome.org/show_bug.cgi?id=683529
This commit is contained in:
Giovanni Campagna 2012-09-06 22:12:44 +02:00
parent 452ac297ab
commit 09e3aed770
4 changed files with 32 additions and 20 deletions

View File

@ -155,9 +155,16 @@ shell_stack_navigate_focus (StWidget *widget,
if (from && clutter_actor_contains (CLUTTER_ACTOR (widget), from)) if (from && clutter_actor_contains (CLUTTER_ACTOR (widget), from))
return FALSE; return FALSE;
if (CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (widget)))
{
clutter_actor_grab_key_focus (CLUTTER_ACTOR (widget)); clutter_actor_grab_key_focus (CLUTTER_ACTOR (widget));
return TRUE; return TRUE;
} }
else
{
return FALSE;
}
}
top_actor = clutter_actor_get_last_child (CLUTTER_ACTOR (widget)); top_actor = clutter_actor_get_last_child (CLUTTER_ACTOR (widget));
if (ST_IS_WIDGET (top_actor)) if (ST_IS_WIDGET (top_actor))

View File

@ -200,9 +200,16 @@ st_bin_navigate_focus (StWidget *widget,
if (from && clutter_actor_contains (bin_actor, from)) if (from && clutter_actor_contains (bin_actor, from))
return FALSE; return FALSE;
if (CLUTTER_ACTOR_IS_MAPPED (bin_actor))
{
clutter_actor_grab_key_focus (bin_actor); clutter_actor_grab_key_focus (bin_actor);
return TRUE; return TRUE;
} }
else
{
return FALSE;
}
}
else if (priv->child && ST_IS_WIDGET (priv->child)) else if (priv->child && ST_IS_WIDGET (priv->child))
return st_widget_navigate_focus (ST_WIDGET (priv->child), from, direction, FALSE); return st_widget_navigate_focus (ST_WIDGET (priv->child), from, direction, FALSE);
else else

View File

@ -284,7 +284,8 @@ st_entry_navigate_focus (StWidget *widget,
if (from == priv->entry) if (from == priv->entry)
return FALSE; return FALSE;
else if (st_widget_get_can_focus (widget)) else if (st_widget_get_can_focus (widget) &&
CLUTTER_ACTOR_IS_MAPPED (priv->entry))
{ {
clutter_actor_grab_key_focus (priv->entry); clutter_actor_grab_key_focus (priv->entry);
return TRUE; return TRUE;

View File

@ -763,18 +763,7 @@ st_widget_get_paint_volume (ClutterActor *self,
static GList * static GList *
st_widget_real_get_focus_chain (StWidget *widget) st_widget_real_get_focus_chain (StWidget *widget)
{ {
ClutterActorIter iter; return clutter_actor_get_children (CLUTTER_ACTOR (widget));
ClutterActor *child;
GList *focus_chain = NULL;
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (widget));
while (clutter_actor_iter_next (&iter, &child))
{
if (CLUTTER_ACTOR_IS_VISIBLE (child))
focus_chain = g_list_prepend (focus_chain, child);
}
return g_list_reverse (focus_chain);
} }
@ -1897,11 +1886,19 @@ st_widget_real_navigate_focus (StWidget *widget,
if (widget->priv->can_focus) if (widget->priv->can_focus)
{ {
if (!focus_child) if (!focus_child)
{
if (CLUTTER_ACTOR_IS_MAPPED (widget_actor))
{ {
/* Accept focus from outside */ /* Accept focus from outside */
clutter_actor_grab_key_focus (widget_actor); clutter_actor_grab_key_focus (widget_actor);
return TRUE; return TRUE;
} }
else
{
/* Refuse to set focus on hidden actors */
return FALSE;
}
}
else else
{ {
/* Yield focus from within: since @widget itself is /* Yield focus from within: since @widget itself is