nikitabobko / AeroSpace

AeroSpace is an i3-like tiling window manager for macOS
https://nikitabobko.github.io/AeroSpace/guide
MIT License
8k stars 131 forks source link

Making sure macOS's "monitor focus" agrees with `focus-monitor` in the case of empty monitors #576

Open ELLIOTTCABLE opened 1 month ago

ELLIOTTCABLE commented 1 month ago

focus-monitor is great (Aerospace has really come a long way!); but at the moment, it's got one glaring flow issue.

When all monitors have at least one window, cycling through them with a focus-monitor left command or similar also drags the macOS "focus" along (that is, the top menubar is faded out on the other, non-focused displays; and pops up a search window on the correct monitor.)

However, if there's a monitor with no windows on it, then when you focus-monitor onto that empty monitor, there's no integration with the system. (The wrong monitor's menubar is highlighted, will open windows on the wrong monitor, etc.)

This is slightly worse when borders or similar is installed - now, the 'active window' indicator is no longer doubling as a "what display/container AeroSpace is going to operate on" indicator.

One janky fix, is to rewrite the default on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] hook to also …

  1. determine if there's any windows on the newly-focused monitor and
  2. then, if not, execute a mouse-click to click on the desktop and activate that monitor from macOS's point of view.

Thus, I suppose, at least one potential "fix" for this might be to make that behaviour the default (hopefully a lot) faster than indirecting through a shell, especially when tabbing through monitors quickly.

Checklist

❯ aerospace --version         
aerospace CLI client version: 0.14.2-Beta 0cb8dbdfc5ee73b8cbc200f175f467ebead55201
AeroSpace.app server version: 0.14.2-Beta 0cb8dbdfc5ee73b8cbc200f175f467ebead55201
ParisTheProgrammer commented 1 month ago

However, if there's a monitor with no windows on it, then when you focus-monitor onto that empty monitor, there's no integration with the system. (The wrong monitor's menubar is highlighted, ⌘␣ will open windows on the wrong monitor, etc.)

This is also the case when using workspace x to focus on a particular monitor, however I don't have any issues with applications opening on the wrong monitor. I've tested using spotlight and raycast (which is what I daily drive) and those work as expected even when the menubar isn't highlighted correctly. I also tested using workspace x and also focus-monitor right with no applications on my secondary monitor and applications still open up on whatever monitor is focused in aerospace (ie. the asterisked workspace in the menubar)

CleanShot 2024-10-09 at 08 06 58

ELLIOTTCABLE commented 2 weeks ago

I'm actually using Raycast, too; and I just tested, and you're … kind-of right? Some actual applications I select with Raycast will open properly on my (empty) main monitor when it's the "Aerospace current" monitor; but Raycast itself opens off to the corner on a secondary monitor, on the "macOS current" monitor:

IMG_1172