Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/naughty/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ no_clear.defaults = {
screen = nil,
ontop = true,
margin = dpi(5),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there are other default values still

so i don't think that your solution of removing one specific value from defaults is a correct direction - prolly the rootcause either in in get_value or in order how those are retrieved

border_width = dpi(1),
position = "top_right",
urgency = "normal",
message = "",
Expand Down
2 changes: 2 additions & 0 deletions lib/naughty/container/background.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ local wbg = require("wibox.container.background")
local gtable = require("gears.table")
local beautiful = require("beautiful")
local gshape = require("gears.shape")
local dpi = beautiful.xresources.apply_dpi

local background = {}

local function update_background(notif, wdg)
local bg = notif.bg or beautiful.notification_bg
local bw = notif.border_width or beautiful.notification_border_width
or dpi(1)
local bc = notif.border_color or beautiful.notification_border_color

-- Always fallback to the rectangle to make sure the border works
Expand Down
1 change: 0 additions & 1 deletion lib/naughty/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ gtable.crush(naughty, require("naughty.constants"))
-- @tfield[opt=awful.screen.focused()] integer screen
-- @tfield[opt=true] boolean ontop
-- @tfield[opt=beautiful.xresources.apply_dpi(5)] integer margin
-- @tfield[opt=beautiful.xresources.apply_dpi(1)] integer border_width
-- @tfield[opt="top_right"] string position

--- The reason why a notification is to be closed.
Expand Down
2 changes: 2 additions & 0 deletions lib/naughty/layout/legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local naughty = require("naughty.core")
local screen = require("awful.screen")
local button = require("awful.button")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
local surface = require("gears.surface")
local wibox = require("wibox")
local gfs = require("gears.filesystem")
Expand Down Expand Up @@ -385,6 +386,7 @@ function naughty.default_notification_handler(notification, args)
or beautiful.bg_focus or '#535d6c'

local border_width = get_value(notification, args, preset, "border_width")
or dpi(1)
local shape = get_value(notification, args, preset, "shape" )
local width = get_value(notification, args, preset, "width" )
local height = get_value(notification, args, preset, "height" )
Expand Down
2 changes: 1 addition & 1 deletion lib/naughty/notification.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ local notification = {}

--- Border width.
-- @property border_width
-- @tparam[opt=beautiful.notification_border_width or 0] number|nil border_width
-- @tparam[opt=beautiful.notification_border_width or 1] number|nil border_width
-- @negativeallowed false
-- @propertyunit pixel
-- @propbeautiful
Expand Down
61 changes: 61 additions & 0 deletions tests/test-naughty-border.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
--- Test that `beautiful.notification_border_width` is honored.
-- Regression test for the bug where the theme variable was ignored because
-- the notification carried a hardcoded `border_width` default that shadowed it.

local naughty = require("naughty")
local background = require("naughty.container.background")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi

require("ruled.notification"):_clear()

local steps = {
-- The theme border width must reach the rendered notification background.
function()
beautiful.notification_border_width = 7

local n = naughty.notification { title = "t", message = "m", timeout = 0 }
local bg = background { notification = n }

assert(bg.border_width == 7,
"theme border_width not applied: " .. tostring(bg.border_width))

n:destroy()

return true
end,

-- An explicit property still takes precedence over the theme.
function()
local n = naughty.notification {
title = "t", message = "m", border_width = 3, timeout = 0
}
local bg = background { notification = n }

assert(bg.border_width == 3,
"explicit border_width ignored: " .. tostring(bg.border_width))

n:destroy()

return true
end,

-- With neither a theme nor an explicit value, the default is preserved.
function()
beautiful.notification_border_width = nil

local n = naughty.notification { title = "t", message = "m", timeout = 0 }
local bg = background { notification = n }

assert(bg.border_width == dpi(1),
"default border_width not preserved: " .. tostring(bg.border_width))

n:destroy()

return true
end,
}

require("_runner").run_steps(steps)

-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
Loading