dateMenu: Do a better job at size freezing while browsing dates

In order to avoid distracting popup size changes while browsing
other dates, we freeze the size to the last size request. However
in case of more complex size negotiations - wrapping or ellipsizing
labels, scrollable elements etc. - there's a chance of stray calls
to get_preferred_width/height() that are not used for the actual
allocation. If such a call happens to be the last size request
before the layout is frozen, the saved size will be wrong. To fix
this, save the allocated size rather than the requested one.

https://bugzilla.gnome.org/show_bug.cgi?id=754031
This commit is contained in:
Florian Müllner 2017-02-26 14:37:51 +01:00
parent 796fdca5c5
commit 4b166dcc79

View File

@ -279,14 +279,22 @@ const FreezableBinLayout = new Lang.Class({
vfunc_get_preferred_width: function(container, forHeight) {
if (!this._frozen || this._savedWidth.some(isNaN))
this._savedWidth = this.parent(container, forHeight);
return this.parent(container, forHeight);
return this._savedWidth;
},
vfunc_get_preferred_height: function(container, forWidth) {
if (!this._frozen || this._savedHeight.some(isNaN))
this._savedHeight = this.parent(container, forWidth);
return this.parent(container, forWidth);
return this._savedHeight;
},
vfunc_allocate: function(container, allocation, flags) {
this.parent(container, allocation, flags);
let [width, height] = allocation.get_size();
this._savedWidth = [width, width];
this._savedHeight = [height, height];
}
});