widget: Don't grab focus when can-focus == false

... inside the default vfunc.

Instead, walk the children until we find the first widget that can be
focused. If no child can be focused, return FALSE from grab_focus.
This commit is contained in:
Benjamin Otte 2019-10-15 16:30:46 +02:00
parent 9c1b1eb894
commit 4eb077979f

View File

@ -5436,9 +5436,23 @@ static gboolean
gtk_widget_real_grab_focus (GtkWidget *focus_widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (focus_widget);
GtkWidget *child;
gtk_root_set_focus (priv->root, focus_widget);
return TRUE;
if (priv->can_focus)
{
gtk_root_set_focus (priv->root, focus_widget);
return TRUE;
}
for (child = _gtk_widget_get_first_child (focus_widget);
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
if (gtk_widget_grab_focus (child))
return TRUE;
}
return FALSE;
}
static gboolean