Hi, here is a set of patches that results into stackable wiboxes when using with awful.wibox
The first patch fixes the x,y position of wiboxes when stretched, which is the default for awful.wibox: I had gaps between vertical and horizontal stretched wiboxes with borders (borders were the issue because of the way wibox x and y are calculated) The second one fixes what I think is an error (but I may be wrong, it depends on the intention of the original coder): clients should take into account wibox borders and not recover them. Thus, struts had to be corrected: again I may have missed something here, but it felt wrong The third is the new feature: stackable wiboxes. When you add a wibox using awful.wibox, it will be stacked after the last one at the same position (top, bottom, left or right). I guess we should have a way to easily move wiboxes order, but I wanted to have a feedback first. Why stackable wiboxes ? because: 1/ it's easier than dealing with widget layouts 2/ calling several times awful.wibox for the same position recovers the previous wibox but with the re-parenting stuff currently developed, I don't know if it is still relevant. let me know if you find it useful or not Pierre
From bce9137482705c13a1dc7a6455bbbba85907c3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= <[email protected]> Date: Fri, 19 Mar 2010 03:17:20 +0100 Subject: [PATCH 1/3] fix wibox origin when stretched MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière <[email protected]> --- lib/awful/wibox.lua.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in index cbc86dc..cce9cdf 100644 --- a/lib/awful/wibox.lua.in +++ b/lib/awful/wibox.lua.in @@ -194,10 +194,10 @@ function stretch(wibox, screen) local area = capi.screen[screen].workarea if position == "right" or position == "left" then wibox.height = area.height - (2 * wibox.border_width) - align(wibox, "center") + wibox.y = area.y else wibox.width = area.width - (2 * wibox.border_width) - align(wibox, "left") + wibox.x = area.x end end end -- 1.7.0
From e29feb7893f3f1fae06c17276cebc8f1016b6a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= <[email protected]> Date: Fri, 19 Mar 2010 03:19:14 +0100 Subject: [PATCH 2/3] Avoid wibox borders to be recovered by clients MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière <[email protected]> --- lib/awful/wibox.lua.in | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in index cce9cdf..bad2e6f 100644 --- a/lib/awful/wibox.lua.in +++ b/lib/awful/wibox.lua.in @@ -88,13 +88,13 @@ local function wibox_update_strut(wibox) if not wibox.visible then wibox:struts { left = 0, right = 0, bottom = 0, top = 0 } elseif wprop.position == "top" then - wibox:struts { left = 0, right = 0, bottom = 0, top = wibox.height + wibox.border_width } + wibox:struts { left = 0, right = 0, bottom = 0, top = wibox.height + 2 * wibox.border_width } elseif wprop.position == "bottom" then - wibox:struts { left = 0, right = 0, bottom = wibox.height + wibox.border_width, top = 0 } + wibox:struts { left = 0, right = 0, bottom = wibox.height + 2 * wibox.border_width, top = 0 } elseif wprop.position == "left" then - wibox:struts { left = wibox.width + wibox.border_width, right = 0, bottom = 0, top = 0 } + wibox:struts { left = wibox.width + 2 * wibox.border_width, right = 0, bottom = 0, top = 0 } elseif wprop.position == "right" then - wibox:struts { left = 0, right = wibox.width + wibox.border_width, bottom = 0, top = 0 } + wibox:struts { left = 0, right = wibox.width + 2 * wibox.border_width, bottom = 0, top = 0 } end break end -- 1.7.0
From 27cea77928835892a8e0db28152291054bc2c056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= <[email protected]> Date: Fri, 19 Mar 2010 03:27:20 +0100 Subject: [PATCH 3/3] Add stackable wiboxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière <[email protected]> --- lib/awful/wibox.lua.in | 39 +++++++++++++++++++++++++++++++-------- 1 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in index bad2e6f..7cca886 100644 --- a/lib/awful/wibox.lua.in +++ b/lib/awful/wibox.lua.in @@ -49,18 +49,36 @@ end function set_position(wibox, position, screen) local screen = screen or wibox.screen or 1 local area = capi.screen[screen].geometry + local current_strut = 0 + + -- The current_strut is defined by the existing wiboxes at the given + -- position + for i, wprop in ipairs(wiboxes) do + if wprop.wibox.visible and wprop.position == position then + if wprop.wibox ~= wibox then + if position == "right" or position == "left" then + current_strut = current_strut + wprop.wibox.width + elseif position == "top" or position == "bottom" then + current_strut = current_strut + wprop.wibox.height + end + current_strut = current_strut + 2 * wprop.wibox.border_width + else + break + end + end + end -- The "length" of a wibox is always chosen to be the optimal size -- (non-floating). -- The "width" of a wibox is kept if it exists. if position == "right" then - wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) + wibox.x = area.x + area.width - (current_strut + wibox.width + 2 * wibox.border_width) elseif position == "left" then - wibox.x = area.x + wibox.x = area.x + current_strut elseif position == "bottom" then - wibox.y = (area.y + area.height) - (wibox.height + 2 * wibox.border_width) + wibox.y = (area.y + area.height) - (current_strut + wibox.height + 2 * wibox.border_width) elseif position == "top" then - wibox.y = area.y + wibox.y = area.y + current_strut end for _, wprop in ipairs(wiboxes) do @@ -83,18 +101,21 @@ local function call_wibox_position_hook_on_prop_update(w) end local function wibox_update_strut(wibox) + local screen = screen or wibox.screen or 1 + local area = capi.screen[screen].geometry + for _, wprop in ipairs(wiboxes) do if wprop.wibox == wibox then if not wibox.visible then wibox:struts { left = 0, right = 0, bottom = 0, top = 0 } elseif wprop.position == "top" then - wibox:struts { left = 0, right = 0, bottom = 0, top = wibox.height + 2 * wibox.border_width } + wibox:struts { left = 0, right = 0, bottom = 0, top = wibox.y + wibox.height + 2 * wibox.border_width } elseif wprop.position == "bottom" then - wibox:struts { left = 0, right = 0, bottom = wibox.height + 2 * wibox.border_width, top = 0 } + wibox:struts { left = 0, right = 0, bottom = area.y + area.height - wibox.y, top = 0} elseif wprop.position == "left" then - wibox:struts { left = wibox.width + 2 * wibox.border_width, right = 0, bottom = 0, top = 0 } + wibox:struts { left = wibox.x + wibox.width + 2 * wibox.border_width, right = 0, bottom = 0, top = 0 } elseif wprop.position == "right" then - wibox:struts { left = 0, right = wibox.width + 2 * wibox.border_width, bottom = 0, top = 0 } + wibox:struts { left = 0, right = area.x + area.width - wibox.x } end break end @@ -128,6 +149,8 @@ function attach(wibox, position) wibox_prop_table.position = position end + wibox:add_signal("property::x", wibox_update_strut) + wibox:add_signal("property::y", wibox_update_strut) wibox:add_signal("property::width", wibox_update_strut) wibox:add_signal("property::height", wibox_update_strut) wibox:add_signal("property::visible", wibox_update_strut) -- 1.7.0
