ianyh / Amethyst

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

Changing Focus Between Screens Fails On Empty Desktop #533

Open ddickstein opened 7 years ago

ddickstein commented 7 years ago

Currently I have a two-monitor setup and can flip the focus between them with ⌥⇧W and ⌥⇧E (I am also using the mouse follows focused windows preference). This works correctly when I have a window up on each monitor that is being managed by Amethyst. However, if one of my monitors is currently displaying the desktop and no windows are up, once I move the focus to that monitor it gets stuck and these refocusing shortcuts stop working. My current solution to this is to either use the application switcher or to move to a different space on the same desktop that might currently have a window open, and once I've moved to that space then focus switching between screens works again. These workarounds are pretty inconvenient though and definitely slow me down.

Trello Card

ianyh commented 7 years ago

Thanks for the report!

Lukas-Stuehrk commented 6 years ago

If I understand it correctly, then the problem is basically this line of code: https://github.com/ianyh/Amethyst/blob/4cda1093d0eb5a9f16d9d175182e5d05bd2a3c37/Amethyst/Categories/NSScreen+Amethyst.swift#L41

This point is calculated from the screen's coordinates which are in Cocoa's coordinate system. But the CGEvent where this point is used is using Quartz' coordinate system. This coordinate system slightly differs from Cocoa's coordinate system. So the simple fix would be to translate the point into Quartz' coordinate system.

However, the implementation of this focus change is basically moving the mouse to the other screen and then tapping in the center of the screen. This is a slightly different behavior than all the other focus changes which don't move the mouse (if you don't have mff enabled). Is this still the wanted behavior? Or does this issue need more changes than simply fixing the point?

ianyh commented 6 years ago

I think it’s still the necessary behavior. Part of the motivation for mouse following to empty screens is because the system spaces shortcuts are based on which screen has the cursor. I had not considered the potential for the mouse position being in the wrong coordinate space. That’s worth looking into.

joelewis101 commented 2 months ago

Hi - thanks so much for amethyst - this issue seems to be happening to me on sonoma 14.5 and amethyst v0.21.1 too