Awesome wm signals may be useful. Here is a quick example (more like hint) how it works.
Put this somewhere at the start of rc.lua
local is_mouse_locked = false
This code put inside client.connect_signal("manage", function (c, startup)
block
-- in this example
-- signal connected to every window and make action if 'is_mouse_locked' switcher active
-- however much better would be connect and disconnect signal to certain window by hotkey
c:connect_signal("mouse::leave",
function(c)
if is_mouse_locked then
local cg = c:geometry() -- get window size
local mg = mouse.coords() -- get current mouse position
-- quick and dirty calculate for mouse position correction
local newx = mg.x <= cg.x and cg.x + 5 or mg.x >= (cg.x + cg.width) and cg.x + cg.width - 5 or mg.x
local newy = mg.y <= cg.y and cg.y + 5 or mg.y >= (cg.y + cg.height) and cg.y + cg.height - 5 or mg.y
-- set mouse to new position
mouse.coords({ x = newx, y = newy })
end
end
)
And add this to hotkeys
awful.key({ modkey, }, "v", function () is_mouse_locked = not is_mouse_locked end),