[gtk+] gtkwindow: Clean up the code for an optimization
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtkwindow: Clean up the code for an optimization
- Date: Tue, 15 Jul 2014 18:49:30 +0000 (UTC)
commit 2e4018c3867f089f305d3b4f19d9f60486cb9ebb
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Jul 15 14:42:36 2014 -0400
gtkwindow: Clean up the code for an optimization
It's hard to figure out what the "expected_reply" means except under
close examination -- it's actually talking about whether this was a
reply to a ConfigureRequest or not. The inversion in the check doesn't
help either.
Make the code cleaner by moving it above the freeze/thaw case, and
making the check more explicit and without a confusing variable. If we
haven't sent any ConfigureRequests out, then it must be a gratuitous
ConfigureNotify.
gtk/gtkwindow.c | 33 ++++++++++++++++-----------------
1 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 76608d3..c3ae869 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -7131,13 +7131,28 @@ gtk_window_configure_event (GtkWidget *widget,
GtkAllocation allocation;
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
- gboolean expected_reply = priv->configure_request_count > 0;
check_scale_changed (window);
if (!gtk_widget_is_toplevel (widget))
return FALSE;
+ /* If this is a gratuitous ConfigureNotify that's already
+ * the same as our allocation, then we can fizzle it out.
+ * This is the case for dragging windows around.
+ *
+ * We can't do this for a ConfigureRequest, since it might
+ * have been a queued resize from child widgets, and so we
+ * need to reallocate our children in case *they* changed.
+ */
+ gtk_widget_get_allocation (widget, &allocation);
+ if (priv->configure_request_count == 0 &&
+ (allocation.width == event->width &&
+ allocation.height == event->height))
+ {
+ return TRUE;
+ }
+
/* priv->configure_request_count incremented for each
* configure request, and decremented to a min of 0 for
* each configure notify.
@@ -7156,22 +7171,6 @@ gtk_window_configure_event (GtkWidget *widget,
gdk_window_thaw_toplevel_updates_libgtk_only (gtk_widget_get_window (widget));
}
- /* If this is a gratuitous ConfigureNotify that's already
- * the same as our allocation, then we can fizzle it out.
- * This is the case for dragging windows around.
- *
- * We can't do this for a ConfigureRequest, since it might
- * have been a queued resize from child widgets, and so we
- * need to reallocate our children in case *they* changed.
- */
- gtk_widget_get_allocation (widget, &allocation);
- if (!expected_reply &&
- (allocation.width == event->width &&
- allocation.height == event->height))
- {
- return TRUE;
- }
-
/*
* If we do need to resize, we do that by:
* - setting configure_notify_received to TRUE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]