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:
koniu 2009-05-08 12:08:09 +01:00 committed by Julien Danjou
parent 5039c24ed0
commit 35cd125ebd
1 changed files with 6 additions and 4 deletions

View File

@ -153,11 +153,12 @@ end
-- @param position top_right | top_left | bottom_right | bottom_left
-- @param height Popup height
-- @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 ws = capi.screen[screen].workarea
local v = {}
width = width or notifications[screen][position][idx].width or config.width
local idx = idx or #notifications[screen][position] + 1
-- calculate x
if position:match("left") then
@ -185,6 +186,7 @@ local function get_offset(screen, position, idx, width, height)
destroy(notifications[screen][position][1])
v = get_offset(screen, position, idx, width, height)
end
if not v.idx then v.idx = idx end
return v
end
@ -196,7 +198,7 @@ local function arrange(screen)
for i,notification in pairs(notifications[screen][p]) do
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.idx = i
notification.idx = offset.idx
end
end
end
@ -303,7 +305,6 @@ function notify(args)
end
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 = ""
if args.title then title = tostring(args.title) .. "\n" end
@ -376,7 +377,7 @@ function notify(args)
else
notification.height = lines * height end
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,
height = notification.height,
x = offset.x,
@ -384,6 +385,7 @@ function notify(args)
notification.box.ontop = ontop
notification.box.opacity = opacity
notification.box.screen = screen
notification.idx = offset.idx
-- populate widgets
notification.box.widgets = { iconbox, textbox }