26

After quitting an application, the previous app that I was interacting with is automatically selected. If I was working in Terminal, switched to Chrome, and then decided to quit Chrome, Terminal becomes the active context. Unfortunately, if Terminal happened to be in a different space at the time, OS X swaps to that space for me.

This effect is pretty jarring every time it happens, and it really gets in the way if, say, Chrome was merely restarting. In that case not only do I get sent to a completely different space, but Chrome then opens itself up in that space where I don't want it.

The only question I could find similar to my problem was: How can I stop spaces from switching automatically?

It suggests to go under System Preferences -> (Spaces / Mission Control), and uncheck When switching to an application, switch to a space with open windows for the application.

While this technically solves my problem, I'm now unable to swap to an open application by simply clicking its icon in the Dock. I can live with this if I have to, but I'd rather have a real solution that doesn't require me to sacrifice quick app-switching.

Ideally I'd like it to switch context to the most-recently used application that's currently open in the existing space. If none exist, default to the Finder.

1
  • 3
    Don't quit your apps :)
    – jtbandes
    Commented Aug 3, 2011 at 4:01

3 Answers 3

10

As far as I know, there's no way to do exactly what you want, but you can come pretty close. It's true that if you uncheck the "When switching..." checkbox, you don't go to the app when you click on the icon in the dock, but you do go to the app when you double click it (or just generally click it a second time when the application is active but nothing is visible).

I've been using it this way for years - I'd almost forgotten there was any other behavior.

3
  • 1
    Thank you! This was exactly what I wanted: the "When switching..." unchecked behavior with Dock behavior left in-tact. The only other undesirable effect is that built-in Cmd-Tab doesn't switch either. For that I just replaced the built-in tab-switcher with Witch. Commented Mar 21, 2012 at 17:37
  • 2
    I thought this happens because the system is switching back to the previous app, but that's not it. Something is causing explicit switching to apps in different desktops (and subsequently switching the space). After disabling the "When switching..." option, in addition to not switching spaces, it also no longer switches to the "wrong" app. Instead it simply returns to the app you were using right before the app being closed. I wish there was a way to just disable that bug. I'd say, switching spaces when switching apps, in itself, is fine. Commented Jun 15, 2014 at 13:59
  • 1
    I'm just adding this for Google. This also works for those of us using iTerm2 with a so-called "floating window" (aka a "visor") that shows and hides itself when using hotkeys. If you reveal the iTerm window and then switch spaces while it's open, hiding it again will take you back to a different space with windows for the app that was in focus before you showed the iTerm visor window. Disabling "When switching ..." fixes this behavior, too. Commented Oct 25, 2023 at 10:18
1

This works on 10.6.8. Just used it myself. Enjoy!

For Leopard 10.5.0–10.5.2, the solution was to access a hidden preference for Spaces by issuing the following command in a Terminal or xterm (X11) window:

defaults write com.apple.dock workspaces-auto-swoosh -bool NO

then restarting the Dock using the following command:

killall Dock

Source

2
  • 4
    As noted in the article, this has the same effect as the System Preference for: When switching to an application, switch to a space with open windows for the application, which is not what I want. I'd still like to be able to use the Dock to switch to currently-opened windows of the application. Commented Jan 20, 2012 at 19:52
  • This still works on El Capitan 10.11 Commented Feb 19, 2016 at 13:56
0

You can force apps to open in certain spaces from System Preferences, which would solve the problem of Chrome opening in a space it shouldn't.

The drawback is that I don't think it will stop the transition from one space to another, and then back again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .