From 51a1bc21af92d866a96c15b538d34708f8c91045 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 12 Sep 2015 21:27:10 +0200 Subject: [PATCH] Revert "Avoid type checking overhead for resize-mode" This reverts commit 3eacfa88f2d9c690a006de9cac1cd3c60901686c. Apart from the patch not being correct, we don't want to expose private structures in header files if we can avoid it. And this type-checking overhead is not an optimization that is even measurable. https://bugzilla.gnome.org/show_bug.cgi?id=754932 --- gtk/gtkcontainer.c | 25 ++++++++++++++++++++++--- gtk/gtkcontainerprivate.h | 28 ---------------------------- gtk/gtkcsswidgetnode.c | 4 ++-- gtk/gtkwidget.c | 2 ++ gtk/gtkwindow.c | 4 ++-- 5 files changed, 28 insertions(+), 35 deletions(-) diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 4bc8e84ce7..16337b59b9 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -251,6 +251,25 @@ * */ + +struct _GtkContainerPrivate +{ + GtkWidget *focus_child; + + GdkFrameClock *resize_clock; + guint resize_handler; + + guint border_width : 16; + guint border_width_set : 1; + + guint has_focus_chain : 1; + guint reallocate_redraws : 1; + guint resize_pending : 1; + guint restyle_pending : 1; + guint resize_mode : 2; + guint request_mode : 2; +}; + enum { ADD, REMOVE, @@ -2052,7 +2071,7 @@ gtk_container_queue_resize_handler (GtkContainer *container) GtkWidget *widget; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - g_return_if_fail (_GTK_IS_RESIZE_CONTAINER (container)); + g_return_if_fail (GTK_IS_RESIZE_CONTAINER (container)); G_GNUC_END_IGNORE_DEPRECATIONS; widget = GTK_WIDGET (container); @@ -2097,7 +2116,7 @@ _gtk_container_queue_resize_internal (GtkContainer *container, _gtk_size_request_cache_clear (_gtk_widget_peek_request_cache (widget)); G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (_GTK_IS_RESIZE_CONTAINER (container)) + if (((GtkContainer*)widget)->priv->resize_mode != GTK_RESIZE_PARENT) break; G_GNUC_END_IGNORE_DEPRECATIONS; @@ -2185,7 +2204,7 @@ gtk_container_real_check_resize (GtkContainer *container) requisition.height > allocation.height) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (_GTK_IS_RESIZE_CONTAINER (container)) + if (GTK_IS_RESIZE_CONTAINER (container)) { gtk_widget_size_allocate (widget, &allocation); gtk_widget_set_allocation (widget, &allocation); diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h index fa524815ae..ec817202a9 100644 --- a/gtk/gtkcontainerprivate.h +++ b/gtk/gtkcontainerprivate.h @@ -24,24 +24,6 @@ G_BEGIN_DECLS -struct _GtkContainerPrivate -{ - GtkWidget *focus_child; - - GdkFrameClock *resize_clock; - guint resize_handler; - - guint border_width : 16; - guint border_width_set : 1; - - guint has_focus_chain : 1; - guint reallocate_redraws : 1; - guint resize_pending : 1; - guint restyle_pending : 1; - guint resize_mode : 2; - guint request_mode : 2; -}; - void _gtk_container_queue_resize (GtkContainer *container); void _gtk_container_queue_restyle (GtkContainer *container); @@ -62,16 +44,6 @@ gboolean _gtk_container_get_border_width_set (GtkContainer *container); void _gtk_container_set_border_width_set (GtkContainer *container, gboolean border_width_set); -static inline GtkResizeMode _gtk_container_get_resize_mode (GtkContainer *container); - -static inline GtkResizeMode -_gtk_container_get_resize_mode (GtkContainer *container) -{ - return container->priv->resize_mode; -} - -#define _GTK_IS_RESIZE_CONTAINER(container) (_gtk_container_get_resize_mode (GTK_CONTAINER (container)) != GTK_RESIZE_PARENT) - G_END_DECLS #endif /* __GTK_CONTAINER_PRIVATE_H__ */ diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c index e9d2056be4..cf68fb4e59 100644 --- a/gtk/gtkcsswidgetnode.c +++ b/gtk/gtkcsswidgetnode.c @@ -101,7 +101,7 @@ gtk_css_widget_node_queue_validate (GtkCssNode *node) GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); G_GNUC_BEGIN_IGNORE_DEPRECATIONS - if (_GTK_IS_RESIZE_CONTAINER (widget_node->widget)) + if (GTK_IS_RESIZE_CONTAINER (widget_node->widget)) widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget, gtk_css_widget_node_queue_callback, node, @@ -115,7 +115,7 @@ gtk_css_widget_node_dequeue_validate (GtkCssNode *node) GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); G_GNUC_BEGIN_IGNORE_DEPRECATIONS - if (_GTK_IS_RESIZE_CONTAINER (widget_node->widget)) + if (GTK_IS_RESIZE_CONTAINER (widget_node->widget)) gtk_widget_remove_tick_callback (widget_node->widget, widget_node->validate_cb_id); G_GNUC_END_IGNORE_DEPRECATIONS diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4cb285c854..4d714b2544 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -17223,6 +17223,8 @@ _gtk_widget_add_controller (GtkWidget *widget, EventControllerData *data; GtkWidgetPrivate *priv; + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller)); g_return_if_fail (widget == gtk_event_controller_get_widget (controller)); priv = widget->priv; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 55ad1ff8d3..b693f94363 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -9444,7 +9444,7 @@ gtk_window_move_resize (GtkWindow *window) gtk_widget_size_allocate (widget, &allocation); G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (_gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE) + if (gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE) gtk_widget_queue_draw (widget); G_GNUC_END_IGNORE_DEPRECATIONS; } @@ -9471,7 +9471,7 @@ gtk_window_move_resize (GtkWindow *window) * we handle those ourselves upon ->configure_notify_received==TRUE. */ G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (_gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE) + if (gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE) { gtk_widget_queue_resize_no_redraw (widget); _gtk_container_dequeue_resize_handler (container);