Commit 53262cf7 authored by Benjamin Otte's avatar Benjamin Otte

sizerequest: Optimize CONSTANT_SIZE better

We can set for_size to -1 earlier than we did. Doing so makes sure we
only cache one value (as we should in the first place). In GTK 3.6, this
worked properly, but with Previously, this check was moved further up to
avoid interacting with size groups. But after recent refactorings, size
groups are handled way earlier anyway.
parent 6d3b4d93
...@@ -105,6 +105,9 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget, ...@@ -105,6 +105,9 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
gint nat_size = 0; gint nat_size = 0;
gboolean found_in_cache; gboolean found_in_cache;
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
for_size = -1;
cache = _gtk_widget_peek_request_cache (widget); cache = _gtk_widget_peek_request_cache (widget);
found_in_cache = _gtk_size_request_cache_lookup (cache, found_in_cache = _gtk_size_request_cache_lookup (cache,
orientation, orientation,
...@@ -120,7 +123,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget, ...@@ -120,7 +123,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ {
if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE) if (for_size < 0)
{ {
push_recursion_check (widget, orientation, for_size); push_recursion_check (widget, orientation, for_size);
GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_size, &nat_size); GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_size, &nat_size);
...@@ -153,7 +156,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget, ...@@ -153,7 +156,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
} }
else else
{ {
if (for_size < 0 || gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE) if (for_size < 0)
{ {
push_recursion_check (widget, orientation, for_size); push_recursion_check (widget, orientation, for_size);
GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_size, &nat_size); GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_size, &nat_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment