Skip to content

Commit

Permalink
widget: No longer postpone style-updated on unrealized widgets
Browse files Browse the repository at this point in the history
GTK used to not emit GtkWidget::style-updated on widgets that weren't
realized. This sped up construction of complex widgetry in the early
days of GTK3 where we instantly invalidated on every change.
We don't do that anymore, so in theory (and in my limited testing with
widget-factory) this shouldn't be a prolem anymore.

What is a problem though is that postponing style-updated leads to 2
problems:
(1) Unrealized widgets will not emit style-updated which may cause them
    to not properly update their state and return wrong values from
    get_preferred_width/height() etc
(2) Emitting style-updated during realize can happen too late.
    When a widget is not made child-visible by its parent (common
    examples: notebook, paned) it will also not be realized when the
    parent is initially shown. However, when they get realized later
    (after a resize of the parent), they will emit style-updated (and
    potentially queue a resize) during size-allocate.

https://bugzilla.gnome.org/show_bug.cgi?id=765700
  • Loading branch information
Benjamin Otte committed May 14, 2016
1 parent 30d2dc4 commit ddcf470
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
13 changes: 1 addition & 12 deletions gtk/gtkwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -5443,9 +5443,6 @@ gtk_widget_realize (GtkWidget *widget)
gtk_widget_ensure_style (widget);
G_GNUC_END_IGNORE_DEPRECATIONS

if (priv->style_update_pending)
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);

g_signal_emit (widget, widget_signals[REALIZE], 0);

gtk_widget_real_set_has_tooltip (widget, gtk_widget_get_has_tooltip (widget), TRUE);
Expand Down Expand Up @@ -16495,15 +16492,7 @@ gtk_widget_class_get_css_name (GtkWidgetClass *widget_class)
void
_gtk_widget_style_context_invalidated (GtkWidget *widget)
{
if (_gtk_widget_get_realized (widget))
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
else
{
/* Compress all style updates so it
* is only emitted once pre-realize.
*/
widget->priv->style_update_pending = TRUE;
}
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
}

GtkCssNode *
Expand Down
1 change: 0 additions & 1 deletion gtk/gtkwidgetprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct _GtkWidgetPrivate
guint receives_default : 1;
guint has_grab : 1;
guint shadowed : 1;
guint style_update_pending : 1;
guint app_paintable : 1;
guint double_buffered : 1;
guint redraw_on_alloc : 1;
Expand Down

0 comments on commit ddcf470

Please sign in to comment.