[gnome-shell] workspace: Fix bad window positions with small windows



commit 083c37a7b25fc1e5771d376848ab55a2e673a773
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Feb 28 16:08:19 2013 -0500

    workspace: Fix bad window positions with small windows
    
    This can happen if you open two or three terminal windows, and then
    open the overview -- they're not centered. The issue is that because
    of the WINDOW_CLONE_MAXIMUM_SCALE clamping, the scale that is being
    laid out is different from the scale that the layout was calculated
    for.
    
    Implement and document a hack-ish solution which simply keeps the
    scale for the layout as originally calculated, but centers the
    windows inside the cell.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694902

 js/ui/workspace.js |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index abc4220..a3cd6a8 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -631,8 +631,9 @@ const WindowPositionFlags = {
 // must always be true. This is for each individual window -- while we
 // could adjust layoutScale to make the largest thumbnail smaller than
 // WINDOW_CLONE_MAXIMUM_SCALE, it would shrink windows which are already
-// under the inequality. This is a difficult issue, and right now is
-// unsolved -- it will generate bad layouts.
+// under the inequality. To solve this, we simply cheat: we simply keep
+// each window's "cell" area to be the same, but we shrink the thumbnail
+// and center it horizontally, and align it to the bottom vertically.
 
 const LayoutStrategy = new Lang.Class({
     Name: 'LayoutStrategy',
@@ -770,13 +771,17 @@ const LayoutStrategy = new Lang.Class({
                 let window = row.windows[j];
 
                 let s = scale * this._computeWindowScale(window);
+                let cellWidth = window.actor.width * s;
+                let cellHeight = window.actor.height * s;
+
                 s = Math.min(s, WINDOW_CLONE_MAXIMUM_SCALE);
-                let width = window.actor.width * s;
-                let height = window.actor.height * s;
-                let y = row.y + row.height - height;
+                let cloneWidth = window.actor.width * s;
+
+                let cloneX = x + (cellWidth - cloneWidth) / 2;
+                let cloneY = row.y + row.height - cellHeight;
 
-                slots.push([x, y, s, window]);
-                x += width + this._columnSpacing;
+                slots.push([cloneX, cloneY, s, window]);
+                x += cellWidth + this._columnSpacing;
             }
         }
         return slots;


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