keygrabber: Allow multiple instances to be created during the same loop. (#2741)

Due to a facepalm caliber mistake, the wrong self was being used...

Fixes #2712
This commit is contained in:
Emmanuel Lepage Vallée 2019-04-07 19:09:49 -04:00 committed by GitHub
parent 7b7dcdd87a
commit 4440c5c1d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 16 deletions

View File

@ -126,7 +126,7 @@ local function add_root_keybindings(self, list)
-- everything into one operation. In not so extreme cases, not doing so -- everything into one operation. In not so extreme cases, not doing so
-- would slow down `awesome.restart()` by a small, but noticeable amount -- would slow down `awesome.restart()` by a small, but noticeable amount
-- of time. -- of time.
gtable.merge(delay_list, list) table.insert(delay_list, {self, list})
-- As of Awesome v4.3, `root.keys()` is an all or nothing API and there -- As of Awesome v4.3, `root.keys()` is an all or nothing API and there
-- isn't a standard mechanism to add and remove keybindings at runtime -- isn't a standard mechanism to add and remove keybindings at runtime
@ -137,26 +137,30 @@ local function add_root_keybindings(self, list)
gtimer.delayed_call(function() gtimer.delayed_call(function()
local ret = {} local ret = {}
for _, v in ipairs(delay_list) do for _, obj in ipairs(delay_list) do
local mods, key, press, release, description = unpack(v) local obj_self, obj_list = obj[1], obj[2]
if press then for _, v in ipairs(obj_list) do
local old_press = press local mods, key, press, release, description = unpack(v)
press = function(...)
self:start() if press then
old_press(...) local old_press = press
press = function(...)
obj_self:start()
old_press(...)
end
end end
end
if release then if release then
local old_release = release local old_release = release
release = function(...) release = function(...)
self:start() obj_self:start()
old_release(...) old_release(...)
end
end end
end
table.insert(ret, akey(mods, key, press, release, description)) table.insert(ret, akey(mods, key, press, release, description))
end
end end
-- Wow... -- Wow...