From: Luke Bonham Date: Tue, 15 Sep 2015 06:26:43 +0000 (+0200) Subject: Merge pull request #138 from InfinityTotality/master X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/63066fba60b919f51c0e66ac27a31201a166ef31?hp=6aca9e17306d260a4742318d994aee5b181e7aee Merge pull request #138 from InfinityTotality/master Many sizing fixes (closes #135) --- diff --git a/layout/cascade.lua b/layout/cascade.lua index 999c599..3d7598b 100644 --- a/layout/cascade.lua +++ b/layout/cascade.lua @@ -28,15 +28,12 @@ function cascade.arrange(p) local global_border = tonumber(beautiful.global_border_width) or 0 if global_border < 0 then global_border = 0 end - -- Themes border width requires an offset. - local bw = tonumber(beautiful.border_width) or 0 - -- Screen. local wa = p.workarea local cls = p.clients - wa.height = wa.height - ((global_border * 2) + (bw * 2)) - wa.width = wa.width - ((global_border * 2) + (bw * 2)) + wa.height = wa.height - (global_border * 2) + wa.width = wa.width - (global_border * 2) wa.x = wa.x + global_border wa.y = wa.y + global_border @@ -70,8 +67,10 @@ function cascade.arrange(p) 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 - g.height = wa.height - current_offset_y + g.width = wa.width - current_offset_x - 2*c.border_width + g.height = wa.height - current_offset_y - 2*c.border_width + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end c:geometry(g) end diff --git a/layout/cascadetile.lua b/layout/cascadetile.lua index e9b9425..3baf3e9 100644 --- a/layout/cascadetile.lua +++ b/layout/cascadetile.lua @@ -50,16 +50,15 @@ function cascadetile.arrange(p) local global_border = tonumber(beautiful.global_border_width) or 0 if global_border < 0 then global_border = 0 end - -- Themes border width requires an offset - local bw = tonumber(beautiful.border_width) or 0 - -- Screen. local wa = p.workarea local cls = p.clients -- Borders are factored in. - wa.height = wa.height - ((global_border * 2) + (bw * 2)) - wa.width = wa.width - ((global_border * 2) + (bw * 2)) + wa.height = wa.height - (global_border * 2) + wa.width = wa.width - (global_border * 2) + wa.x = wa.x + global_border + wa.y = wa.y + global_border -- Width of main column? local t = tag.selected(p.screen) @@ -100,14 +99,18 @@ function cascadetile.arrange(p) if #cls > 0 then -- Main column, fixed width and height. - local c = cls[#cls] + local c = cls[1] local g = {} - local mainwid = wa.width * mwfact + -- 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. + local mainwid = math.floor((wa.width - useless_gap) * mwfact) local slavewid = wa.width - mainwid if overlap_main == 1 then - g.width = wa.width + g.width = wa.width - 2*c.border_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 @@ -116,12 +119,12 @@ function cascadetile.arrange(p) -- overlapping everything else. g.width = g.width - cascadetile.extra_padding else - g.width = mainwid + g.width = mainwid - 2*c.border_width end - g.height = wa.height - g.x = wa.x + global_border - g.y = wa.y + global_border + g.height = wa.height - 2*c.border_width + g.x = wa.x + g.y = wa.y if useless_gap > 0 then -- Reduce width once and move window to the right. Reduce @@ -138,19 +141,21 @@ function cascadetile.arrange(p) g.width = g.width - useless_gap end end + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end c:geometry(g) -- Remaining clients stacked in slave column, new ones on top. if #cls > 1 then - for i = (#cls - 1),1,-1 + 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) * cascadetile.offset_x - g.y = wa.y + (i - 1) * cascadetile.offset_y + global_border + 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)) * cascadetile.offset_x + g.y = wa.y + (i - 2) * cascadetile.offset_y if useless_gap > 0 then g.width = g.width - 2 * useless_gap @@ -158,6 +163,8 @@ function cascadetile.arrange(p) 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 end diff --git a/layout/centerfair.lua b/layout/centerfair.lua index 1e8915d..5022726 100644 --- a/layout/centerfair.lua +++ b/layout/centerfair.lua @@ -49,16 +49,15 @@ function centerfair.arrange(p) local global_border = tonumber(beautiful.global_border_width) or 0 if global_border < 0 then global_border = 0 end - -- Themes border width requires an offset - local bw = tonumber(beautiful.border_width) or 0 - -- Screen. local wa = p.workarea local cls = p.clients -- Borders are factored in. - wa.height = wa.height - ((global_border * 2) + (bw * 2)) - wa.width = wa.width - ((global_border * 2) + (bw * 2)) + wa.height = wa.height - (global_border * 2) + wa.width = wa.width - (global_border * 2) + wa.x = wa.x + global_border + wa.y = wa.y + global_border -- How many vertical columns? Read from nmaster on the tag. local t = tag.selected(p.screen) @@ -66,36 +65,36 @@ function centerfair.arrange(p) local ncol = centerfair.ncol or tag.getncol(t) if num_x <= 2 then num_x = 2 end - local width = math.floor((wa.width-(num_x+1)*useless_gap) / num_x) + local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x) - local offset_y = wa.y + useless_gap if #cls < num_x then -- Less clients than the number of columns, let's center it! - local offset_x = wa.x + useless_gap + (wa.width - #cls*width - (#cls+1)*useless_gap) / 2 + local offset_x = wa.x + (wa.width - #cls*width - (#cls - 1)*useless_gap) / 2 local g = {} - g.width = width - g.height = wa.height - 2*useless_gap - 2 - g.y = offset_y + global_border + g.y = wa.y + useless_gap for i = 1, #cls do - g.x = offset_x + (#cls - i) * (width + useless_gap + 2) + global_border - cls[i]:geometry(g) + local c = cls[i] + g.width = width - 2*c.border_width + g.height = wa.height - 2*useless_gap - 2*c.border_width + 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) end else -- More clients than the number of columns, let's arrange it! - local offset_x = wa.x - if useless_gap > 0 then - offset_x = offset_x - end - -- Master client deserves a special treatement + local c = cls[1] local g = {} - g.width = wa.width - (num_x - 1) * width - num_x * 2*useless_gap - 2 - g.height = wa.height - 2*useless_gap - 2 - g.x = offset_x + useless_gap + global_border - g.y = offset_y + global_border + 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 + 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 - cls[#cls]:geometry(g) + c:geometry(g) -- Treat the other clients @@ -134,28 +133,30 @@ function centerfair.arrange(p) end -- Compute geometry of the other clients - local nclient = #cls-1 -- we start with the 2nd client - g.x = g.x + g.width+useless_gap + 2 - g.width = width - - if useless_gap > 0 then - g.width = g.width + useless_gap - 2 - end + local nclient = 2 -- we start with the 2nd client + g.x = g.x + g.width + useless_gap + 2*c.border_width for i = 1, (num_x-1) do - to_remove = 2 - g.height = math.floor((wa.height - (num_y[i] * useless_gap)) / num_y[i]) - g.y = offset_y + global_border + local height = math.floor((wa.height - (num_y[i] + 1)*useless_gap) / num_y[i]) + g.y = wa.y + useless_gap for j = 0, (num_y[i]-2) do - cls[nclient]:geometry(g) - nclient = nclient - 1 - g.y = g.y + g.height+useless_gap + 2 - to_remove = to_remove + 2 + local c = cls[nclient] + g.height = height - 2*c.border_width + g.width = width - 2*c.border_width + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + c:geometry(g) + nclient = nclient + 1 + g.y = g.y + height + useless_gap end - g.height = wa.height - num_y[i]*useless_gap - (num_y[i]-1)*g.height - useless_gap - to_remove - cls[nclient]:geometry(g) - nclient = nclient - 1 - g.x = g.x+g.width+useless_gap + 2 + 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 + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + c:geometry(g) + nclient = nclient + 1 + g.x = g.x + width + useless_gap end end end diff --git a/layout/centerwork.lua b/layout/centerwork.lua index 61f4907..98a3ac2 100644 --- a/layout/centerwork.lua +++ b/layout/centerwork.lua @@ -16,10 +16,10 @@ local math = { floor = math.floor } local centerwork = { name = "centerwork", - top_left = 0, - top_right = 1, + top_right = 0, + bottom_right = 1, bottom_left = 2, - bottom_right = 3 + top_left = 3 } function centerwork.arrange(p) @@ -32,16 +32,15 @@ function centerwork.arrange(p) local global_border = tonumber(beautiful.global_border_width) or 0 if global_border < 0 then global_border = 0 end - -- Themes border width requires an offset - local bw = tonumber(beautiful.border_width) or 0 - -- Screen. local wa = p.workarea local cls = p.clients -- Borders are factored in. - wa.height = wa.height - ((global_border * 2) + (bw * 2)) - wa.width = wa.width - ((global_border * 2) + (bw * 2)) + wa.height = wa.height - (global_border * 2) + wa.width = wa.width - (global_border * 2) + wa.x = wa.x + global_border + wa.y = wa.y + global_border -- Width of main column? local t = awful.tag.selected(p.screen) @@ -50,7 +49,7 @@ function centerwork.arrange(p) if #cls > 0 then -- Main column, fixed width and height. - local c = cls[#cls] + local c = cls[1] local g = {} local mainwid = math.floor(wa.width * mwfact) local slavewid = wa.width - mainwid @@ -59,10 +58,12 @@ function centerwork.arrange(p) local slaveThei = math.floor(wa.height / 2) local slaveBhei = wa.height - slaveThei - g.height = wa.height - 2 * useless_gap - g.width = mainwid - g.x = wa.x + slaveLwid + global_border - g.y = wa.y + useless_gap + global_border + g.height = wa.height - 2*useless_gap - 2*c.border_width + g.width = mainwid - 2*c.border_width + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + g.x = wa.x + slaveLwid + g.y = wa.y + useless_gap c:geometry(g) @@ -70,7 +71,7 @@ function centerwork.arrange(p) if #cls > 1 then local at = 0 - for i = (#cls - 1),1,-1 + for i = 2,#cls do -- It's all fixed. If there are more than 5 clients, -- those additional clients will float. This is @@ -83,36 +84,38 @@ function centerwork.arrange(p) c = cls[i] g = {} - if at == centerwork.top_left + if i - 2 == centerwork.top_left then -- top left - g.x = wa.x + useless_gap + global_border - g.y = wa.y + useless_gap + global_border - g.width = slaveLwid - 2 * useless_gap - g.height = slaveThei - useless_gap - elseif at == centerwork.top_right + g.x = wa.x + useless_gap + g.y = wa.y + useless_gap + g.width = slaveLwid - 2*useless_gap - 2*c.border_width + g.height = slaveThei - useless_gap - 2*c.border_width + elseif i - 2 == centerwork.top_right then -- top right - g.x = wa.x + slaveLwid + mainwid + useless_gap + global_border - g.y = wa.y + useless_gap + global_border - g.width = slaveRwid - 2 * useless_gap - g.height = slaveThei - useless_gap - elseif at == centerwork.bottom_left + g.x = wa.x + slaveLwid + mainwid + useless_gap + g.y = wa.y + useless_gap + g.width = slaveRwid - 2*useless_gap - 2*c.border_width + g.height = slaveThei - useless_gap - 2*c.border_width + elseif i - 2 == centerwork.bottom_left then -- bottom left - g.x = wa.x + useless_gap + global_border - g.y = wa.y + slaveThei + useless_gap + global_border - g.width = slaveLwid - 2 * useless_gap - g.height = slaveBhei - 2 * useless_gap - elseif at == centerwork.bottom_right + g.x = wa.x + useless_gap + g.y = wa.y + slaveThei + useless_gap + g.width = slaveLwid - 2*useless_gap - 2*c.border_width + g.height = slaveBhei - 2*useless_gap - 2*c.border_width + elseif i - 2 == centerwork.bottom_right then -- bottom right - g.x = wa.x + slaveLwid + mainwid + useless_gap + global_border - g.y = wa.y + slaveThei + useless_gap + global_border - g.width = slaveRwid - 2 * useless_gap - g.height = slaveBhei - 2 * useless_gap + g.x = wa.x + slaveLwid + mainwid + useless_gap + g.y = wa.y + slaveThei + useless_gap + g.width = slaveRwid - 2*useless_gap - 2*c.border_width + g.height = slaveBhei - 2*useless_gap - 2*c.border_width end + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end c:geometry(g) at = at + 1 diff --git a/layout/termfair.lua b/layout/termfair.lua index 4e45eec..6aca99d 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -46,16 +46,15 @@ function termfair.arrange(p) local global_border = tonumber(beautiful.global_border_width) or 0 if global_border < 0 then global_border = 0 end - -- Themes border width requires an offset - local bw = tonumber(beautiful.border_width) or 0 - -- Screen. local wa = p.workarea local cls = p.clients -- Borders are factored in. - wa.height = wa.height - ((global_border * 2) + (bw * 2)) - wa.width = wa.width - ((global_border * 2) + (bw * 2)) + wa.height = wa.height - (global_border * 2) + wa.width = wa.width - (global_border * 2) + wa.x = wa.x + global_border + wa.y = wa.y + global_border -- How many vertical columns? local t = tag.selected(p.screen) @@ -71,8 +70,8 @@ function termfair.arrange(p) local at_x = 0 local at_y = 0 local remaining_clients = #cls - local width = math.floor(wa.width / num_x) - local height = math.floor(wa.height / num_y) + local width = math.floor((wa.width - (num_x + 1)*useless_gap) / num_x) + local height = math.floor((wa.height - (num_y + 1)*useless_gap) / num_y) -- We start the first row. Left-align by limiting the number of -- available slots. @@ -93,27 +92,29 @@ function termfair.arrange(p) local g = {} if this_x == (num_x - 1) then - g.width = wa.width - (num_x - 1) * width - useless_gap + g.width = wa.width - (num_x - 1)*width - (num_x + 1)*useless_gap - 2*c.border_width else - g.width = width - useless_gap + g.width = width - 2*c.border_width end if this_y == (num_y - 1) then - g.height = wa.height - (num_y - 1) * height - useless_gap + g.height = wa.height - (num_y - 1)*height - (num_y + 1)*useless_gap - 2*c.border_width else - g.height = height - useless_gap + g.height = height - 2*c.border_width end - g.x = wa.x + this_x * width + global_border - g.y = wa.y + this_y * height + global_border + 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 + (useless_gap / 2) - g.y = g.y + (useless_gap / 2) + 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.height < 1 then g.height = 1 end c:geometry(g) remaining_clients = remaining_clients - 1 diff --git a/layout/uselesstile.lua b/layout/uselesstile.lua index e48c85d..c769d58 100644 --- a/layout/uselesstile.lua +++ b/layout/uselesstile.lua @@ -37,7 +37,7 @@ end -- Find geometry for secondary windows column local function cut_column(wa, n, index) - local width = wa.width / n + local width = math.floor(wa.width / n) local area = { x = wa.x + (index - 1) * width, y = wa.y, width = width, height = wa.height } return area @@ -45,7 +45,7 @@ end -- Find geometry for certain window in column local function cut_row(wa, factor, index, used) - local height = wa.height * factor.window[index] / factor.total + local height = math.floor(wa.height * factor.window[index] / factor.total) local area = { x = wa.x, y = wa.y + used, width = wa.width, height = height } return area @@ -55,8 +55,8 @@ end local function size_correction(c, geometry, useless_gap) geometry.width = math.max(geometry.width - 2 * c.border_width - useless_gap, 1) geometry.height = math.max(geometry.height - 2 * c.border_width - useless_gap, 1) - geometry.x = geometry.x + useless_gap / 2 - geometry.y = geometry.y + useless_gap / 2 + geometry.x = math.floor(geometry.x + useless_gap / 2) + geometry.y = math.floor(geometry.y + useless_gap / 2) end -- Check size factor for group of clients and calculate total @@ -85,6 +85,7 @@ local function tile_column(canvas, area, list, useless_gap, transformation, winf for i, c in ipairs(list) do local g = cut_row(area, factor, i, used) + if i == #list then g.height = area.height - used end used = used + g.height -- swap workarea dimensions @@ -94,6 +95,7 @@ local function tile_column(canvas, area, list, useless_gap, transformation, winf -- useless gap and border correction size_correction(c, g, useless_gap) + c:geometry(g) end end @@ -161,7 +163,7 @@ local function tile(p, orientation) local master_area = { x = wa.x, y = wa.y, - width = nmaster > 0 and wa.width * mwfact or 0, + width = nmaster > 0 and math.floor(wa.width * mwfact) or 0, height = wa.height } @@ -186,6 +188,7 @@ local function tile(p, orientation) local rows_min = math.floor(#cls_other / ncol) local client_index = 1 + local used = 0 for i = 1, ncol do local position = transformation.flip and ncol - i + 1 or i local rows = i <= last_small_column and rows_min or rows_min + 1 @@ -198,6 +201,8 @@ local function tile(p, orientation) -- and tile local column_area = cut_column(other_area, ncol, position) + if i == ncol then column_area.width = other_area.width - used end + used = used + column_area.width if not data[i] then data[i] = {} end tile_column(wa, column_area, column, useless_gap, transformation, data[i])