From 29f41d70fc39133d1a4d89cfeffd141c009f3008 Mon Sep 17 00:00:00 2001 From: danimateo <44500155+danimateo@users.noreply.github.com> Date: Wed, 27 Mar 2024 19:38:50 +0200 Subject: [PATCH] Dismiss the notification without triggering default action on right-click --- lib/naughty/layout/box.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/naughty/layout/box.lua b/lib/naughty/layout/box.lua index dd7fe8f3f..eaec622c7 100644 --- a/lib/naughty/layout/box.lua +++ b/lib/naughty/layout/box.lua @@ -23,6 +23,7 @@ local abutton = require("awful.button") local ascreen = require("awful.screen") local gpcall = require("gears.protected_call") local dpi = require("beautiful").xresources.apply_dpi +local cst = require("naughty.constants") local default_widget = require("naughty.widget._default") @@ -378,18 +379,20 @@ local function new(args) end --TODO remove - local function hide() - local n = ret._private.notification[1] + local function hide(reason) + return function () + local n = ret._private.notification[1] - if n then - n:destroy() + if n then + n:destroy() + end end end - --FIXME there's another pull request for this + -- On right click, close the notification without triggering the default action ret:buttons(gtable.join( - abutton({ }, 1, hide), - abutton({ }, 3, hide) + abutton({ }, 1, hide(cst.notification_closed_reason.dismissed_by_user)), + abutton({ }, 3, hide(cst.notification_closed_reason.silent)) )) gtable.crush(ret, box, false)