naughty: Use :get_height_for_width()
This changes the code in naughty so that it first decides on a width for the notification and then uses the new function :get_height_for_width() to find a suitable height. This makes a difference in the following example where before this change the text is cut off and afterwards it is shown completely: naughty.notify({ text = string.rep("abcdefghijklmnopqrstuvwxyz\n", 4), width = 75 }) Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
fcfed22d8a
commit
4577e32a38
|
@ -598,18 +598,6 @@ function naughty.notify(args)
|
||||||
|
|
||||||
if hover_timeout then notification.box:connect_signal("mouse::enter", hover_destroy) end
|
if hover_timeout then notification.box:connect_signal("mouse::enter", hover_destroy) end
|
||||||
|
|
||||||
-- calculate the height
|
|
||||||
if not height then
|
|
||||||
local w, h = textbox:get_preferred_size(s)
|
|
||||||
if iconbox and icon_h + 2 * margin > h + 2 * margin then
|
|
||||||
height = icon_h + 2 * margin
|
|
||||||
else
|
|
||||||
height = h + 2 * margin
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
height = height + actions_total_height
|
|
||||||
|
|
||||||
-- calculate the width
|
-- calculate the width
|
||||||
if not width then
|
if not width then
|
||||||
local w, h = textbox:get_preferred_size(s)
|
local w, h = textbox:get_preferred_size(s)
|
||||||
|
@ -620,6 +608,19 @@ function naughty.notify(args)
|
||||||
width = actions_max_width
|
width = actions_max_width
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- calculate the height
|
||||||
|
if not height then
|
||||||
|
local w = width - (iconbox and icon_w + 2 * margin or 0) - 2 * margin
|
||||||
|
local h = textbox:get_height_for_width(w, s)
|
||||||
|
if iconbox and icon_h + 2 * margin > h + 2 * margin then
|
||||||
|
height = icon_h + 2 * margin
|
||||||
|
else
|
||||||
|
height = h + 2 * margin
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
height = height + actions_total_height
|
||||||
|
|
||||||
-- crop to workarea size if too big
|
-- crop to workarea size if too big
|
||||||
local workarea = capi.screen[screen].workarea
|
local workarea = capi.screen[screen].workarea
|
||||||
if width > workarea.width - 2 * (border_width or 0) - 2 * (naughty.config.padding or 0) then
|
if width > workarea.width - 2 * (border_width or 0) - 2 * (naughty.config.padding or 0) then
|
||||||
|
|
Loading…
Reference in New Issue