dotfiles/awesome/utils/mouse.lua

23 lines
741 B
Lua
Raw Normal View History

2023-05-29 15:27:20 +02:00
local mouse_utils = {}
function mouse_utils.move_mouse_onto_focused_client()
local c = client.focus
2023-09-06 16:28:37 +02:00
if c then
2023-05-29 15:27:20 +02:00
local geometry = c:geometry()
local mouse_coords = mouse.coords()
local margin = 10
-- Don't move the mouse if it's already over the client
if not (mouse_coords.x > geometry.x - margin
and mouse_coords.x < geometry.x + geometry.width + margin
and mouse_coords.y > geometry.y - margin
and mouse_coords.y < geometry.y + geometry.height + margin) then
local x = geometry.x + geometry.width/2
local y = geometry.y + geometry.height/2
mouse.coords({x = x, y = y}, true)
end
end
end
return mouse_utils