Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Source/MouseFollowsFocus.spoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function obj:start()
})
self.window_filter:subscribe({
hs.window.filter.windowFocused
}, function(window)
}, function(window)
if self.onChangeOfScreenOnly and self.currentWindowScreen and self.currentWindowScreen:id() == window:screen():id() then return end
self:updateMouse(window)
self.currentWindowScreen = window:screen()
Expand Down Expand Up @@ -91,6 +91,13 @@ function obj:updateMouse(window)
local current_pos = hs.geometry(hs.mouse.absolutePosition())
local frame = window:frame()
if not current_pos:inside(frame) then
local current_screen = hs.mouse.getCurrentScreen()
local window_screen = window:screen()
if current_screen and window_screen and current_screen ~= window_screen then
-- avoid getting the mouse stuck on a screen corner by moving through the center of each screen
hs.mouse.absolutePosition(current_screen:frame().center)
hs.mouse.absolutePosition(window_screen:frame().center)
end
hs.mouse.absolutePosition(frame.center)
end
end
Expand Down
Binary file modified Spoons/MouseFollowsFocus.spoon.zip
Binary file not shown.