]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

layouts: geometry computation aligned to v4.0 API; fixes #267
authorcopycat-killer <dada@archlinux.info>
Thu, 26 Jan 2017 18:28:41 +0000 (19:28 +0100)
committercopycat-killer <dada@archlinux.info>
Thu, 26 Jan 2017 18:28:41 +0000 (19:28 +0100)
layout/cascade.lua
layout/centerwork.lua
layout/termfair.lua

index 2b02c000fb0d2468361b267b7f4c7cdcd9ad000a..204ce4017bc211f532c750ae5f2e6c3979590486 100644 (file)
@@ -8,8 +8,8 @@
                                                   
 --]]
 
                                                   
 --]]
 
-local scr      = require("awful.screen")
-local tonumber = tonumber
+local floor  = math.floor
+local screen = screen
 
 local cascade = {
     name     = "cascade",
 
 local cascade = {
     name     = "cascade",
@@ -28,17 +28,11 @@ local cascade = {
 }
 
 local function do_cascade(p, tiling)
 }
 
 local function do_cascade(p, tiling)
-    -- Screen.
-    local wa  = p.workarea
+    local t = p.tag or screen[p.screen].selected_tag
+    local wa = p.workarea
     local cls = p.clients
     local cls = p.clients
-    local ta = scr.focused().selected_tag
 
 
-    if not ta then return end
-
-    if #cls <= 0 then return end
-
-    -- Useless gaps.
-    local useless_gap = p.useless_gap or 0
+    if #cls == 0 then return end
 
     if not tiling then
         -- Cascade windows.
 
     if not tiling then
         -- Cascade windows.
@@ -47,7 +41,7 @@ local function do_cascade(p, tiling)
         if cascade.nmaster > 0 then
             num_c = cascade.nmaster
         else
         if cascade.nmaster > 0 then
             num_c = cascade.nmaster
         else
-            num_c = ta.master_count
+            num_c = t.master_count
         end
 
         -- Opening a new window will usually force all existing windows to
         end
 
         -- Opening a new window will usually force all existing windows to
@@ -66,13 +60,13 @@ local function do_cascade(p, tiling)
 
             g.x      = wa.x + (how_many - i) * cascade.offset_x
             g.y      = wa.y + (i - 1) * cascade.offset_y
 
             g.x      = wa.x + (how_many - i) * cascade.offset_x
             g.y      = wa.y + (i - 1) * cascade.offset_y
-            g.width  = wa.width - current_offset_x - 2*c.border_width
-            g.height = wa.height - current_offset_y - 2*c.border_width
+            g.width  = wa.width - current_offset_x
+            g.height = wa.height - current_offset_y
 
             if g.width  < 1 then g.width  = 1 end
             if g.height < 1 then g.height = 1 end
 
 
             if g.width  < 1 then g.width  = 1 end
             if g.height < 1 then g.height = 1 end
 
-            c:geometry(g)
+            p.geometries[c] = g
         end
     else
         -- Layout with one fixed column meant for a master window. Its
         end
     else
         -- Layout with one fixed column meant for a master window. Its
@@ -92,7 +86,7 @@ local function do_cascade(p, tiling)
         if cascade.tile.mwfact > 0 then
             mwfact = cascade.tile.mwfact
         else
         if cascade.tile.mwfact > 0 then
             mwfact = cascade.tile.mwfact
         else
-            mwfact = ta.master_width_factor
+            mwfact = t.master_width_factor
         end
 
         -- Make slave windows overlap main window? Do this if ncol is 1.
         end
 
         -- Make slave windows overlap main window? Do this if ncol is 1.
@@ -100,7 +94,7 @@ local function do_cascade(p, tiling)
         if cascade.tile.ncol > 0 then
             overlap_main = cascade.tile.ncol
         else
         if cascade.tile.ncol > 0 then
             overlap_main = cascade.tile.ncol
         else
-            overlap_main = ta.column_count
+            overlap_main = t.column_count
         end
 
         -- Minimum space for slave windows? See cascade.tile.lua.
         end
 
         -- Minimum space for slave windows? See cascade.tile.lua.
@@ -108,7 +102,7 @@ local function do_cascade(p, tiling)
         if cascade.tile.nmaster > 0 then
             num_c = cascade.tile.nmaster
         else
         if cascade.tile.nmaster > 0 then
             num_c = cascade.tile.nmaster
         else
-            num_c = ta.master_count
+            num_c = t.master_count
         end
 
         local how_many = (#cls - 1 >= num_c and (#cls - 1)) or num_c
         end
 
         local how_many = (#cls - 1 >= num_c and (#cls - 1)) or num_c
@@ -121,15 +115,13 @@ local function do_cascade(p, tiling)
         -- Main column, fixed width and height.
         local c = cls[1]
         local g = {}
         -- Main column, fixed width and height.
         local c = cls[1]
         local g = {}
-        -- Subtracting the useless_gap width from the work area width here
-        -- makes this mwfact calculation work the same as in uselesstile.
         -- Rounding is necessary to prevent the rendered size of slavewid
         -- from being 1 pixel off when the result is not an integer.
         -- Rounding is necessary to prevent the rendered size of slavewid
         -- from being 1 pixel off when the result is not an integer.
-        local mainwid = math.floor((wa.width - useless_gap) * mwfact)
+        local mainwid = floor(wa.width * mwfact)
         local slavewid = wa.width - mainwid
 
         if overlap_main == 1 then
         local slavewid = wa.width - mainwid
 
         if overlap_main == 1 then
-            g.width = wa.width - 2*c.border_width
+            g.width = wa.width
 
             -- The size of the main window may be reduced a little bit.
             -- This allows you to see if there are any windows below the
 
             -- The size of the main window may be reduced a little bit.
             -- This allows you to see if there are any windows below the
@@ -138,49 +130,34 @@ local function do_cascade(p, tiling)
             -- overlapping everything else.
             g.width = g.width - cascade.tile.extra_padding
         else
             -- overlapping everything else.
             g.width = g.width - cascade.tile.extra_padding
         else
-            g.width = mainwid - 2*c.border_width
+            g.width = mainwid
         end
 
         end
 
-        g.height = wa.height - 2*c.border_width
+        g.height = wa.height
         g.x = wa.x
         g.y = wa.y
         g.x = wa.x
         g.y = wa.y
-        if useless_gap > 0 then
-            -- Reduce width once and move window to the right.
-            -- Reduce height twice, however.
-            g.width = g.width - useless_gap
-            g.height = g.height - 2 * useless_gap
-            g.x = g.x + useless_gap
-            g.y = g.y + useless_gap
-
-            -- When there's no window to the right, add an additional gap.
-            if overlap_main == 1 then g.width = g.width - useless_gap end
-        end
-        if g.width < 1 then g.width = 1 end
+
+        if g.width < 1  then g.width  = 1 end
         if g.height < 1 then g.height = 1 end
         if g.height < 1 then g.height = 1 end
-        c:geometry(g)
+
+        p.geometries[c] = g
 
         -- Remaining clients stacked in slave column, new ones on top.
 
         -- Remaining clients stacked in slave column, new ones on top.
-        if #cls > 1 then
-            for i = 2,#cls do
-                c = cls[i]
-                g = {}
-                g.width = slavewid - current_offset_x - 2*c.border_width
-                g.height = wa.height - current_offset_y - 2*c.border_width
-                g.x = wa.x + mainwid + (how_many - (i - 1)) * cascade.tile.offset_x
-                g.y = wa.y + (i - 2) * cascade.tile.offset_y
-
-                if useless_gap > 0 then
-                    g.width = g.width - 2 * useless_gap
-                    g.height = g.height - 2 * useless_gap
-                    g.x = g.x + useless_gap
-                    g.y = g.y + useless_gap
-                end
-
-                if g.width < 1 then g.width = 1 end
-                if g.height < 1 then g.height = 1 end
-
-                c:geometry(g)
-            end
+        if #cls <= 1 then return end
+        for i = 2,#cls do
+            c = cls[i]
+            g = {}
+
+            g.width  = slavewid - current_offset_x
+            g.height = wa.height - current_offset_y
+
+            g.x = wa.x + mainwid + (how_many - (i - 1)) * cascade.tile.offset_x
+            g.y = wa.y + (i - 2) * cascade.tile.offset_y
+
+            if g.width < 1  then g.width  = 1 end
+            if g.height < 1 then g.height = 1 end
+
+            p.geometries[c] = g
         end
     end
 end
         end
     end
 end
index a8d9a962d510a82b5581c22bd5fa774aef2648f4..eafab78ce5c5054f1834e616b97e555305f6294c 100644 (file)
@@ -10,9 +10,8 @@
                                                   
 --]]
 
                                                   
 --]]
 
-local tonumber = tonumber
-local math     = { floor = math.floor }
-local scr      = require("awful.screen")
+local floor  = math.floor
+local screen = screen
 
 local centerwork = {
     name         = "centerwork",
 
 local centerwork = {
     name         = "centerwork",
@@ -20,60 +19,54 @@ local centerwork = {
 }
 
 local function do_centerwork(p, orientation)
 }
 
 local function do_centerwork(p, orientation)
-    -- Screen.
-    local wa  = p.workarea
+    local t = p.tag or screen[p.screen].selected_tag
+    local wa = p.workarea
     local cls = p.clients
     local cls = p.clients
-    local ta = scr.focused().selected_tag
 
 
-    if not ta then return end
-
-    if #cls <= 0 then return end
-
-    -- Useless gaps.
-    local useless_gap = p.useless_gap or 0
+    if #cls == 0 then return end
 
     local c = cls[1]
     local g = {}
 
     -- Main column, fixed width and height.
 
     local c = cls[1]
     local g = {}
 
     -- Main column, fixed width and height.
-    local mwfact          = ta.master_width_factor
-    local mainhei         = math.floor(wa.height * mwfact)
-    local mainwid         = math.floor(wa.width * mwfact)
+    local mwfact          = t.master_width_factor
+    local mainhei         = floor(wa.height * mwfact)
+    local mainwid         = floor(wa.width * mwfact)
     local slavewid        = wa.width - mainwid
     local slavewid        = wa.width - mainwid
-    local slaveLwid       = math.floor(slavewid / 2)
+    local slaveLwid       = floor(slavewid / 2)
     local slaveRwid       = slavewid - slaveLwid
     local slavehei        = wa.height - mainhei
     local slaveRwid       = slavewid - slaveLwid
     local slavehei        = wa.height - mainhei
-    local slaveThei       = math.floor(slavehei / 2)
+    local slaveThei       = floor(slavehei / 2)
     local slaveBhei       = slavehei - slaveThei
     local slaveBhei       = slavehei - slaveThei
-    local nbrFirstSlaves  = math.floor(#cls / 2)
-    local nbrSecondSlaves = math.floor((#cls - 1) / 2)
+    local nbrFirstSlaves  = floor(#cls / 2)
+    local nbrSecondSlaves = floor((#cls - 1) / 2)
 
     local slaveFirstDim, slaveSecondDim = 0, 0
 
     if orientation == "vertical" then
 
     local slaveFirstDim, slaveSecondDim = 0, 0
 
     if orientation == "vertical" then
-        if nbrFirstSlaves  > 0 then slaveFirstDim  = math.floor(wa.height / nbrFirstSlaves) end
-        if nbrSecondSlaves > 0 then slaveSecondDim = math.floor(wa.height / nbrSecondSlaves) end
+        if nbrFirstSlaves  > 0 then slaveFirstDim  = floor(wa.height / nbrFirstSlaves) end
+        if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.height / nbrSecondSlaves) end
 
 
-        g.height = wa.height - 2*useless_gap - 2*c.border_width
-        g.width  = mainwid - 2*c.border_width
+        g.height = wa.height
+        g.width  = mainwid
 
         g.x = wa.x + slaveLwid
 
         g.x = wa.x + slaveLwid
-        g.y = wa.y + useless_gap
+        g.y = wa.y
     else
     else
-        if nbrFirstSlaves  > 0 then slaveFirstDim  = math.floor(wa.width / nbrFirstSlaves) end
-        if nbrSecondSlaves > 0 then slaveSecondDim = math.floor(wa.width / nbrSecondSlaves) end
+        if nbrFirstSlaves  > 0 then slaveFirstDim  = floor(wa.width / nbrFirstSlaves) end
+        if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.width / nbrSecondSlaves) end
 
 
-        g.height  = mainhei - 2*c.border_width
-        g.width = wa.width - 2*useless_gap - 2*c.border_width
+        g.height  = mainhei
+        g.width = wa.width
 
 
-        g.x = wa.x + useless_gap
+        g.x = wa.x
         g.y = wa.y + slaveThei
     end
 
     if g.width  < 1 then g.width  = 1 end
     if g.height < 1 then g.height = 1 end
 
         g.y = wa.y + slaveThei
     end
 
     if g.width  < 1 then g.width  = 1 end
     if g.height < 1 then g.height = 1 end
 
-    c:geometry(g)
+    p.geometries[c] = g
 
     -- Auxiliary windows.
     if #cls <= 1 then return end
 
     -- Auxiliary windows.
     if #cls <= 1 then return end
@@ -81,62 +74,62 @@ local function do_centerwork(p, orientation)
         local c = cls[i]
         local g = {}
 
         local c = cls[i]
         local g = {}
 
-        local rowIndex = math.floor(i/2)
+        local rowIndex = floor(i/2)
 
         if orientation == "vertical" then
             if i % 2 == 0 then
                 -- left slave
 
         if orientation == "vertical" then
             if i % 2 == 0 then
                 -- left slave
-                g.x = wa.x + useless_gap
-                g.y = wa.y + useless_gap + (rowIndex-1)*slaveFirstDim
+                g.x = wa.x
+                g.y = wa.y + (rowIndex-1)*slaveFirstDim
 
 
-                g.width = slaveLwid - 2*useless_gap - 2*c.border_width
+                g.width = slaveLwid
 
                 -- if last slave in left row use remaining space for that slave
                 if rowIndex == nbrFirstSlaves then
 
                 -- if last slave in left row use remaining space for that slave
                 if rowIndex == nbrFirstSlaves then
-                    g.height = wa.y + wa.height - g.y - useless_gap - 2*c.border_width
+                    g.height = wa.y + wa.height - g.y
                 else
                 else
-                    g.height = slaveFirstDim - useless_gap - 2*c.border_width
+                    g.height = slaveFirstDim
                 end
             else
                 -- right slave
                 end
             else
                 -- right slave
-                g.x = wa.x + slaveLwid + mainwid + useless_gap
-                g.y = wa.y + useless_gap + (rowIndex-1)*slaveSecondDim
+                g.x = wa.x + slaveLwid + mainwid
+                g.y = wa.y + (rowIndex-1)*slaveSecondDim
 
 
-                g.width = slaveRwid - 2*useless_gap - 2*c.border_width
+                g.width = slaveRwid
 
                 -- if last slave in right row use remaining space for that slave
                 if rowIndex == nbrSecondSlaves then
 
                 -- if last slave in right row use remaining space for that slave
                 if rowIndex == nbrSecondSlaves then
-                    g.height = wa.y + wa.height - g.y - useless_gap - 2*c.border_width
+                    g.height = wa.y + wa.height - g.y
                 else
                 else
-                    g.height = slaveSecondDim - useless_gap - 2*c.border_width
+                    g.height = slaveSecondDim
                 end
             end
         else
             if i % 2 == 0 then
                 -- top slave
                 end
             end
         else
             if i % 2 == 0 then
                 -- top slave
-                g.x = wa.x + useless_gap + (rowIndex-1)*slaveFirstDim
-                g.y = wa.y + useless_gap
+                g.x = wa.x + (rowIndex-1)*slaveFirstDim
+                g.y = wa.y
 
 
-                g.height = slaveThei - 2*useless_gap - 2*c.border_width
+                g.height = slaveThei
 
                 -- if last slave in top row use remaining space for that slave
                 if rowIndex == nbrFirstSlaves then
 
                 -- if last slave in top row use remaining space for that slave
                 if rowIndex == nbrFirstSlaves then
-                    g.width = wa.x + wa.width - g.x - useless_gap - 2*c.border_width
+                    g.width = wa.x + wa.width - g.x
                 else
                 else
-                    g.width = slaveFirstDim - useless_gap - 2*c.border_width
+                    g.width = slaveFirstDim
                 end
             else
                 -- bottom slave
                 end
             else
                 -- bottom slave
-                g.x = wa.x + useless_gap + (rowIndex-1)*slaveFirstDim
-                g.y = wa.y + slaveThei + mainhei + useless_gap
+                g.x = wa.x + (rowIndex-1)*slaveSecondDim
+                g.y = wa.y + slaveThei + mainhei
 
 
-                g.height = slaveBhei - 2*useless_gap - 2*c.border_width
+                g.height = slaveBhei
 
                 -- if last slave in bottom row use remaining space for that slave
                 if rowIndex == nbrSecondSlaves then
 
                 -- if last slave in bottom row use remaining space for that slave
                 if rowIndex == nbrSecondSlaves then
-                    g.width = wa.x + wa.width - g.x - useless_gap - 2*c.border_width
+                    g.width = wa.x + wa.width - g.x
                 else
                 else
-                    g.width = slaveSecondDim - useless_gap - 2*c.border_width
+                    g.width = slaveSecondDim
                 end
 
             end
                 end
 
             end
@@ -145,7 +138,7 @@ local function do_centerwork(p, orientation)
         if g.width  < 1 then g.width  = 1 end
         if g.height < 1 then g.height = 1 end
 
         if g.width  < 1 then g.width  = 1 end
         if g.height < 1 then g.height = 1 end
 
-        c:geometry(g)
+        p.geometries[c] = g
     end
 end
 
     end
 end
 
index 26a71308f1788e8f93364c8f70ca83d7976685a6..33b7ffc7489634761565caab3248c336b494a975 100644 (file)
@@ -9,27 +9,21 @@
                                                   
 --]]
 
                                                   
 --]]
 
-local scr      = require("awful.screen")
 local math     = { ceil  = math.ceil,
                    floor = math.floor,
                    max   = math.max }
 local math     = { ceil  = math.ceil,
                    floor = math.floor,
                    max   = math.max }
+local screen   = screen
 local tonumber = tonumber
 
 local termfair  = { name = "termfair" }
 termfair.center = { name = "centerfair" }
 
 local function do_fair(p, orientation)
 local tonumber = tonumber
 
 local termfair  = { name = "termfair" }
 termfair.center = { name = "centerfair" }
 
 local function do_fair(p, orientation)
-    -- Screen.
-    local wa  = p.workarea
+    local t = p.tag or screen[p.screen].selected_tag
+    local wa = p.workarea
     local cls = p.clients
     local cls = p.clients
-    local ta = scr.focused().selected_tag
 
 
-    if not ta then return end
-
-    if #cls <= 0 then return end
-
-    -- Useless gaps.
-    local useless_gap = p.useless_gap or 0
+    if #cls == 0 then return end
 
     if orientation == "west" then
         -- Layout with fixed number of vertical columns (read from nmaster).
 
     if orientation == "west" then
         -- Layout with fixed number of vertical columns (read from nmaster).
@@ -50,18 +44,16 @@ local function do_fair(p, orientation)
         --   | 3 | 2 | 1 |      | 3 | 2 | 1 |      | 3 | 2 | 1 |
         --   +---+---+---+      +---+---+---+      +---+---+---+
 
         --   | 3 | 2 | 1 |      | 3 | 2 | 1 |      | 3 | 2 | 1 |
         --   +---+---+---+      +---+---+---+      +---+---+---+
 
-        if #cls <= 0 then return end
-
         -- How many vertical columns? Read from nmaster on the tag.
         -- How many vertical columns? Read from nmaster on the tag.
-        local num_x = tonumber(termfair.nmaster) or ta.master_count
-        local ncol  = tonumber(termfair.ncol) or ta.column_count
+        local num_x = tonumber(termfair.nmaster) or t.master_count
+        local ncol  = tonumber(termfair.ncol) or t.column_count
 
         if num_x <= 2 then num_x = 2 end
         if ncol  <= 1 then ncol  = 1 end
 
         if num_x <= 2 then num_x = 2 end
         if ncol  <= 1 then ncol  = 1 end
-        local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x)
+        local width = math.floor(wa.width/num_x)
 
         local num_y     = math.max(math.ceil(#cls / num_x), ncol)
 
         local num_y     = math.max(math.ceil(#cls / num_x), ncol)
-        local height    = math.floor((wa.height - (num_y + 1)*useless_gap) / num_y)
+        local height    = math.floor(wa.height/num_y)
         local cur_num_x = num_x
         local at_x      = 0
         local at_y      = 0
         local cur_num_x = num_x
         local at_x      = 0
         local at_y      = 0
@@ -84,30 +76,24 @@ local function do_fair(p, orientation)
             -- Calculate geometry.
             local g = {}
             if this_x == (num_x - 1) then
             -- Calculate geometry.
             local g = {}
             if this_x == (num_x - 1) then
-                g.width = wa.width - (num_x - 1)*width - (num_x + 1)*useless_gap - 2*c.border_width
+                g.width = wa.width - (num_x - 1)*width
             else
             else
-                g.width = width - 2*c.border_width
+                g.width = width
             end
 
             if this_y == (num_y - 1) then
             end
 
             if this_y == (num_y - 1) then
-                g.height = wa.height - (num_y - 1)*height - (num_y + 1)*useless_gap - 2*c.border_width
+                g.height = wa.height - (num_y - 1)*height
             else
             else
-                g.height = height - 2*c.border_width
+                g.height = height
             end
 
             g.x = wa.x + this_x*width
             g.y = wa.y + this_y*height
 
             end
 
             g.x = wa.x + this_x*width
             g.y = wa.y + this_y*height
 
-            if useless_gap > 0 then
-                -- All clients tile evenly.
-                g.x = g.x + (this_x + 1)*useless_gap
-                g.y = g.y + (this_y + 1)*useless_gap
-            end
-
-            if g.width < 1 then g.width = 1 end
+            if g.width  < 1 then g.width  = 1 end
             if g.height < 1 then g.height = 1 end
 
             if g.height < 1 then g.height = 1 end
 
-            c:geometry(g)
+            p.geometries[c] = g
 
             remaining_clients = remaining_clients - 1
 
 
             remaining_clients = remaining_clients - 1
 
@@ -146,100 +132,98 @@ local function do_fair(p, orientation)
         --   +---+---+---+      +---+---+---+
 
         -- How many vertical columns? Read from nmaster on the tag.
         --   +---+---+---+      +---+---+---+
 
         -- How many vertical columns? Read from nmaster on the tag.
-        local num_x = tonumber(termfair.center.nmaster) or ta.master_count
-        local ncol  = tonumber(termfair.center.ncol) or ta.column_count
+        local num_x = tonumber(termfair.center.nmaster) or t.master_count
+        local ncol  = tonumber(termfair.center.ncol) or t.column_count
 
         if num_x <= 2 then num_x = 2 end
         if ncol  <= 1 then ncol  = 1 end
 
 
         if num_x <= 2 then num_x = 2 end
         if ncol  <= 1 then ncol  = 1 end
 
-        local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x)
+        local width = math.floor(wa.width / num_x)
 
         if #cls < num_x then
             -- Less clients than the number of columns, let's center it!
 
         if #cls < num_x then
             -- Less clients than the number of columns, let's center it!
-            local offset_x = wa.x + (wa.width - #cls*width - (#cls - 1)*useless_gap) / 2
-            local g = {}
-            g.y = wa.y + useless_gap
+            local offset_x = wa.x + (wa.width - #cls*width) / 2
             for i = 1, #cls do
             for i = 1, #cls do
-                local c = cls[i]
-                g.width = width - 2*c.border_width
-                g.height = wa.height - 2*useless_gap - 2*c.border_width
+                local g = { y = wa.y }
+                g.width  = width
+                g.height = wa.height
                 if g.width < 1 then g.width = 1 end
                 if g.height < 1 then g.height = 1 end
                 if g.width < 1 then g.width = 1 end
                 if g.height < 1 then g.height = 1 end
-                g.x = offset_x + (i - 1) * (width + useless_gap)
-                c:geometry(g)
+                g.x = offset_x + (i - 1) * width
+                p.geometries[cls[i]] = g
             end
         else
             -- More clients than the number of columns, let's arrange it!
             -- Master client deserves a special treatement
             end
         else
             -- More clients than the number of columns, let's arrange it!
             -- Master client deserves a special treatement
-            local c = cls[1]
             local g = {}
             local g = {}
-            g.width = wa.width - (num_x - 1)*width - (num_x + 1)*useless_gap - 2*c.border_width
-            g.height = wa.height - 2*useless_gap - 2*c.border_width
+            g.width = wa.width - (num_x - 1)*width
+            g.height = wa.height
             if g.width < 1 then g.width = 1 end
             if g.height < 1 then g.height = 1 end
             if g.width < 1 then g.width = 1 end
             if g.height < 1 then g.height = 1 end
-            g.x = wa.x + useless_gap
-            g.y = wa.y + useless_gap
-
-            c:geometry(g)
+            g.x = wa.x
+            g.y = wa.y
+            p.geometries[cls[1]] = g
 
             -- Treat the other clients
 
             -- Compute distribution of clients among columns
 
             -- Treat the other clients
 
             -- Compute distribution of clients among columns
-            local num_y ={}
-            do
-                local remaining_clients = #cls-1
-                local ncol_min = math.ceil(remaining_clients/(num_x-1))
-                if ncol >= ncol_min then
-                    for i = (num_x-1), 1, -1 do
-                        if (remaining_clients-i+1) < ncol then
-                            num_y[i] = remaining_clients-i + 1
-                        else
-                            num_y[i] = ncol
-                        end
-                        remaining_clients = remaining_clients - num_y[i]
+            local num_y = {}
+            local remaining_clients = #cls-1
+            local ncol_min = math.ceil(remaining_clients/(num_x-1))
+
+            if ncol >= ncol_min then
+                for i = (num_x-1), 1, -1 do
+                    if (remaining_clients-i+1) < ncol then
+                        num_y[i] = remaining_clients-i + 1
+                    else
+                        num_y[i] = ncol
+                    end
+                    remaining_clients = remaining_clients - num_y[i]
+                end
+            else
+                local rem = remaining_clients % (num_x-1)
+                if rem == 0 then
+                    for i = 1, num_x-1 do
+                        num_y[i] = ncol_min
                     end
                 else
                     end
                 else
-                    local rem = remaining_clients % (num_x-1)
-                    if rem == 0 then
-                        for i = 1, num_x-1 do
-                            num_y[i] = ncol_min
-                        end
-                    else
-                        for i = 1, num_x-1 do
-                            num_y[i] = ncol_min - 1
-                        end
-                        for i = 0, rem-1 do
-                            num_y[num_x-1-i] = num_y[num_x-1-i] + 1
-                        end
+                    for i = 1, num_x-1 do
+                        num_y[i] = ncol_min - 1
+                    end
+                    for i = 0, rem-1 do
+                        num_y[num_x-1-i] = num_y[num_x-1-i] + 1
                     end
                 end
             end
 
             -- Compute geometry of the other clients
             local nclient = 2 -- we start with the 2nd client
                     end
                 end
             end
 
             -- Compute geometry of the other clients
             local nclient = 2 -- we start with the 2nd client
-            g.x = g.x + g.width + useless_gap + 2*c.border_width
-
+            local wx = g.x + g.width
             for i = 1, (num_x-1) do
             for i = 1, (num_x-1) do
-                local height = math.floor((wa.height - (num_y[i] + 1)*useless_gap) / num_y[i])
-                g.y = wa.y + useless_gap
+                local height = math.floor(wa.height / num_y[i])
+                local wy = wa.y
                 for j = 0, (num_y[i]-2) do
                 for j = 0, (num_y[i]-2) do
-                    local c = cls[nclient]
-                    g.height = height - 2*c.border_width
-                    g.width = width - 2*c.border_width
+                    local g = {}
+                    g.x = wx
+                    g.y = wy
+                    g.height = height
+                    g.width = width
                     if g.width < 1 then g.width = 1 end
                     if g.height < 1 then g.height = 1 end
                     if g.width < 1 then g.width = 1 end
                     if g.height < 1 then g.height = 1 end
-                    c:geometry(g)
+                    p.geometries[cls[nclient]] = g
                     nclient = nclient + 1
                     nclient = nclient + 1
-                    g.y = g.y + height + useless_gap
+                    wy = wy + height
                 end
                 end
-                local c = cls[nclient]
-                g.height = wa.height - (num_y[i] + 1)*useless_gap - (num_y[i] - 1)*height - 2*c.border_width
-                g.width = width - 2*c.border_width
+                local g = {}
+                g.x = wx
+                g.y = wy
+                g.height = wa.height - (num_y[i] - 1)*height
+                g.width = width
                 if g.width < 1 then g.width = 1 end
                 if g.height < 1 then g.height = 1 end
                 if g.width < 1 then g.width = 1 end
                 if g.height < 1 then g.height = 1 end
-                c:geometry(g)
+                p.geometries[cls[nclient]] = g
                 nclient = nclient + 1
                 nclient = nclient + 1
-                g.x = g.x + width + useless_gap
+                wx = wx + width
             end
         end
     end
             end
         end
     end