Can anyone give me a hint how to prevent the mouse from leaving a certain window or fullscreen game? Tried it with three steam games (Satellite Reign, Cities:Skylines & Civ 5), all have the same issue: As soon as I move the mouse on the border (for screen panning) instead the focus is switched to my second monitor.
Any advice or hint to the right source (I guess mouse behaviour as a custom client property?) is very welcome :)
Thanks!
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),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.