From f9975f763c818e13cf21ebcc2184b4acd8b2774f Mon Sep 17 00:00:00 2001 From: Yauhen Kirylau Date: Mon, 23 Jan 2017 22:51:41 +0100 Subject: [PATCH] Avoid cyclic dependency between awful and menubar (#1433) --- lib/awful/hotkeys_popup/widget.lua | 5 ++--- lib/menubar/utils.lua | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/awful/hotkeys_popup/widget.lua b/lib/awful/hotkeys_popup/widget.lua index cf4a5a36..5a0e0a8c 100644 --- a/lib/awful/hotkeys_popup/widget.lua +++ b/lib/awful/hotkeys_popup/widget.lua @@ -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 diff --git a/lib/menubar/utils.lua b/lib/menubar/utils.lua index 6f80e860..596dea57 100644 --- a/lib/menubar/utils.lua +++ b/lib/menubar/utils.lua @@ -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