awful.key: fix modifiers matching
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0c800d9612
commit
79a53769de
|
@ -45,22 +45,18 @@ function match(key, pressed_mod, pressed_key)
|
||||||
if pressed_key ~= key.key then return false end
|
if pressed_key ~= key.key then return false end
|
||||||
-- Then, compare mod
|
-- Then, compare mod
|
||||||
local mod = key.modifiers
|
local mod = key.modifiers
|
||||||
local nbmod = 0
|
|
||||||
-- For each modifier of the key object, check that the modifier has been
|
-- For each modifier of the key object, check that the modifier has been
|
||||||
-- pressed.
|
-- pressed.
|
||||||
for _, m in ipairs(mod) do
|
for _, m in ipairs(mod) do
|
||||||
-- Has it been pressed?
|
-- Has it been pressed?
|
||||||
if util.table.hasitem(pressed_mod, m) then
|
if not util.table.hasitem(pressed_mod, m) then
|
||||||
-- Yes, the number of modifier correctly pressed++
|
|
||||||
nbmod = nbmod + 1
|
|
||||||
else
|
|
||||||
-- No, so this is failure!
|
-- No, so this is failure!
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- If the number of pressed modifier is ~=, it is probably >, so this is not
|
-- If the number of pressed modifier is ~=, it is probably >, so this is not
|
||||||
-- the same, return false.
|
-- the same, return false.
|
||||||
if nbmod ~= #mod then
|
if #pressed_mod ~= #mod then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue