[gtk/wip/carlosg/for-master: 20/20] gtkpopover: Revert focus to parent on hide()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/for-master: 20/20] gtkpopover: Revert focus to parent on hide()
- Date: Fri, 2 Oct 2020 00:07:02 +0000 (UTC)
commit a41d072660dcd015a5bad7205b999514ec4a0092
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Oct 1 16:54:10 2020 +0200
gtkpopover: Revert focus to parent on hide()
When a popover hides while containing the keyboard focus, the
keyboard focus doesn't move outside the GtkPopover. This is widget
that is not interested in preserving focus nor forwarding to
hidden children, so give the focus back to the parent widget
when the popover hides.
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3214
gtk/gtkpopover.c | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index fd3567d8e2..5fa89eb872 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -957,10 +957,15 @@ gtk_popover_hide (GtkWidget *widget)
{
GtkPopover *popover = GTK_POPOVER (widget);
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
+ GtkRoot *root = gtk_widget_get_root (widget);
+ GtkWidget *focus = gtk_root_get_focus (root);
if (priv->autohide)
gtk_grab_remove (widget);
+ if (focus && (focus == widget || gtk_widget_is_ancestor (focus, widget)))
+ gtk_widget_grab_focus (gtk_widget_get_parent (GTK_WIDGET (popover)));
+
gtk_popover_set_mnemonics_visible (GTK_POPOVER (widget), FALSE);
_gtk_widget_set_visible_flag (widget, FALSE);
gtk_widget_unmap (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]