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
authorworron <worrongm@gmail.com>
Mon, 5 Jan 2015 22:53:09 +0000 (01:53 +0300)
committerworron <worrongm@gmail.com>
Mon, 5 Jan 2015 22:53:09 +0000 (01:53 +0300)
layout/uselesstile.lua

index 65ce9b5ef9a88f351582c26d4a3684d0fc0de2ec..5bb0c05b3a570e89f0fdb816234be7b6bf6e8959 100644 (file)
@@ -1,12 +1,12 @@
 
 --[[
-                                                  
-     Licensed under GNU General Public License v2 
-      * (c) 2014       projektile                 
-      * (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")
@@ -19,16 +19,7 @@ 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) 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
+local function tile_group(cls, wa, orientation, fact, group, gap)
 
     -- Themes border width requires an offset
     local bw = tonumber(beautiful.border_width) or 0
@@ -69,58 +60,28 @@ local function tile_group(cls, wa, orientation, fact, group)
         end
         total_fact = total_fact + fact[i]
     end
-    size = math.min(size, (available - global_border))
+    size = math.min(size, available)
     local coord = wa[y]
     local geom = {}
     local used_size = 0
-    local unused = wa[height] - (global_border * 2)
+    local unused = wa[height]
     local stat_coord = wa[x]
     --stat_coord = size
     for c = group.first,group.last do
         local i = c - group.first +1
-        geom[width] = size - global_border - (bw * 2)
+        geom[width] = size - (bw * 2)
         geom[height] = math.floor(unused * fact[i] / total_fact) - (bw * 2)
-        geom[x] = group.coord + global_border
-        geom[y] = coord + global_border
+        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
-
-            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
+        used_size = math.max(used_size, geom[width] + 2 * bw)
 
-            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
@@ -132,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"
@@ -152,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
@@ -176,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
@@ -196,7 +173,7 @@ local function tile(param, orientation)
                 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