[gnome-shell] workspace: Center window previews horizontally and vertically



commit dda23fc4c6ac4cb34758d04f9b6afaf2003ed626
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Thu Jan 14 22:48:15 2021 +0100

    workspace: Center window previews horizontally and vertically
    
    Window previews looks slightly offset to the left and top right now
    because we don't use the same padding on all edges of the Workspace. We
    do that because the oversize and overlap of the window previews is
    different on all sides (for example the bottom overlap is very large
    because there we show the window title).
    
    To make sure window previews are always perfectly centered on the
    Workspace, only use the largest one of the oversize values as spacing
    and padding, and add the larger one of the overlap values for the
    vertical padding in addition.
    
    With this, we now center the window previews on the Workspace while
    never overpainting the allocation of that Workspace to show overlays.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3634
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1670>

 js/ui/workspace.js | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 1a5bd02271..2d6764dc41 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -467,17 +467,22 @@ var WorkspaceLayout = GObject.registerClass({
         const [topOversize, bottomOversize] = window.chromeHeights();
         const [leftOversize, rightOversize] = window.chromeWidths();
 
+        const oversize =
+            Math.max(topOversize, bottomOversize, leftOversize, rightOversize);
+
         if (rowSpacing !== null)
-            rowSpacing += topOversize + bottomOversize;
+            rowSpacing += oversize;
         if (colSpacing !== null)
-            colSpacing += Math.max(leftOversize, rightOversize);
+            colSpacing += oversize;
 
         if (containerBox) {
             const [topOverlap, bottomOverlap] = window.overlapHeights();
-            containerBox.x1 += leftOversize;
-            containerBox.x2 -= rightOversize;
-            containerBox.y1 += topOversize + topOverlap;
-            containerBox.y2 -= bottomOversize + bottomOverlap;
+            const overlap = Math.max(topOverlap, bottomOverlap);
+
+            containerBox.x1 += oversize;
+            containerBox.x2 -= oversize;
+            containerBox.y1 += oversize + overlap;
+            containerBox.y2 -= oversize + overlap;
         }
 
         return [rowSpacing, colSpacing, containerBox];


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