naughty: skip permanent notifications when there is no more room
This skips permanent notifications (with timeout=0) in `get_offset` when there is not enough room for a new notification. It will still fallback to removing the first/oldest one. Closes https://github.com/awesomeWM/awesome/pull/306.
This commit is contained in:
parent
173545bc72
commit
62f5e59497
|
@ -209,10 +209,24 @@ local function get_offset(screen, position, idx, width, height)
|
||||||
v.y = ws.y + ws.height - (naughty.config.padding + height + existing)
|
v.y = ws.y + ws.height - (naughty.config.padding + height + existing)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Find old notification to replace in case there is not enough room.
|
||||||
|
-- This tries to skip permanent notifications (without a timeout),
|
||||||
|
-- e.g. critical ones.
|
||||||
|
local find_old_to_replace = function()
|
||||||
|
for i = 1, idx-1 do
|
||||||
|
local n = naughty.notifications[screen][position][i]
|
||||||
|
if n.timeout > 0 then
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Fallback to first one.
|
||||||
|
return naughty.notifications[screen][position][1]
|
||||||
|
end
|
||||||
|
|
||||||
-- if positioned outside workarea, destroy oldest popup and recalculate
|
-- if positioned outside workarea, destroy oldest popup and recalculate
|
||||||
if v.y + height > ws.y + ws.height or v.y < ws.y then
|
if v.y + height > ws.y + ws.height or v.y < ws.y then
|
||||||
|
naughty.destroy(find_old_to_replace())
|
||||||
idx = idx - 1
|
idx = idx - 1
|
||||||
naughty.destroy(naughty.notifications[screen][position][1])
|
|
||||||
v = get_offset(screen, position, idx, width, height)
|
v = get_offset(screen, position, idx, width, height)
|
||||||
end
|
end
|
||||||
if not v.idx then v.idx = idx end
|
if not v.idx then v.idx = idx end
|
||||||
|
|
Loading…
Reference in New Issue