awful.key: fix modifier comparison in match()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-28 20:02:10 +02:00
parent 75203f0f94
commit 8629522884
1 changed files with 12 additions and 3 deletions

View File

@ -46,12 +46,21 @@ function match(key, pressed_mod, pressed_key)
-- Then, compare mod -- Then, compare mod
local mod = key.modifiers local mod = key.modifiers
local nbmod = 0 local nbmod = 0
for _, m in ipairs(pressed_mod) do -- For each modifier of the key object, check that the modifier has been
if util.table.hasitem(mod, m) then -- pressed.
for _, m in ipairs(mod) do
-- Has it been pressed?
if util.table.hasitem(pressed_mod, m) then
-- Yes, the number of modifier correctly pressed++
nbmod = nbmod + 1 nbmod = nbmod + 1
else
-- No, so this is failure!
return false
end end
end end
if nbmod ~= #pressed_mod then -- If the number of pressed modifier is ~=, it is probably >, so this is not
-- the same, return false.
if nbmod ~= #mod then
return false return false
end end
return true return true