fix(lib: naughty: core): make it work with textbox per-screen dpi

Closes https://github.com/awesomeWM/awesome/pull/464.
This commit is contained in:
actionless 2015-09-21 23:59:35 +02:00 committed by Daniel Hahler
parent 28ffdb050e
commit f2e554de91
1 changed files with 5 additions and 3 deletions

View File

@ -454,6 +454,8 @@ function naughty.notify(args)
local border_color = args.border_color or preset.border_color or beautiful.bg_focus or '#535d6c' local border_color = args.border_color or preset.border_color or beautiful.bg_focus or '#535d6c'
local notification = { screen = screen, destroy_cb = destroy_cb, timeout = timeout } local notification = { screen = screen, destroy_cb = destroy_cb, timeout = timeout }
local textbox_context = {dpi=bt.xresources.get_dpi(s)}
-- replace notification if needed -- replace notification if needed
if args.replaces_id then if args.replaces_id then
local obj = naughty.getById(args.replaces_id) local obj = naughty.getById(args.replaces_id)
@ -526,7 +528,7 @@ function naughty.notify(args)
actiontextbox:set_font(font) actiontextbox:set_font(font)
actiontextbox:set_markup(string.format('<b>%s</b>', action)) actiontextbox:set_markup(string.format('<b>%s</b>', action))
-- calculate the height and width -- calculate the height and width
local w, h = actiontextbox:fit(nil, -1, -1) -- Hack! :( local w, h = actiontextbox:fit(textbox_context, -1, -1) -- Hack! :(
local height = h + 2 * margin local height = h + 2 * margin
local width = w + 2 * margin local width = w + 2 * margin
@ -596,7 +598,7 @@ function naughty.notify(args)
-- calculate the height -- calculate the height
if not height then if not height then
local w, h = textbox:fit(nil, -1, -1) -- Hack! :-( local w, h = textbox:fit(textbox_context, -1, -1) -- Hack! :-(
if iconbox and icon_h + 2 * margin > h + 2 * margin then if iconbox and icon_h + 2 * margin > h + 2 * margin then
height = icon_h + 2 * margin height = icon_h + 2 * margin
else else
@ -608,7 +610,7 @@ function naughty.notify(args)
-- calculate the width -- calculate the width
if not width then if not width then
local w, h = textbox:fit(nil, -1, -1) -- Hack! :-( local w, h = textbox:fit(textbox_context, -1, -1) -- Hack! :-(
width = w + (iconbox and icon_w + 2 * margin or 0) + 2 * margin width = w + (iconbox and icon_w + 2 * margin or 0) + 2 * margin
end end