feat(lib: menubar): dpi support in menubar
Closes https://github.com/awesomeWM/awesome/pull/580.
This commit is contained in:
parent
f6d08274a6
commit
eb8577a424
|
@ -123,25 +123,25 @@ end
|
||||||
-- @tparam table all_items All items list.
|
-- @tparam table all_items All items list.
|
||||||
-- @tparam str query Search query.
|
-- @tparam str query Search query.
|
||||||
-- @return table List of items for current page.
|
-- @return table List of items for current page.
|
||||||
local function get_current_page(all_items, query)
|
local function get_current_page(all_items, query, scr)
|
||||||
if not instance.prompt.width then
|
if not instance.prompt.width then
|
||||||
instance.prompt.width = compute_text_width(instance.prompt.prompt)
|
instance.prompt.width = compute_text_width(instance.prompt.prompt, scr)
|
||||||
end
|
end
|
||||||
if not menubar.left_label_width then
|
if not menubar.left_label_width then
|
||||||
menubar.left_label_width = compute_text_width(menubar.left_label)
|
menubar.left_label_width = compute_text_width(menubar.left_label, scr)
|
||||||
end
|
end
|
||||||
if not menubar.right_label_width then
|
if not menubar.right_label_width then
|
||||||
menubar.right_label_width = compute_text_width(menubar.right_label)
|
menubar.right_label_width = compute_text_width(menubar.right_label, scr)
|
||||||
end
|
end
|
||||||
local available_space = instance.geometry.width - menubar.right_margin -
|
local available_space = instance.geometry.width - menubar.right_margin -
|
||||||
menubar.right_label_width - menubar.left_label_width -
|
menubar.right_label_width - menubar.left_label_width -
|
||||||
compute_text_width(query) - instance.prompt.width
|
compute_text_width(query, scr) - instance.prompt.width
|
||||||
|
|
||||||
local width_sum = 0
|
local width_sum = 0
|
||||||
local current_page = {}
|
local current_page = {}
|
||||||
for i, item in ipairs(all_items) do
|
for i, item in ipairs(all_items) do
|
||||||
item.width = item.width or
|
item.width = item.width or
|
||||||
compute_text_width(" " .. item.name) +
|
compute_text_width(" " .. item.name, scr) +
|
||||||
(item.icon and instance.geometry.height or 0)
|
(item.icon and instance.geometry.height or 0)
|
||||||
if width_sum + item.width > available_space then
|
if width_sum + item.width > available_space then
|
||||||
if current_item < i then
|
if current_item < i then
|
||||||
|
@ -160,7 +160,7 @@ end
|
||||||
|
|
||||||
--- Update the menubar according to the command entered by user.
|
--- Update the menubar according to the command entered by user.
|
||||||
-- @tparam str query Search query.
|
-- @tparam str query Search query.
|
||||||
local function menulist_update(query)
|
local function menulist_update(query, scr)
|
||||||
query = query or ""
|
query = query or ""
|
||||||
shownitems = {}
|
shownitems = {}
|
||||||
local pattern = awful.util.query_to_pattern(query)
|
local pattern = awful.util.query_to_pattern(query)
|
||||||
|
@ -221,7 +221,7 @@ local function menulist_update(query)
|
||||||
|
|
||||||
common.list_update(common_args.w, nil, label,
|
common.list_update(common_args.w, nil, label,
|
||||||
common_args.data,
|
common_args.data,
|
||||||
get_current_page(shownitems, query))
|
get_current_page(shownitems, query, scr))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create the menubar wibox and widgets.
|
--- Create the menubar wibox and widgets.
|
||||||
|
@ -308,7 +308,7 @@ function menubar.show(scr)
|
||||||
|
|
||||||
current_item = 1
|
current_item = 1
|
||||||
current_category = nil
|
current_category = nil
|
||||||
menulist_update()
|
menulist_update(nil, scr)
|
||||||
|
|
||||||
local prompt_args = menubar.prompt_args or {}
|
local prompt_args = menubar.prompt_args or {}
|
||||||
prompt_args.prompt = "Run: "
|
prompt_args.prompt = "Run: "
|
||||||
|
@ -316,7 +316,9 @@ function menubar.show(scr)
|
||||||
function(s) end, -- exe_callback function set to do nothing
|
function(s) end, -- exe_callback function set to do nothing
|
||||||
awful.completion.shell, -- completion_callback
|
awful.completion.shell, -- completion_callback
|
||||||
awful.util.getdir("cache") .. "/history_menu",
|
awful.util.getdir("cache") .. "/history_menu",
|
||||||
nil, menubar.hide, menulist_update, prompt_keypressed_callback
|
nil,
|
||||||
|
menubar.hide, function(query) menulist_update(query, scr) end,
|
||||||
|
prompt_keypressed_callback
|
||||||
)
|
)
|
||||||
instance.wibox.visible = true
|
instance.wibox.visible = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue