naughty: fix bug in re-indexing popups if removing older to make space
Signed-off-by: koniu <gkusnierz@gmail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
5039c24ed0
commit
35cd125ebd
|
@ -153,11 +153,12 @@ end
|
||||||
-- @param position top_right | top_left | bottom_right | bottom_left
|
-- @param position top_right | top_left | bottom_right | bottom_left
|
||||||
-- @param height Popup height
|
-- @param height Popup height
|
||||||
-- @param width Popup width (optional)
|
-- @param width Popup width (optional)
|
||||||
-- @return Absolute position in {x, y} dictionary
|
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
|
||||||
local function get_offset(screen, position, idx, width, height)
|
local function get_offset(screen, position, idx, width, height)
|
||||||
local ws = capi.screen[screen].workarea
|
local ws = capi.screen[screen].workarea
|
||||||
local v = {}
|
local v = {}
|
||||||
width = width or notifications[screen][position][idx].width or config.width
|
width = width or notifications[screen][position][idx].width or config.width
|
||||||
|
local idx = idx or #notifications[screen][position] + 1
|
||||||
|
|
||||||
-- calculate x
|
-- calculate x
|
||||||
if position:match("left") then
|
if position:match("left") then
|
||||||
|
@ -185,6 +186,7 @@ local function get_offset(screen, position, idx, width, height)
|
||||||
destroy(notifications[screen][position][1])
|
destroy(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
|
||||||
|
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
@ -196,7 +198,7 @@ local function arrange(screen)
|
||||||
for i,notification in pairs(notifications[screen][p]) do
|
for i,notification in pairs(notifications[screen][p]) do
|
||||||
local offset = get_offset(screen, p, i, notification.width, notification.height)
|
local offset = get_offset(screen, p, i, notification.width, notification.height)
|
||||||
notification.box:geometry({ x = offset.x, y = offset.y, width = notification.width, height = notification.height })
|
notification.box:geometry({ x = offset.x, y = offset.y, width = notification.width, height = notification.height })
|
||||||
notification.idx = i
|
notification.idx = offset.idx
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -303,7 +305,6 @@ function notify(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
notification.position = args.position or (args.preset and args.preset.position) or config.presets.normal.position
|
notification.position = args.position or (args.preset and args.preset.position) or config.presets.normal.position
|
||||||
notification.idx = #notifications[screen][notification.position] + 1
|
|
||||||
|
|
||||||
local title = ""
|
local title = ""
|
||||||
if args.title then title = tostring(args.title) .. "\n" end
|
if args.title then title = tostring(args.title) .. "\n" end
|
||||||
|
@ -376,7 +377,7 @@ function notify(args)
|
||||||
else
|
else
|
||||||
notification.height = lines * height end
|
notification.height = lines * height end
|
||||||
notification.width = width
|
notification.width = width
|
||||||
local offset = get_offset(screen, notification.position, notification.idx, notification.width, notification.height)
|
local offset = get_offset(screen, notification.position, nil, notification.width, notification.height)
|
||||||
notification.box:geometry({ width = notification.width,
|
notification.box:geometry({ width = notification.width,
|
||||||
height = notification.height,
|
height = notification.height,
|
||||||
x = offset.x,
|
x = offset.x,
|
||||||
|
@ -384,6 +385,7 @@ function notify(args)
|
||||||
notification.box.ontop = ontop
|
notification.box.ontop = ontop
|
||||||
notification.box.opacity = opacity
|
notification.box.opacity = opacity
|
||||||
notification.box.screen = screen
|
notification.box.screen = screen
|
||||||
|
notification.idx = offset.idx
|
||||||
|
|
||||||
-- populate widgets
|
-- populate widgets
|
||||||
notification.box.widgets = { iconbox, textbox }
|
notification.box.widgets = { iconbox, textbox }
|
||||||
|
|
Loading…
Reference in New Issue