2009-04-14 17:53:22 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2009 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local setmetatable = setmetatable
|
|
|
|
local ipairs = ipairs
|
|
|
|
local capi = { button = button }
|
|
|
|
local util = require("awful.util")
|
|
|
|
|
|
|
|
--- Button helper for awful
|
|
|
|
module("awful.button")
|
|
|
|
|
|
|
|
--- Modifiers to ignore
|
|
|
|
ignore_modifiers = { "Lock", "Mod2" }
|
|
|
|
|
|
|
|
--- Create a new button to use as binding.
|
|
|
|
-- This function is useful to create several buttons from one, because it will use
|
|
|
|
-- the ignore_modifier variable to create more button with or without the ignored
|
|
|
|
-- modifiers activated.
|
|
|
|
-- For example if you want to ignore CapsLock in your buttonbinding (which is
|
|
|
|
-- ignored by default by this function), creatina button binding with this function
|
|
|
|
-- will return 2 button objects: one with CapsLock on, and the other one with
|
|
|
|
-- CapsLock off.
|
2009-05-01 15:37:17 +02:00
|
|
|
-- @see capi.button
|
2009-04-17 11:13:22 +02:00
|
|
|
-- @return A table with one or several button objects.
|
2009-08-17 14:10:03 +02:00
|
|
|
function new(mod, button, press, release)
|
2009-04-14 17:53:22 +02:00
|
|
|
local ret = {}
|
|
|
|
local subsets = util.subsets(ignore_modifiers)
|
|
|
|
for _, set in ipairs(subsets) do
|
2009-08-17 14:10:03 +02:00
|
|
|
ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set),
|
|
|
|
button = button })
|
|
|
|
if press then
|
|
|
|
ret[#ret]:add_signal("press", function(bobj, ...) press(...) end)
|
|
|
|
end
|
|
|
|
if release then
|
|
|
|
ret[#ret]:add_signal("release", function (bobj, ...) release(...) end)
|
|
|
|
end
|
2009-04-14 17:53:22 +02:00
|
|
|
end
|
2009-04-17 11:13:22 +02:00
|
|
|
return ret
|
2009-04-14 17:53:22 +02:00
|
|
|
end
|
|
|
|
|
2009-05-25 11:14:08 +02:00
|
|
|
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
2009-04-14 17:53:22 +02:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|