ianyh / Amethyst

Automatic tiling window manager for macOS à la xmonad.
https://ianyh.com/amethyst/
MIT License
14.81k stars 487 forks source link

Mouse doesn't follow window when moving windows #853

Open reuben opened 5 years ago

reuben commented 5 years ago

System

What's the problem?

I think this was lost at some point when this was converted to Swift? There's still a lone focusedWindow.focus() in WindowTransitionCoordinator.swapFocusedWindowClockwise (but not in the other methods), but I think that solution no longer works due to the async nature of the new code. If you add focusedWindow.focus() calls to the other window transition methods, the mouse cursor gets updated to the last position before the transition, since the focus() call is sync and happens before the reflow.

I tried calling Window.currentlyFocused()?.focus() inside the reflow operation's completionBlock but that leads to some weird behavior where the focus is stuck to the currently focused window and you can't change it.

I think there's an additional bug that may be influencing this behavior in Window.isFocused. I set some breakpoints and inspected the values during reflow operations, and basically it always returns false. Changing the isEqual(to: focused) call to focused.windowID() == self.windowID() seems to do the right thing, or at least returns true when I expect it to.

See also #120 and #147.

reuben commented 4 years ago

Fantastic \o/

ianyh commented 4 years ago

I unfortunately had to reintroduce this. See #1060