[gnome-shell] appDisplay: Ensure icon grid is always aligned with the pixel grid
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] appDisplay: Ensure icon grid is always aligned with the pixel grid
- Date: Thu, 8 Apr 2021 16:56:21 +0000 (UTC)
commit 6f0589313d886fe0848384ef29fecd22ea09405d
Author: Sebastian Keller <skeller gnome org>
Date: Thu Apr 8 17:40:43 2021 +0200
appDisplay: Ensure icon grid is always aligned with the pixel grid
When adaptToSize was called with an odd width, the calculated padding
was not an integer and as a result the icon grid was no longer aligned
to the pixel grid. Similarly it was possible for the page size to be a
non-integer value, which was causing items to not be aligned for
pages > 1.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4015
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1799>
js/ui/appDisplay.js | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index bb7e47e178..2cfd2cd032 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1122,43 +1122,53 @@ var BaseAppView = GObject.registerClass({
if (spaceRatio > gridRatio * 1.1) {
// Enough room for some preview
pageHeight = availHeight;
- pageWidth = availHeight * gridRatio;
+ pageWidth = Math.ceil(availHeight * gridRatio);
if (spaceRatio > gridRatio * 1.5) {
// Ultra-wide layout, give some extra space for
// the page area, but up to an extent.
const extraPageSpace = Math.min(
- (availWidth - pageWidth) / 2, MAX_PAGE_PADDING);
+ Math.floor((availWidth - pageWidth) / 2), MAX_PAGE_PADDING);
pageWidth += extraPageSpace;
- this._grid.layout_manager.pagePadding.left = extraPageSpace / 2;
- this._grid.layout_manager.pagePadding.right = extraPageSpace / 2;
+ this._grid.layout_manager.pagePadding.left =
+ Math.floor(extraPageSpace / 2);
+ this._grid.layout_manager.pagePadding.right =
+ Math.ceil(extraPageSpace / 2);
}
} else {
// Not enough room, needs to shrink horizontally
- pageWidth = availWidth * 0.8;
+ pageWidth = Math.ceil(availWidth * 0.8);
pageHeight = availHeight;
- this._grid.layout_manager.pagePadding.left = availWidth * 0.02;
- this._grid.layout_manager.pagePadding.right = availWidth * 0.02;
+ this._grid.layout_manager.pagePadding.left =
+ Math.floor(availWidth * 0.02);
+ this._grid.layout_manager.pagePadding.right =
+ Math.ceil(availWidth * 0.02);
}
this._grid.adaptToSize(pageWidth, pageHeight);
- const horizontalPadding = (availWidth - this._grid.layout_manager.pageWidth) / 2;
- const verticalPadding = (availHeight - this._grid.layout_manager.pageHeight) / 2;
+ const leftPadding = Math.floor(
+ (availWidth - this._grid.layout_manager.pageWidth) / 2);
+ const rightPadding = Math.ceil(
+ (availWidth - this._grid.layout_manager.pageWidth) / 2);
+ const topPadding = Math.floor(
+ (availHeight - this._grid.layout_manager.pageHeight) / 2);
+ const bottomPadding = Math.ceil(
+ (availHeight - this._grid.layout_manager.pageHeight) / 2);
this._scrollView.content_padding = new Clutter.Margin({
- left: horizontalPadding,
- right: horizontalPadding,
- top: verticalPadding,
- bottom: verticalPadding,
+ left: leftPadding,
+ right: rightPadding,
+ top: topPadding,
+ bottom: bottomPadding,
});
this._availWidth = availWidth;
this._availHeight = availHeight;
- this._pageIndicatorOffset = horizontalPadding;
+ this._pageIndicatorOffset = leftPadding;
this._pageArrowOffset = Math.max(
- horizontalPadding - PAGE_PREVIEW_MAX_ARROW_OFFSET, 0);
+ leftPadding - PAGE_PREVIEW_MAX_ARROW_OFFSET, 0);
}
_getIndicatorOffset(page, progress, baseOffset) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]