From ef7e4ce967d6143c35df02dee427d1a8cfd97ae9 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 12 Jan 2020 19:34:39 -0500 Subject: [PATCH] naughty.box: Allow constructor arguments to be passed to `wibox()`. Because it was using a metatable proxy instead of a full copy, `pairs()` wasn't working and thus any code based on it was blind to the `args`. Fixes #2956 --- lib/naughty/layout/box.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/naughty/layout/box.lua b/lib/naughty/layout/box.lua index 90b0c45a..3d8feb4a 100644 --- a/lib/naughty/layout/box.lua +++ b/lib/naughty/layout/box.lua @@ -274,15 +274,15 @@ local function new(args) border_color = args.border_color or beautiful.notification_border_color, } + -- The C code needs `pairs` to work, so a full copy is required. + gtable.crush(new_args, args, true) + -- Add a weak-table layer for the screen. local weak_args = setmetatable({ screen = args.notification and args.notification.screen or nil - }, {__index = args, __mode = "v"}) + }, {__mode="v"}) - -- This will cascade from the overriden `new_args` to the weak `weak_args` - -- to the original arguments. This way the original wont be modified and - -- the screen wont leak. - new_args = setmetatable(new_args, {__index = weak_args}) + setmetatable(new_args, {__index = weak_args}) -- Generate the box before the popup is created to avoid the size changing new_args.widget = generate_widget(new_args, new_args.notification) @@ -316,6 +316,8 @@ local function new(args) abutton({ }, 3, hide) )) + gtable.crush(ret, box, false) + return ret end