[gtk/wip/matthiasc/can-focus: 29/31] Move focus to the parent if a popover is dismissed



commit 72ae6daa1e4481210d11e63823271cfc87d8e385
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Apr 9 12:03:23 2020 -0400

    Move focus to the parent if a popover is dismissed
    
    This is better than just dropping focus altogether,
    and is expected behavior in most cases.

 gtk/gtkwindow.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7e211aaa0f..707bd84b98 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5740,7 +5740,16 @@ _gtk_window_unset_focus_and_default (GtkWindow *window,
         child = _gtk_widget_get_parent (child);
 
       if (child == widget)
-       gtk_window_set_focus (GTK_WINDOW (window), NULL);
+        {
+          GtkWidget *new_focus;
+
+          if (GTK_IS_NATIVE (widget))
+            new_focus = gtk_widget_get_parent (widget);
+          else
+            new_focus = NULL;
+
+         gtk_window_set_focus (GTK_WINDOW (window), new_focus);
+        }
     }
       
   child = priv->default_widget;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]