mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-16 21:50:34 +00:00
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.
This commit is contained in:
parent
b7a8bde895
commit
2e4018c386
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user