[gnome-shell] windowPreview: Add scaled extra size to chromeWidths() and chromeHeights



commit bc034d55531b8762169bc2ef56178a3c003889b8
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Feb 8 19:06:37 2021 +0100

    windowPreview: Add scaled extra size to chromeWidths() and chromeHeights
    
    Right now the rowSpacing and columSpacing of the layout strategy is
    calculated by looking at the overlapping sizes of the close button and
    the app icon of the WindowPreview, plus a constant spacing read from CSS
    by the WorkspaceLayout that's added to that. We're not factoring in the
    extra size of the scaled-up WindowPreviews here and instead depend on
    the constant spacing being large enough. If we don't want to depend on
    the spacing here, we should add the scaled-up extra size to the sizes
    returned by chromeWidths() and chromeHeights().
    
    Since the last commits all previews scale up by the same amount of
    pixels, so we can now just add that size to the values returned by
    chromeWidths() and chromeHeights().
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1692>

 js/ui/windowPreview.js | 14 ++++++++++++--
 js/ui/workspace.js     |  9 ---------
 2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js
index 2527789485..1659d00775 100644
--- a/js/ui/windowPreview.js
+++ b/js/ui/windowPreview.js
@@ -466,15 +466,22 @@ var WindowPreview = GObject.registerClass({
     chromeHeights() {
         const [, closeButtonHeight] = this._closeButton.get_preferred_height(-1);
         const [, iconHeight] = this._icon.get_preferred_height(-1);
+        const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
+        const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * scaleFactor;
 
         const topOversize = closeButtonHeight / 2;
         const bottomOversize = (1 - ICON_OVERLAP) * iconHeight;
 
-        return [topOversize, bottomOversize];
+        return [
+            topOversize + activeExtraSize,
+            bottomOversize + activeExtraSize,
+        ];
     }
 
     chromeWidths() {
         const [, closeButtonWidth] = this._closeButton.get_preferred_width(-1);
+        const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
+        const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * scaleFactor;
 
         const leftOversize = this._closeButtonSide === St.Side.LEFT
             ? closeButtonWidth / 2
@@ -483,7 +490,10 @@ var WindowPreview = GObject.registerClass({
             ? 0
             : closeButtonWidth / 2;
 
-        return [leftOversize, rightOversize];
+        return [
+            leftOversize + activeExtraSize,
+            rightOversize  + activeExtraSize,
+        ];
     }
 
     showOverlay(animate) {
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index e75d64377c..403c5dded0 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -12,7 +12,6 @@ const Util = imports.misc.util;
 const { WindowPreview } = imports.ui.windowPreview;
 
 var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95;
-var MAXIMUM_PREVIEW_AREA = 0.98;
 
 var WINDOW_REPOSITIONING_DELAY = 750;
 
@@ -470,14 +469,6 @@ var WorkspaceLayout = GObject.registerClass({
             colSpacing += Math.max(leftOversize, rightOversize);
 
         if (containerBox) {
-            // add some padding around preview area
-            const [width, height] = containerBox.get_size();
-            containerBox.set_size(
-                width * MAXIMUM_PREVIEW_AREA,
-                height * MAXIMUM_PREVIEW_AREA);
-            containerBox.x1 += width * (1 - MAXIMUM_PREVIEW_AREA) / 2;
-            containerBox.y1 += height * (1 - MAXIMUM_PREVIEW_AREA) / 2;
-
             const [topOverlap, bottomOverlap] = window.overlapHeights();
             containerBox.x1 += leftOversize + topOverlap;
             containerBox.x2 -= rightOversize;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]