From a074ef5d7c840e5ea95cae43001034cfee09772a Mon Sep 17 00:00:00 2001 From: Dave Jordan Date: Tue, 31 Mar 2009 16:40:18 -0500 Subject: [PATCH] Use a grid pattern in overlay if more than 6 windows The diagonal arrangement currently used in the overlay when there are more than 6 windows is hard to read and hides most of the previews. Both of these issues are fixed by arranging the windows in a grid pattern. http://bugzilla.gnome.org/show_bug.cgi?id=576269 --- js/ui/workspaces.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js index f0eefb727..37a9c1d2e 100644 --- a/js/ui/workspaces.js +++ b/js/ui/workspaces.js @@ -696,16 +696,14 @@ Workspace.prototype = { return POSITIONS[numberOfWindows][windowIndex]; // If we don't have a predefined scheme for this window count, - // overlap the windows along the diagonal of the workspace - // (improve this!) - let fraction = Math.sqrt(1/numberOfWindows); + // arrange the windows in a grid pattern. + let gridWidth = Math.ceil(Math.sqrt(numberOfWindows)); + let gridHeight = Math.ceil(numberOfWindows / gridWidth); - // The top window goes at the lower right - this is different from the - // fixed position schemes where the windows are in "reading order" - // and the top window goes at the upper left. - let pos = (numberOfWindows - windowIndex - 1) / (numberOfWindows - 1); - let xCenter = (fraction / 2) + (1 - fraction) * pos; - let yCenter = xCenter; + let fraction = Math.sqrt(.5/(gridWidth * gridHeight)); + + let xCenter = (.5 / gridWidth) + ((windowIndex) % gridWidth) / gridWidth; + let yCenter = (.5 / gridHeight) + Math.floor((windowIndex / gridWidth)) / gridHeight; return [xCenter, yCenter, fraction]; },