]> git.madduck.net Git - etc/awesome.git/blobdiff - layout/uselesstile.lua

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:

Window border width issue fixes in uselesstile
[etc/awesome.git] / layout / uselesstile.lua
index b82c97e7c9af529ae35c178745fc9f8f24a73fb4..5bb0c05b3a570e89f0fdb816234be7b6bf6e8959 100644 (file)
@@ -1,31 +1,28 @@
 
 --[[
-                                                  
-     Licensed under GNU General Public License v2 
-      * (c) 2013,      Luke Bonham                
-      * (c) 2009       Donald Ephraim Curtis      
-      * (c) 2008       Julien Danjolu             
-                                                  
+
+     Licensed under GNU General Public License v2
+      * (c) 2014       projektile
+      * (c) 2013       Luke Bonham
+      * (c) 2009       Donald Ephraim Curtis
+      * (c) 2008       Julien Danjolu
+
 --]]
 
 local tag       = require("awful.tag")
 local beautiful = require("beautiful")
 local ipairs    = ipairs
-local math      = { floor = math.floor, 
+local math      = { floor = math.floor,
                     max   = math.max,
                     min   = math.min }
 local tonumber  = tonumber
 
 local uselesstile = {}
 
-local function tile_group(cls, wa, orientation, fact, group)
-    -- A useless gap (like the dwm patch) can be defined with
-    -- beautiful.useless_gap_width .
-    local useless_gap = tonumber(beautiful.useless_gap_width)
-    if useless_gap == nil
-    then
-        useless_gap = 0
-    end
+local function tile_group(cls, wa, orientation, fact, group, gap)
+
+    -- Themes border width requires an offset
+    local bw = tonumber(beautiful.border_width) or 0
 
     -- get our orientation right
     local height = "height"
@@ -40,7 +37,8 @@ local function tile_group(cls, wa, orientation, fact, group)
     end
 
     -- make this more generic (not just width)
-    available = wa[width] - (group.coord - wa[x])
+    --if for top
+    available = wa[width] - (group.coord - wa[x]) -- it's truly not here
 
     -- find our total values
     local total_fact = 0
@@ -63,7 +61,6 @@ local function tile_group(cls, wa, orientation, fact, group)
         total_fact = total_fact + fact[i]
     end
     size = math.min(size, available)
-
     local coord = wa[y]
     local geom = {}
     local used_size = 0
@@ -72,49 +69,19 @@ local function tile_group(cls, wa, orientation, fact, group)
     --stat_coord = size
     for c = group.first,group.last do
         local i = c - group.first +1
-        geom[width] = size
-        geom[height] = math.floor(unused * fact[i] / total_fact)
+        geom[width] = size - (bw * 2)
+        geom[height] = math.floor(unused * fact[i] / total_fact) - (bw * 2)
         geom[x] = group.coord
         geom[y] = coord
 
-        coord = coord + geom[height]
-        unused = unused - geom[height]
+        coord = coord + geom[height] + 2 * bw
+        unused = unused - geom[height] - 2 * bw
         total_fact = total_fact - fact[i]
-        used_size = math.max(used_size, geom[width])
-
-        -- Useless gap
-        if useless_gap > 0
-        then
-            -- Top and left clients are shrinked by two steps and
-            -- get moved away from the border. Other clients just
-            -- get shrinked in one direction.
-
-            top = false
-            left = false
+        used_size = math.max(used_size, geom[width] + 2 * bw)
 
-            if geom[y] == wa[y] then
-                top = true
-            end
-
-            if geom[x] == 0 or geom[x] == wa[x] then
-                left = true
-            end
-
-            if top then
-                geom[height] = geom[height] - 2 * useless_gap
-                geom[y] = geom[y] + useless_gap
-            else
-                geom[height] = geom[height] - useless_gap
-            end
-
-            if left then
-                geom[width] = geom[width] - 2 * useless_gap
-                geom[x] = geom[x] + useless_gap
-            else
-                geom[width] = geom[width] - useless_gap
-            end
-        end
-        -- End of useless gap.
+        -- Useless gap correction
+        geom.width = geom.width - gap
+        geom.height = geom.height - gap
 
         geom = cls[c]:geometry(geom)
     end
@@ -126,6 +93,16 @@ local function tile(param, orientation)
     local t = tag.selected(param.screen)
     orientation = orientation or "right"
 
+    -- A useless gap (like the dwm patch) can be defined with
+    -- beautiful.useless_gap_width .
+    local useless_gap = tonumber(beautiful.useless_gap_width) or 0
+    if useless_gap < 0 then useless_gap = 0 end
+
+    -- A global border can be defined with
+    -- beautiful.global_border_width
+    local global_border = tonumber(beautiful.global_border_width) or 0
+    if global_border < 0 then global_border = 0 end
+
     -- this handles are different orientations
     local height = "height"
     local width = "width"
@@ -146,6 +123,12 @@ local function tile(param, orientation)
     local wa = param.workarea
     local ncol = tag.getncol(t)
 
+    -- Workarea size correction
+    wa.height = wa.height - 2 * global_border - useless_gap
+    wa.width  = wa.width -  2 * global_border - useless_gap
+    wa.x = wa.x + useless_gap + global_border
+    wa.y = wa.y + useless_gap + global_border
+
     local data = tag.getdata(t).windowfact
 
     if not data then
@@ -170,7 +153,7 @@ local function tile(param, orientation)
             if not data[0] then
                 data[0] = {}
             end
-            coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size})
+            coord = coord + tile_group(cls, wa, orientation, data[0], {first=1, last=nmaster, coord = coord, size = size}, useless_gap)
         end
 
         if not place_master and nother > 0 then
@@ -183,14 +166,14 @@ local function tile(param, orientation)
             end
             for i = 1,ncol do
                 -- Try to get equal width among remaining columns
-                local size = math.min( (wasize - (coord - wa[x])) / (ncol - i + 1) )
+                local size = math.min((wasize - (coord - wa[x]))  / (ncol - i + 1)) --+ (global_border/(ncol))/(ncol+i^2)
                 local first = last + 1
                 last = last + math.floor((#cls - last)/(ncol - i + 1))
                 -- tile the column and update our current x coordinate
                 if not data[i] then
                     data[i] = {}
                 end
-                coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size })
+                coord = coord + tile_group(cls, wa, orientation, data[i], { first = first, last = last, coord = coord, size = size }, useless_gap)
             end
         end
         place_master = not place_master
@@ -230,3 +213,4 @@ uselesstile.arrange = uselesstile.right.arrange
 uselesstile.name = uselesstile.right.name
 
 return uselesstile
+