altTab: don't override icon size request

Instead of overriding the actor's request with the icon size, just set
the new icon size on the actors, and let the default handler take the
preferred size of children.

https://bugzilla.gnome.org/show_bug.cgi?id=705410
This commit is contained in:
Cosimo Cecchi 2014-02-15 19:45:28 -08:00
parent 407dc74502
commit ad97fc6855

View File

@ -430,7 +430,6 @@ const AppIcon = new Lang.Class({
set_size: function(size) { set_size: function(size) {
this.icon = this.app.create_icon_texture(size); this.icon = this.app.create_icon_texture(size);
this._iconBin.set_size(size, size);
this._iconBin.child = this.icon; this._iconBin.child = this.icon;
} }
}); });
@ -479,12 +478,13 @@ const AppSwitcher = new Lang.Class({
Mainloop.source_remove(this._mouseTimeOutId); Mainloop.source_remove(this._mouseTimeOutId);
}, },
_getPreferredHeight: function (actor, forWidth, alloc) { _setIconSize: function() {
let j = 0; let j = 0;
while(this._items.length > 1 && this._items[j].style_class != 'item-box') { while(this._items.length > 1 && this._items[j].style_class != 'item-box') {
j++; j++;
} }
let themeNode = this._items[j].get_theme_node(); let themeNode = this._items[j].get_theme_node();
let iconPadding = themeNode.get_horizontal_padding(); let iconPadding = themeNode.get_horizontal_padding();
let iconBorder = themeNode.get_border_width(St.Side.LEFT) + themeNode.get_border_width(St.Side.RIGHT); let iconBorder = themeNode.get_border_width(St.Side.LEFT) + themeNode.get_border_width(St.Side.RIGHT);
let [iconMinHeight, iconNaturalHeight] = this.icons[j].label.get_preferred_height(-1); let [iconMinHeight, iconNaturalHeight] = this.icons[j].label.get_preferred_height(-1);
@ -495,19 +495,17 @@ const AppSwitcher = new Lang.Class({
let primary = Main.layoutManager.primaryMonitor; let primary = Main.layoutManager.primaryMonitor;
let parentPadding = this.actor.get_parent().get_theme_node().get_horizontal_padding(); let parentPadding = this.actor.get_parent().get_theme_node().get_horizontal_padding();
let availWidth = primary.width - parentPadding - this.actor.get_theme_node().get_horizontal_padding(); let availWidth = primary.width - parentPadding - this.actor.get_theme_node().get_horizontal_padding();
let height = 0;
for(let i = 0; i < iconSizes.length; i++) {
this._iconSize = iconSizes[i];
height = iconSizes[i] + iconSpacing;
let w = height * this._items.length + totalSpacing;
if (w <= availWidth)
break;
}
if (this._items.length == 1) { if (this._items.length == 1) {
this._iconSize = iconSizes[0]; this._iconSize = iconSizes[0];
height = iconSizes[0] + iconSpacing; } else {
for(let i = 0; i < iconSizes.length; i++) {
this._iconSize = iconSizes[i];
let height = iconSizes[i] + iconSpacing;
let w = height * this._items.length + totalSpacing;
if (w <= availWidth)
break;
}
} }
for(let i = 0; i < this.icons.length; i++) { for(let i = 0; i < this.icons.length; i++) {
@ -515,9 +513,11 @@ const AppSwitcher = new Lang.Class({
break; break;
this.icons[i].set_size(this._iconSize); this.icons[i].set_size(this._iconSize);
} }
},
alloc.min_size = height; _getPreferredHeight: function (actor, forWidth, alloc) {
alloc.natural_size = height; this._setIconSize();
this.parent(actor, forWidth, alloc);
}, },
_allocate: function (actor, box, flags) { _allocate: function (actor, box, flags) {