forked from AuroraMiddleware/gtk
widget: Allow focusing widgets with non-container parent
Especially if said parent also has can-focus set to FALSE, which is a special-case we had before for GtkContainer instances.
This commit is contained in:
parent
0b48bb23b2
commit
0153147ca2
@ -7159,8 +7159,6 @@ reset_focus_recurse (GtkWidget *widget,
|
||||
static void
|
||||
gtk_widget_real_grab_focus (GtkWidget *focus_widget)
|
||||
{
|
||||
if (gtk_widget_get_can_focus (focus_widget))
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
GtkWidget *widget;
|
||||
|
||||
@ -7223,7 +7221,6 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
|
||||
}
|
||||
if (GTK_IS_WINDOW (widget))
|
||||
_gtk_window_internal_set_focus (GTK_WINDOW (widget), focus_widget);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -7314,7 +7311,35 @@ gtk_widget_real_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
if (!gtk_widget_get_can_focus (widget))
|
||||
{
|
||||
/* @widget can't be focused, but maybe one of its child widgets. */
|
||||
GtkWidget *focus_child = gtk_widget_get_focus_child (widget);
|
||||
GtkWidget *child;
|
||||
|
||||
for (child = _gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = _gtk_widget_get_next_sibling (child))
|
||||
{
|
||||
if (focus_child)
|
||||
{
|
||||
if (focus_child == child)
|
||||
{
|
||||
focus_child = NULL;
|
||||
|
||||
if (gtk_widget_child_focus (child, direction))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (_gtk_widget_is_drawable (child) &&
|
||||
gtk_widget_is_ancestor (child, widget))
|
||||
{
|
||||
if (gtk_widget_child_focus (child, direction))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gtk_widget_is_focus (widget))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user