shims: Update the `button` and `key` shims to be objects.
Now that something actually tries to set the index handlers, it cannot be a dumb function anymore.
This commit is contained in:
parent
35a4b4edbf
commit
f4cfb99cde
|
@ -1,7 +1,35 @@
|
|||
return function() return {
|
||||
data = {},
|
||||
_is_capi_button = true,
|
||||
connect_signal = function() end
|
||||
} end
|
||||
local gears_obj = require("gears.object")
|
||||
|
||||
local button, meta = awesome._shim_fake_class()
|
||||
|
||||
local function new_button(_, args)
|
||||
local ret = gears_obj()
|
||||
ret._private = args or {}
|
||||
|
||||
-- The miss handler wont work for this.
|
||||
for k, v in pairs(ret._private) do
|
||||
rawset(ret, k, v)
|
||||
end
|
||||
|
||||
if not rawget(ret, "modifiers") then
|
||||
rawset(ret, "modifiers", {})
|
||||
end
|
||||
|
||||
--TODO v5: remove this.
|
||||
ret.data = ret._private
|
||||
|
||||
rawset(ret, "_is_capi_button", true)
|
||||
|
||||
local md = setmetatable(ret, {
|
||||
__index = function(...) return meta.__index(...) end,
|
||||
__newindex = function(...) return meta.__newindex(...) end
|
||||
})
|
||||
|
||||
assert((not args) or args.button == md.button)
|
||||
|
||||
return md
|
||||
end
|
||||
|
||||
return setmetatable(button, { __call = new_button, })
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
local gobject = require("gears.object")
|
||||
local gtable = require("gears.table")
|
||||
local gears_obj = require("gears.object")
|
||||
|
||||
return setmetatable({_is_capi_key = true}, {__call = function(_, args)
|
||||
return gtable.crush(gobject(), args)
|
||||
end})
|
||||
local key, meta = awesome._shim_fake_class()
|
||||
|
||||
local function new_key(_, args)
|
||||
local ret = gears_obj()
|
||||
ret._private = args or {}
|
||||
|
||||
-- The miss handler wont work for this.
|
||||
for k, v in pairs(ret._private) do
|
||||
rawset(ret, k, v)
|
||||
end
|
||||
|
||||
--TODO v5: remove this.
|
||||
ret.data = ret._private
|
||||
|
||||
rawset(ret, "_is_capi_key", true)
|
||||
|
||||
local md = setmetatable(ret, {
|
||||
__index = function(...) return meta.__index(...) end,
|
||||
__newindex = function(...) return meta.__newindex(...) end
|
||||
})
|
||||
|
||||
assert((not args) or args.key == md.key)
|
||||
|
||||
return md
|
||||
end
|
||||
|
||||
return setmetatable(key, { __call = new_key, })
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -2,8 +2,6 @@ local root = {_tags={}}
|
|||
|
||||
local gtable = require("gears.table")
|
||||
|
||||
local hotkeys = nil
|
||||
|
||||
function root:tags()
|
||||
return root._tags
|
||||
end
|
||||
|
@ -86,15 +84,9 @@ local function match_modifiers(mods1, mods2)
|
|||
end
|
||||
|
||||
local function execute_keybinding(key, event)
|
||||
-- It *could* be extracted from gears.object private API, but it's equally
|
||||
-- ugly as using the list used by the hotkey widget.
|
||||
if not hotkeys then
|
||||
hotkeys = require("awful.key").hotkeys
|
||||
end
|
||||
|
||||
for _, v in ipairs(hotkeys) do
|
||||
if key == v.key and match_modifiers(v.mod, get_mods()) and v[event] then
|
||||
v[event]()
|
||||
for _, v in ipairs(keys) do
|
||||
if key == v.key and match_modifiers(v.modifiers, get_mods()) then
|
||||
v:emit_signal(event)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue