Hi all,
this is the hopefully final fix to the horizontal.center width inside a
vertical.topdown with width (in vertical, width is height :) set etc.
(combinations are many, the same actually happens if you put
horizontal.rightleft in there, which previous fix didn't handle). It
simply always sets total.width to widgets.width if present.
cheers
lukash
>From e74eda8d1dc24fe9f9ec0e304a1b71cc204f5ca0 Mon Sep 17 00:00:00 2001
From: Lukas Hrazky <[email protected]>
Date: Wed, 28 Oct 2009 11:49:08 +0100
Subject: [PATCH] widget layouts: always set widgets.height as total
Signed-off-by: Lukas Hrazky <[email protected]>
---
lib/awful/widget/layout/horizontal.lua.in | 9 ++-------
lib/awful/widget/layout/linear_common.lua.in | 12 ++++--------
lib/awful/widget/layout/vertical.lua.in | 9 ++-------
3 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/lib/awful/widget/layout/horizontal.lua.in b/lib/awful/widget/layout/horizontal.lua.in
index ed22806..ab7a9ac 100644
--- a/lib/awful/widget/layout/horizontal.lua.in
+++ b/lib/awful/widget/layout/horizontal.lua.in
@@ -66,13 +66,8 @@ function center(bounds, widgets, screen)
for _, w in ipairs(g) do
w.x = w.x + (bounds.width - g.total.width) / 2
end
- -- if width is set for widgets table, make total this wide,
- -- otherwise move total.x to reflect new position
- if widgets.width then
- g.total.width = widgets.width
- else
- g.total.x = g.total.x + (bounds.width - g.total.width) / 2
- end
+ g.total.x = 0
+ g.total.width = 0
return g
end
diff --git a/lib/awful/widget/layout/linear_common.lua.in b/lib/awful/widget/layout/linear_common.lua.in
index b431c05..90c3966 100644
--- a/lib/awful/widget/layout/linear_common.lua.in
+++ b/lib/awful/widget/layout/linear_common.lua.in
@@ -78,12 +78,8 @@ function linear_common.fixed(idx, bounds, widgets, screen)
v.width = t_width
v.height = t_height
- -- subtract the space taken by the table from our bounds - only if the taken space
- -- is either on the left or on the right of our bounds (not in the middle)
- if g.total[idx.x] == bounds[idx.x] or
- g.total[idx.x] + g.total[idx.width] == bounds[idx.x] + bounds[idx.width] then
- bounds[idx.width] = bounds[idx.width] - g.total[idx.width]
- end
+ -- subtract the space taken by the table from our bounds
+ bounds[idx.width] = bounds[idx.width] - g.total[idx.width]
-- we only move the 'x' coord if the taken space is on the left side of our bounds
if g.total[idx.x] == bounds[idx.x] then
bounds[idx.x] = bounds[idx.x] + g.total[idx.width] + m[idx.right]
@@ -141,7 +137,7 @@ function linear_common.fixed(idx, bounds, widgets, screen)
-- calculate the total space taken by the widgets
geometries.total[idx.width] = geometries.total[idx.width] - bounds[idx.width]
- geometries.total[idx.height] = maxh
+ geometries.total[idx.height] = widgets[idx.height] or maxh
-- if the bounds are on the left of what was empty in the beginning of this function,
-- we move the total to the right. this, however, most probably happened cos of rightleft layout
-- inside 'widgets', and only if there was nothing aligned to the left
@@ -280,7 +276,7 @@ function linear_common.flex(idx, bounds, widgets, screen)
-- we have total already from the cloned bounds, just set the height to what we got
geometries.total[idx.width] = geometries.total[idx.width] - bounds[idx.width]
- geometries.total[idx.height] = maxh
+ geometries.total[idx.height] = widgets[idx.height] or maxh
return geometries
end
diff --git a/lib/awful/widget/layout/vertical.lua.in b/lib/awful/widget/layout/vertical.lua.in
index 0e51bcc..c706147 100644
--- a/lib/awful/widget/layout/vertical.lua.in
+++ b/lib/awful/widget/layout/vertical.lua.in
@@ -68,13 +68,8 @@ function center(bounds, widgets, screen)
for _, w in ipairs(g) do
w.y = w.y + (bounds.height - g.total.height) / 2
end
- -- if height is set for widgets table, make total this wide,
- -- otherwise move total.y to reflect new position
- if widgets.height then
- g.total.height = widgets.height
- else
- g.total.y = g.total.y + (bounds.height - g.total.height) / 2
- end
+ g.total.y = 0
+ g.total.height = 0
return g
end
--
1.6.5