[gtk+] Fix hiding popover when focus moves outside
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Fix hiding popover when focus moves outside
- Date: Mon, 6 Jun 2016 02:54:13 +0000 (UTC)
commit 72ea348ad624c184aed437704e5a31e5eefb16cc
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Mon Apr 25 13:16:21 2016 +0100
Fix hiding popover when focus moves outside
Commit a01fe14 changed the behaviour of popovers when the focus leaves
them to stop child popovers being hidden when the focus leaves their
parent. However they are now a bit too reluctant to hide - if the
focus passes to an unrelated popover the first popover is not
hidden. Also if the focus passes to another widget that does not
perform a gtk grab then the popover isn't hidden until the user
presses a non-movement key or clicks outside the popover.
The solution is to go back to checking if the focused widget is a
descendant of the popover, but to include popovers and their related
widgets in the ancestry chain.
https://bugzilla.gnome.org/show_bug.cgi?id=765595
gtk/gtkpopover.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 9c19fbb..8d170dd 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -439,17 +439,23 @@ window_set_focus (GtkWindow *window,
{
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
- if (priv->modal && widget &&
- gtk_widget_is_drawable (GTK_WIDGET (popover)) &&
- !gtk_widget_is_ancestor (widget, GTK_WIDGET (popover)))
- {
- GtkWidget *grab_widget;
+ if (!priv->modal || !widget || !gtk_widget_is_drawable (GTK_WIDGET (popover)))
+ return;
- grab_widget = gtk_grab_get_current ();
+ widget = gtk_widget_get_ancestor (widget, GTK_TYPE_POPOVER);
+ while (widget != NULL)
+ {
+ if (widget == GTK_WIDGET (popover))
+ return;
- if (!grab_widget || !GTK_IS_POPOVER (grab_widget))
- gtk_widget_hide (GTK_WIDGET (popover));
+ widget = gtk_popover_get_relative_to (GTK_POPOVER (widget));
+ if (widget == NULL)
+ break;
+ widget = gtk_widget_get_ancestor (widget, GTK_TYPE_POPOVER);
}
+
+ popover_unset_prev_focus (popover);
+ gtk_widget_hide (GTK_WIDGET (popover));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]