[gtk/otte/for-master: 3/4] widget: Insist that widgets are rooted to be focusable



commit 9c1b1eb89474cd868df99b6967e828882d79e9db
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 15 16:11:03 2019 +0200

    widget: Insist that widgets are rooted to be focusable
    
    This check was in the vfunc before, but it's a general rule, so apply it
    before.

 gtk/gtkwidget.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 592754c267..c3e0e288d2 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5425,7 +5425,8 @@ gtk_widget_grab_focus (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
-  if (!gtk_widget_is_sensitive (widget))
+  if (!gtk_widget_is_sensitive (widget) ||
+      widget->priv->root == NULL)
     return FALSE;
 
   return GTK_WIDGET_GET_CLASS (widget)->grab_focus (widget);
@@ -5436,9 +5437,6 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
 {
   GtkWidgetPrivate *priv = gtk_widget_get_instance_private (focus_widget);
 
-  if (!priv->root)
-    return FALSE;
-
   gtk_root_set_focus (priv->root, focus_widget);
   return TRUE;
 }


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