Merge pull request #147 from kmiller13/master

Add middle anchors for naughty notifications
This commit is contained in:
Daniel Hahler 2015-02-22 21:40:53 +01:00
commit 649b0ce52d
1 changed files with 7 additions and 1 deletions

View File

@ -108,8 +108,10 @@ naughty.notifications = { suspended = { } }
for s = 1, capi.screen.count() do for s = 1, capi.screen.count() do
naughty.notifications[s] = { naughty.notifications[s] = {
top_left = {}, top_left = {},
top_middle = {},
top_right = {}, top_right = {},
bottom_left = {}, bottom_left = {},
bottom_middle = {},
bottom_right = {}, bottom_right = {},
} }
end end
@ -141,6 +143,7 @@ end
-- Evaluate desired position of the notification by index - internal -- Evaluate desired position of the notification by index - internal
-- @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
-- | top_middle | bottom_middle
-- @param height Popup height -- @param height Popup height
-- @param width Popup width (optional) -- @param width Popup width (optional)
-- @return Absolute position and index in { x = X, y = Y, idx = I } table -- @return Absolute position and index in { x = X, y = Y, idx = I } table
@ -153,6 +156,8 @@ local function get_offset(screen, position, idx, width, height)
-- calculate x -- calculate x
if position:match("left") then if position:match("left") then
v.x = ws.x + naughty.config.padding v.x = ws.x + naughty.config.padding
elseif position:match("middle") then
v.x = (ws.width / 2) - (width / 2)
else else
v.x = ws.x + ws.width - (width + naughty.config.padding) v.x = ws.x + ws.width - (width + naughty.config.padding)
end end
@ -246,7 +251,8 @@ end
-- Default: nil -- Default: nil
-- @param screen Target screen for the notification. Default: 1 -- @param screen Target screen for the notification. Default: 1
-- @param position Corner of the workarea displaying the popups. -- @param position Corner of the workarea displaying the popups.
-- Values: "top_right" (default), "top_left", "bottom_left", "bottom_right". -- Values: "top_right" (default), "top_left", "bottom_left", "bottom_right",
-- "top_middle", "bottom_middle".
-- @param ontop Boolean forcing popups to display on top. Default: true -- @param ontop Boolean forcing popups to display on top. Default: true
-- @param height Popup height. Default: nil (auto) -- @param height Popup height. Default: nil (auto)
-- @param width Popup width. Default: nil (auto) -- @param width Popup width. Default: nil (auto)