From 3cb150abbe81e789eabff1b35942b4ad8af98967 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 4 Feb 2020 17:31:18 +0100 Subject: [PATCH] widget: Remove _gtk_widget_is_drawable() Use _gtk_widget_get_mapped() instead. Drawable checked visible && mapped and mapped widgets are always visible, so that was an unnecessary check. --- gtk/gtkwidget.c | 10 +++++----- gtk/gtkwidgetfocus.c | 4 ++-- gtk/gtkwidgetprivate.h | 6 ------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 5f47c384e4..62d15c6d2d 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2587,7 +2587,7 @@ gtk_widget_unparent (GtkWidget *widget) if (gtk_widget_get_focus_child (priv->parent) == widget) gtk_widget_set_focus_child (priv->parent, NULL); - if (_gtk_widget_is_drawable (priv->parent)) + if (_gtk_widget_get_mapped (priv->parent)) gtk_widget_queue_draw (priv->parent); if (priv->visible && _gtk_widget_get_visible (priv->parent)) @@ -4372,7 +4372,7 @@ gtk_widget_real_can_activate_accel (GtkWidget *widget, /* widgets must be onscreen for accels to take effect */ return gtk_widget_is_sensitive (widget) && - _gtk_widget_is_drawable (widget) && + _gtk_widget_get_mapped (widget) && gdk_surface_is_viewable (priv->surface); } @@ -10424,7 +10424,7 @@ gtk_widget_contains (GtkWidget *widget, { g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - if (!_gtk_widget_is_drawable (widget)) + if (!_gtk_widget_get_mapped (widget)) return FALSE; return GTK_WIDGET_GET_CLASS (widget)->contains (widget, x, y); @@ -10435,7 +10435,7 @@ static gboolean gtk_widget_can_be_picked (GtkWidget *widget, GtkPickFlags flags) { - if (!_gtk_widget_is_drawable (widget)) + if (!_gtk_widget_get_mapped (widget)) return FALSE; if (!(flags & GTK_PICK_NON_TARGETABLE) && @@ -12205,7 +12205,7 @@ gtk_widget_snapshot (GtkWidget *widget, { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - if (!_gtk_widget_is_drawable (widget)) + if (!_gtk_widget_get_mapped (widget)) return; if (_gtk_widget_get_alloc_needed (widget)) diff --git a/gtk/gtkwidgetfocus.c b/gtk/gtkwidgetfocus.c index a8da390adc..921b72527d 100644 --- a/gtk/gtkwidgetfocus.c +++ b/gtk/gtkwidgetfocus.c @@ -424,7 +424,7 @@ gtk_widget_focus_sort (GtkWidget *widget, child = _gtk_widget_get_next_sibling (child)) { if (_gtk_widget_get_realized (child) && - _gtk_widget_is_drawable (child) && + _gtk_widget_get_mapped (child) && gtk_widget_get_sensitive (child)) g_ptr_array_add (focus_order, child); } @@ -475,7 +475,7 @@ gtk_widget_focus_move (GtkWidget *widget, ret = gtk_widget_child_focus (child, direction); } } - else if (_gtk_widget_is_drawable (child) && + else if (_gtk_widget_get_mapped (child) && gtk_widget_is_ancestor (child, widget)) { ret = gtk_widget_child_focus (child, direction); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 415b75e7f5..72fb1df993 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -381,12 +381,6 @@ _gtk_widget_get_mapped (GtkWidget *widget) return widget->priv->mapped; } -static inline gboolean -_gtk_widget_is_drawable (GtkWidget *widget) -{ - return widget->priv->visible && widget->priv->mapped; -} - static inline gboolean _gtk_widget_get_realized (GtkWidget *widget) {