Move maintaining the focus chain

Put this code in the same place where we generate
the crossing events.
This commit is contained in:
Matthias Clasen 2019-03-08 13:52:46 -05:00
parent 7d354b5084
commit 888b92674f
2 changed files with 15 additions and 8 deletions

View File

@ -1458,6 +1458,21 @@ synth_crossing (GtkWidget *widget,
if (gdk_event_get_event_type (source) == GDK_FOCUS_CHANGE)
{
/* maintain focus chain */
if (enter || notify_type == GDK_NOTIFY_INFERIOR)
{
GtkWidget *parent = gtk_widget_get_parent (widget);
if (parent)
gtk_widget_set_focus_child (parent, widget);
}
else if (!enter && notify_type != GDK_NOTIFY_INFERIOR)
{
GtkWidget *parent = gtk_widget_get_parent (widget);
if (parent)
gtk_widget_set_focus_child (parent, NULL);
}
/* maintain widget state */
if (notify_type == GDK_NOTIFY_ANCESTOR ||
notify_type == GDK_NOTIFY_INFERIOR ||
notify_type == GDK_NOTIFY_NONLINEAR)

View File

@ -7168,7 +7168,6 @@ gtk_window_set_focus (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *old_focus = NULL;
GtkWidget *f;
GdkSeat *seat;
GdkDevice *device;
GdkEvent *event;
@ -7200,13 +7199,6 @@ gtk_window_set_focus (GtkWindow *window,
g_clear_object (&old_focus);
for (f = focus; f; f = gtk_widget_get_parent (f))
{
GtkWidget *parent = gtk_widget_get_parent (f);
if (parent)
gtk_widget_set_focus_child (parent, f);
}
g_object_notify (G_OBJECT (window), "focus-widget");
}