titlebar: Implement setting the font (as documented, but unimplemented)

It was documented to exist, but didn't.
This commit is contained in:
Emmanuel Lepage Vallee 2021-10-25 20:22:42 -07:00
parent c36a869ded
commit 907053f31a
1 changed files with 18 additions and 0 deletions

View File

@ -583,6 +583,7 @@ local function new(c, args)
bars[position] = { bars[position] = {
args = args, args = args,
drawable = ret, drawable = ret,
font = args.font or beautiful.titlebar_font,
update_colors = update_colors update_colors = update_colors
} }
@ -683,6 +684,20 @@ local function update_on_signal(c, signal, widget)
table.insert(widgets, widget) table.insert(widgets, widget)
end end
--- Honor the font.
local function draw_title(self, ctx, cr, width, height)
if ctx.position and ctx.client then
local bars = all_titlebars[ctx.client]
local data = bars and bars[ctx.position]
if data and data.font then
self:set_font(data.font)
end
end
textbox.draw(self, ctx, cr, width, height)
end
--- Create a new title widget. --- Create a new title widget.
-- --
-- A title widget displays the name of a client. -- A title widget displays the name of a client.
@ -694,6 +709,9 @@ end
-- @constructorfct awful.titlebar.widget.titlewidget -- @constructorfct awful.titlebar.widget.titlewidget
function titlebar.widget.titlewidget(c) function titlebar.widget.titlewidget(c)
local ret = textbox() local ret = textbox()
rawset(ret, "draw", draw_title)
local function update() local function update()
ret:set_text(c.name or titlebar.fallback_name) ret:set_text(c.name or titlebar.fallback_name)
end end