[gtk/wip/matthiasc/can-focus: 6/16] window: Make set_focus equal to grab_focus



commit 0593295b55e2be510a9e4f7c556b7b22bbc1c41b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 29 15:26:56 2020 -0400

    window: Make set_focus equal to grab_focus
    
    Make gtk_window_set_focus call gtk_widget_grab_focus internally.
    This means that set_focus can now end up putting the focus on
    a child of the passed-in widget, and makes the focus-widget
    property work for setting initial focus to (the child of) an
    entry in a ui file.

 gtk/gtkwindow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 60e427e4c6..e1d7acb55d 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5667,7 +5667,10 @@ gtk_window_set_focus (GtkWindow *window,
 {
   g_return_if_fail (GTK_IS_WINDOW (window));
 
-  gtk_root_set_focus (GTK_ROOT (window), focus);
+  if (focus)
+    gtk_widget_grab_focus (focus);
+  else
+    gtk_window_root_set_focus (GTK_ROOT (window), NULL);
 }
 
 static void


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