Merge pull request #730 from actionless/fix-menubar-pagination-again

fix(lib: menubar): take in account common list padding
This commit is contained in:
Daniel Hahler 2016-03-03 22:15:11 +01:00
commit a1687dc72e
1 changed files with 7 additions and 3 deletions

View File

@ -61,7 +61,7 @@ menubar.geometry = { width = nil,
y = nil }
--- Width of blank space left in the right side.
menubar.right_margin = 50
menubar.right_margin = theme.xresources.apply_dpi(8)
--- Label used for "Next page", default "▶▶".
menubar.right_label = "▶▶"
@ -69,6 +69,10 @@ menubar.right_label = "▶▶"
--- Label used for "Previous page", default "◀◀".
menubar.left_label = "◀◀"
-- awful.widget.common.list_update adds three times a margin of dpi(4)
-- for each item:
local list_interspace = theme.xresources.apply_dpi(4) * 3
--- Allows user to specify custom parameters for prompt.run function
-- (like colors).
menubar.prompt_args = {}
@ -147,8 +151,8 @@ local function get_current_page(all_items, query, scr)
local current_page = {}
for i, item in ipairs(all_items) do
item.width = item.width or
compute_text_width(" " .. item.name, scr) +
(item.icon and instance.geometry.height or 0)
compute_text_width(item.name, scr) +
(item.icon and instance.geometry.height or 0) + list_interspace
if width_sum + item.width > available_space then
if current_item < i then
table.insert(current_page, { name = menubar.right_label, icon = nil })