naughty: new argument 'width' in notify()
Signed-off-by: Sébastien Gross <seb@chezwam.org> Signed-off-by: koniu <gkusnierz@gmail.com>
This commit is contained in:
parent
cccd04b2c4
commit
65d5e29141
|
@ -70,6 +70,7 @@ config.hover_timeout = nil
|
||||||
-- Each element is a table consisting of:
|
-- Each element is a table consisting of:
|
||||||
-- @field box Wibox object containing the popup
|
-- @field box Wibox object containing the popup
|
||||||
-- @field height Popup height
|
-- @field height Popup height
|
||||||
|
-- @field width Popup width
|
||||||
-- @field die Function to be executed on timeout
|
-- @field die Function to be executed on timeout
|
||||||
-- @name notifications[position]
|
-- @name notifications[position]
|
||||||
-- @class table
|
-- @class table
|
||||||
|
@ -85,17 +86,19 @@ notifications = {
|
||||||
-- @param idx Index of the notification
|
-- @param idx Index of the notification
|
||||||
-- @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)
|
||||||
-- @return Absolute position in {x, y} dictionary
|
-- @return Absolute position in {x, y} dictionary
|
||||||
|
|
||||||
local function get_offset(idx, position, height)
|
local function get_offset(idx, position, height, width)
|
||||||
local ws = capi.screen[config.screen].workarea
|
local ws = capi.screen[config.screen].workarea
|
||||||
local v = {}
|
local v = {}
|
||||||
|
width = width or notifications[position][idx].width or config.width
|
||||||
|
|
||||||
-- calculate x
|
-- calculate x
|
||||||
if position:match("left") then
|
if position:match("left") then
|
||||||
v.x = ws.x + config.padding
|
v.x = ws.x + config.padding
|
||||||
else
|
else
|
||||||
v.x = ws.x + ws.width - (config.width + config.border_width*2 + config.padding)
|
v.x = ws.x + ws.width - (width + config.border_width*2 + config.padding)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- calculate existing popups' height
|
-- calculate existing popups' height
|
||||||
|
@ -127,7 +130,8 @@ local function arrange()
|
||||||
for p,pos in pairs(notifications) do
|
for p,pos in pairs(notifications) do
|
||||||
for i,notification in pairs(notifications[p]) do
|
for i,notification in pairs(notifications[p]) do
|
||||||
local offset = get_offset(i, p, notification.height)
|
local offset = get_offset(i, p, notification.height)
|
||||||
notification.box:geometry({ x = offset.x, y = offset.y, width = config.width, height = notification.height })
|
local width = notification.width
|
||||||
|
notification.box:geometry({ x = offset.x, y = offset.y, width = width, height = notification.height })
|
||||||
notification.idx = i
|
notification.idx = i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -159,6 +163,7 @@ end
|
||||||
-- @param screen Target screen for the notification
|
-- @param screen Target screen for the notification
|
||||||
-- @param ontop Target screen for the notification
|
-- @param ontop Target screen for the notification
|
||||||
-- @param run Function to run on left click
|
-- @param run Function to run on left click
|
||||||
|
-- @param width The popup width
|
||||||
-- @usage naughty.notify({ title = 'Achtung!', text = 'You\'re idling', timeout = 0 })
|
-- @usage naughty.notify({ title = 'Achtung!', text = 'You\'re idling', timeout = 0 })
|
||||||
function notify(args)
|
function notify(args)
|
||||||
-- gather variables together
|
-- gather variables together
|
||||||
|
@ -168,6 +173,7 @@ function notify(args)
|
||||||
local text = args.text or ""
|
local text = args.text or ""
|
||||||
local screen = args.screen or config.screen
|
local screen = args.screen or config.screen
|
||||||
local ontop = args.ontop or config.ontop
|
local ontop = args.ontop or config.ontop
|
||||||
|
local width = args.width or config.width
|
||||||
|
|
||||||
local notification = {}
|
local notification = {}
|
||||||
notification.position = args.position or config.position
|
notification.position = args.position or config.position
|
||||||
|
@ -225,8 +231,9 @@ function notify(args)
|
||||||
notification.height = iconbox.image.height
|
notification.height = iconbox.image.height
|
||||||
else
|
else
|
||||||
notification.height = lines * config.height end
|
notification.height = lines * config.height end
|
||||||
local offset = get_offset(notification.idx, notification.position, notification.height)
|
notification.width = width
|
||||||
notification.box:geometry({ width = config.width,
|
local offset = get_offset(notification.idx, notification.position, notification.height, notification.width)
|
||||||
|
notification.box:geometry({ width = width,
|
||||||
height = notification.height,
|
height = notification.height,
|
||||||
x = offset.x,
|
x = offset.x,
|
||||||
y = offset.y })
|
y = offset.y })
|
||||||
|
|
Loading…
Reference in New Issue