From 6b86b6a3e2d06941d88fe51d9ed1367549924eb4 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Sun, 19 Jul 2020 14:41:18 +0200 Subject: [PATCH] iconGrid: Account for non-icon content and padding/spacing when scaling _updateIconSizes() was assuming that the icon is the only content of an item when scaling the icon size to ensure the item size matches _fixedHItemSize/_fixedVItemSize. However the icon may have padding and there might be a label and spacing between the icon and the label. This resulted in items being larger than their slots. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2234 --- js/ui/iconGrid.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 25cd14099..6e691c58a 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -845,8 +845,10 @@ var IconGrid = GObject.registerClass({ // Note that this is ICON_SIZE as used by BaseIcon, not elsewhere in IconGrid; it's a bit messed up _updateIconSizes() { this._updateIconSizesLaterId = 0; - let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize, this._vItemSize); - let newIconSize = Math.floor(ICON_SIZE * scale); + let extraWidth = Math.max(0, this._hItemSize - ICON_SIZE); + let extraHeight = Math.max(0, this._vItemSize - ICON_SIZE); + let newIconSize = Math.min(this._fixedHItemSize - extraWidth, + this._fixedVItemSize - extraHeight); for (let i in this._items) this._items[i].icon.setIconSize(newIconSize);