diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2015-07-14 18:24:42 -0700 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2015-07-14 18:32:45 -0700 |
commit | 18dbe181fb13571ecbc76ce7f7f28c36c557a3d6 (patch) | |
tree | 2129fca10da0abae10ca8bbd6e6ec48ac29d3ad6 | |
parent | 2dda89cbd52e09cfbc24a9139caa7a65a5f73f2c (diff) | |
download | gtk+-18dbe181fb13571ecbc76ce7f7f28c36c557a3d6.tar.gz |
gtkframe: Don't queue a redraw on the entire widget every size allocate
Lots of applications often use GtkFrame as a giant toplevel container,
and that means that they get size allocated often. When frames get size
allocated, they invalidate their entire widget tree, even if they
haven't changed size or anything like that happens at all. This is
because the shadow / label needs to be redrawn if the child changes
size. We can optimize this out and only mark ourselves for a redraw if
the child has actually changed its size.
-rw-r--r-- | gtk/gtkframe.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 7c82e3ad6f..421b0515ff 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -706,6 +706,16 @@ gtk_frame_draw (GtkWidget *widget, return FALSE; } +static gboolean +rectangle_equal (const GdkRectangle *a, + const GdkRectangle *b) +{ + return a->x == b->x + && a->y == b->y + && a->width == b->width + && a->height == b->height; +} + static void gtk_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -719,11 +729,11 @@ gtk_frame_size_allocate (GtkWidget *widget, gtk_widget_set_allocation (widget, allocation); gtk_frame_compute_child_allocation (frame, &new_allocation); - + /* If the child allocation changed, that means that the frame is drawn * in a new place, so we must redraw the entire widget. */ - if (gtk_widget_get_mapped (widget)) + if (gtk_widget_get_mapped (widget) && !rectangle_equal (&priv->child_allocation, &new_allocation)) { gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE); } |