lwouis / alt-tab-macos

Windows alt-tab on macOS
https://alt-tab-macos.netlify.app
GNU General Public License v3.0
10.59k stars 322 forks source link

AltTab should be accessible while "Show desktop" from Mission Control is active #783

Open lwouis opened 3 years ago

lwouis commented 3 years ago

image

From discussion here: https://github.com/lwouis/alt-tab-macos/issues/706#issuecomment-766888262

lwouis commented 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.

RoadToDream commented 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 think that quit "Show Desktop" is totally our intension, as the purpose of "Show Desktop" is to drag some file to some application.

brettstover commented 2 years ago

@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.

lwouis commented 2 years ago

@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).

brettstover commented 2 years ago

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!

lwouis commented 1 year ago

I looked into this more today. 2 issues make it impossible at the moment: