summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-10-06 02:14:54 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-10-06 02:14:54 +0000
commitb6d40677174565ba84d744113177acccc9de5b29 (patch)
tree6138481a368630b89d26714e5293888fcb640fe8
parent7f5deed2eba41ec90e2aa8c9c3db016ec9ae62f3 (diff)
parentac164d240b0dcd37b84207094f00606cb1c353ac (diff)
downloadgtk+-b6d40677174565ba84d744113177acccc9de5b29.tar.gz
Merge branch 'wip/carlosg/for-master' into 'master'
gtkpopover: Revert focus to parent on hide() Closes #3214 See merge request GNOME/gtk!2653
-rw-r--r--gtk/gtkwindow.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7377502371..52e74e82be 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5206,55 +5206,52 @@ gtk_window_css_changed (GtkWidget *widget,
}
}
-/**
+/*
* _gtk_window_unset_focus_and_default:
* @window: a #GtkWindow
* @widget: a widget inside of @window
- *
+ *
* Checks whether the focus and default widgets of @window are
* @widget or a descendent of @widget, and if so, unset them.
- **/
+ */
void
_gtk_window_unset_focus_and_default (GtkWindow *window,
- GtkWidget *widget)
+ GtkWidget *widget)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *child;
GtkWidget *parent;
+ GtkWidget *focus;
g_object_ref (window);
g_object_ref (widget);
- parent = _gtk_widget_get_parent (widget);
- if (gtk_widget_get_focus_child (parent) == widget)
+ focus = priv->focus_widget;
+ if (focus && (focus == widget || gtk_widget_is_ancestor (focus, widget)))
{
- child = priv->focus_widget;
-
- while (child && child != widget)
- child = _gtk_widget_get_parent (child);
+ parent = _gtk_widget_get_parent (widget);
- if (child == widget)
+ while (parent)
{
- GtkWidget *new_focus;
-
- if (GTK_IS_NATIVE (widget))
- new_focus = gtk_widget_get_parent (widget);
- else
- new_focus = NULL;
+ if (_gtk_widget_get_visible (parent))
+ {
+ gtk_window_set_focus (window, parent);
+ break;
+ }
- gtk_window_set_focus (GTK_WINDOW (window), new_focus);
+ parent = gtk_widget_get_parent (parent);
}
}
-
+
child = priv->default_widget;
-
+
while (child && child != widget)
child = _gtk_widget_get_parent (child);
if (child == widget)
gtk_window_set_default_widget (window, NULL);
-
+
g_object_unref (widget);
g_object_unref (window);
}