Avoid cyclic dependency between awful and menubar (#1433)

This commit is contained in:
Yauhen Kirylau 2017-01-23 22:51:41 +01:00 committed by Daniel Hahler
parent 519b65ee14
commit f9975f763c
2 changed files with 3 additions and 7 deletions

View file

@ -15,7 +15,6 @@ local awful = require("awful")
local wibox = require("wibox")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
local compute_textbox_width = require("menubar").utils.compute_textbox_width
-- Stripped copy of this module https://github.com/copycat-killer/lain/blob/master/util/markup.lua:
@ -290,8 +289,8 @@ function widget.new()
joined_labels = joined_labels .. rendered_hotkey .. (i~=#_keys and "\n" or "")
end
current_column.layout:add(wibox.widget.textbox(joined_labels))
local max_width = compute_textbox_width(wibox.widget.textbox(max_label_content), s) +
widget_instance.group_margin
local max_width, _ = wibox.widget.textbox(max_label_content):get_preferred_size(s)
max_width = max_width + widget_instance.group_margin
if not current_column.max_width or max_width > current_column.max_width then
current_column.max_width = max_width
end

View file

@ -293,11 +293,8 @@ function utils.parse_dir(dir_path, callback)
end)()
end
--- Compute textbox width.
-- @tparam wibox.widget.textbox textbox Textbox instance.
-- @tparam number|screen s Screen
-- @treturn int Text width.
function utils.compute_textbox_width(textbox, s)
awful_util.deprecate("Use 'width, _ = textbox:get_preferred_size(s)' directly.")
s = screen[s or mouse.screen]
local w, _ = textbox:get_preferred_size(s)
return w