[gnome-shell/gnome-3-36] iconGrid: Account for display scaling when scaling down icons
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-36] iconGrid: Account for display scaling when scaling down icons
- Date: Fri, 4 Sep 2020 18:36:47 +0000 (UTC)
commit 4718f46618ab9da806895f7862d79968214c767f
Author: Sebastian Keller <skeller gnome org>
Date: Fri Aug 21 17:08:45 2020 +0200
iconGrid: Account for display scaling when scaling down icons
Using display scaling (without 'scale-monitor-framebuffer') means the
CSS item size the (fixed)ItemSize is calculated from has been multiplied
by the scaling factor. So when subtracting the hardcoded icon size from
this to calculate the size of the non-icon content of the item, it needs
to be multiplied by the scaling factor as well.
Then once the new icon size has been calculated after accounting for the
non-icon content, the resulting size has to be divided by the scaling
factor, because StIcon expects the unscaled icon size. Otherwise the
icon would get scaled twice.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3090
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1420
js/ui/iconGrid.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 6e691c58ad..1269a5432e 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -845,10 +845,11 @@ 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 extraWidth = Math.max(0, this._hItemSize - ICON_SIZE);
- let extraHeight = Math.max(0, this._vItemSize - ICON_SIZE);
+ let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
+ let extraWidth = Math.max(0, this._hItemSize - scaleFactor * ICON_SIZE);
+ let extraHeight = Math.max(0, this._vItemSize - scaleFactor * ICON_SIZE);
let newIconSize = Math.min(this._fixedHItemSize - extraWidth,
- this._fixedVItemSize - extraHeight);
+ this._fixedVItemSize - extraHeight) / scaleFactor;
for (let i in this._items)
this._items[i].icon.setIconSize(newIconSize);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]