Open lwouis opened 3 years ago
I wonder what will happen after AltTab is released. It's very much possible that it focuses the window, but doesn't leave the "Show desktop" situation. That wouldn't be a great UX. And there is no public API to leave "Show desktop".
If I'm correct about this, then we can either scratch this ticket, and just disable AltTab on "Show desktop", or find a workaround that stops "Show desktop" to make it a smooth UX.
I wonder what will happen after AltTab is released. It's very much possible that it focuses the window, but doesn't leave the "Show desktop" situation. That wouldn't be a great UX. And there is no public API to leave "Show desktop".
If I'm correct about this, then we can either scratch this ticket, and just disable AltTab on "Show desktop", or find a workaround that stops "Show desktop" to make it a smooth UX.
I think that quit "Show Desktop" is totally our intension, as the purpose of "Show Desktop" is to drag some file to some application.
@lwouis:
And there is no public API to leave "Show desktop".
/System/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control 1
in Terminal will show/hide desktop depending if the desktop is shown or hidden.
An easy way to test this is in Script Editor, enter:
do shell script "/System/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control 1"
and then hit command-R several times to run the script. You'll see show desktop functionality get toggled on/off.
In Swift, this will show/hide the desktop:
let command = """
/System/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control 1
"""
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = ["zsh", "-c", command]
task.launch()
task.waitUntilExit()
The problem remains of knowing when you are showing the desktop, which you would need in order to be sure that calling this hides the currently shown desktop instead of showing the desktop.
@brettstover this approach is interesting. AltTab supports down to macOS 10.12. I wonder how compatible this approach is. /System/
is pretty new for instance I believe. It would need to be tested, as I care very much for retro-compatibility. Another issue would be latency. I wonder if it's wouldn't be too slow sometimes to call MC like this.
I wonder if there is a way to do a similar effect with AppleScript (without calling Mission Control.app
directly).
Yeah on versions of macOS before /System was introduced you can use /Applications directly to access Mission Control.app. And before Mission Control.app was introduced, I believe the same behaviour was present on Expose.app. So if wanted to use and be backward compatible would require some testing on previous versions and some switching on os version in related code. I'm not aware of a direct AppleScript approach and I haven't noticed any latency issues. Side note: If you ls -la
in /Applications folder on Monterrey you don't even see Mission Control.app there. It seems like Finder adds it to the Applications folder even though it's not actually located there!
I looked into this more today. 2 issues make it impossible at the moment:
CollectionBehavior.canJoinAllSpaces
, and it works well with Show Desktop when set to [CollectionBehavior.canJoinAllSpaces, CollectionBehavior.stationary]
. However, I don't see a way to dynamically switch between both at the right time. The OS seems to not take into account changes in collectionBehavior
instantly also. There is a latency/caching going on. Furthermore, the user could open the window first, then we don't know if they will trigger Expose or Show Desktop. No way to prepare for it.
From discussion here: https://github.com/lwouis/alt-tab-macos/issues/706#issuecomment-766888262