Open oskarols opened 9 years ago
Oddly, this seems to not be reproducible from the Hammerspoon Console (on 10.10.3). I have a Finder window on my second monitor, under several other windows, the Console open on my primary monitor, with focus, and running hs.application.launchOrFocus("Finder") pops the Finder window to the front of the second monitor and gives it focus.
@cmsj I think I was able to do the same thing, as long as the console was created in the same window as a Finder window.
@oskarols good point, I was able to reproduce this using the console if it was created on a different screen to a Finder window.
So it definitely looks to me like this is handing focus to the desktop, which is a "special" Finder window.
The question is, what should Hammerspoon be doing about this? I'd really really like to avoid having lots of whitelisting/blacklisting in the APIs. I think I'd prefer to just add a note to the API docs that launchOrFocus() may behave in unusual ways for apps that have "special" windows.
Thoughts?
At least over here, the system shortcut `cmd-`` always cycles through (what I presume to be, since the icons mysteriously vanished) the desktop, so it seems indeed a case of working-as-intended. Then again I don't know what the point of this behaviour is (so IMHO this might deserve an exceptional 'fix' for launchOrFocus) - I mean, if Finder at least triggered the 'show desktop' action, it might make more sense - but there must probably be some (historical) reason.
Basic test case: have 2 screens, finder on one screen, and have the other screen focused.
Try running:
Finder will not be focused.
Behind the scenes Finder is running a non-standard window, it seems to be the case that when you do not have an actual Finder window on the same screen then focus instead goes to this hidden window.
Edit: Actually, it's more curious than this. Even if you manually filter out the non-standard window and focus only the actual Finder window — it will still not receive focus, unless you trigger
:focus()
three times.For the time being, this seems to do the trick as a quick workaround: