naughty: Only enable the legacy mode when there is no other handlers.

It was called legacy for a reason, it is meant to be used only when the
rc.lua doesn't have the newer notification section.
This commit is contained in:
Emmanuel Lepage Vallee 2019-03-08 14:39:38 -05:00
parent d956b5411b
commit 4aaf6ea730
3 changed files with 15 additions and 19 deletions

View File

@ -122,6 +122,10 @@ gtable.crush(naughty, require("naughty.constants"))
-- @property active
-- @param table
--- True when there is a handler connected to `request::display`.
-- @property has_display_handler
-- @param boolean
local properties = {
suspended = false,
expiration_paused = false
@ -346,6 +350,10 @@ function naughty.get_active()
return naughty._active
end
function naughty.get_has_display_handler()
return conns["request::display"] and #conns["request::display"] > 0 or false
end
--- Set new notification timeout.
--
-- This function is deprecated, use `notification:reset_timeout(new_timeout)`.
@ -454,7 +462,7 @@ end
--- Emitted when a notification has to be displayed.
--
-- To add an handler, use:
-- To add a handler, use:
--
-- naughty.connect_signal("request::display", function(notification, args)
-- -- do something

View File

@ -279,23 +279,10 @@ end
naughty.connect_signal("destroyed", cleanup)
--- The default notification GUI handler.
--
-- To disable this handler, use:
--
-- naughty.disconnect_signal(
-- "request::display", naughty.default_notification_handler
-- )
--
-- It looks like:
--
--@DOC_naughty_actions_EXAMPLE@
--
-- @tparam table notification The `naughty.notification` object.
-- @tparam table args Any arguments passed to the `naughty.notify` function,
-- including, but not limited to all `naughty.notification` properties.
-- @signalhandler naughty.default_notification_handler
function naughty.default_notification_handler(notification, args)
-- This is a fallback for users whose config doesn't have the newer
-- `request::display` section.
if naughty.has_display_handler then return end
-- If request::display is called more than once, simply make sure the wibox
-- is visible.
@ -561,4 +548,4 @@ function naughty.default_notification_handler(notification, args)
end
end
naughty.connect_signal("request::display", naughty.default_notification_handler)
naughty.connect_signal("request::fallback", naughty.default_notification_handler)

View File

@ -551,7 +551,8 @@ local function create(args)
-- Let all listeners handle the actual visual aspects
if (not n.ignore) and (not n.preset.ignore) then
naughty.emit_signal("request::display", n, args)
naughty.emit_signal("request::display" , n, args)
naughty.emit_signal("request::fallback", n, args)
end
-- Because otherwise the setter logic would not be executed