MacOS – Stop Mavericks from opening apps on the second screen

displaymacos

I have a MacBook Pro and connected an external display to it, so far, so great. However, Mavericks seems to insist on opening new applications on the secondary display, even if the currently active (key and main) window/app is on the main display. Incredibly frustrating because they have different screen sizes and it messes terribly with my saved window sizes. Is there any way from stopping Mavericks from doing that? I only want apps to open on the main display, or at least have them remember on which display I closed them last time.

In case it helps, this is my display arrangement from the system preferences:
enter image description here

Best Answer

I'm used to connecting to conference room projectors or big-screens that vary in resolution, so as I move from room to room over the course of the day, my windows constantly have to be resized too. So I feel your pain. :-)

In order to avoid confusion, I want to define a couple terms for this answer:

  • The primary display is the one with the menubar in the Arrangement tab in System Preferences.
  • The main display is the one you want stuff on, whether or not it is the primary display.
  • The secondary display is the one without the menubar in the Arrangement tab in System Preferences.

Basically, the problem is that you see an important difference between the main and primary displays; Mac OS X does not, and it's going to fight you when you try to maintain this distinction by treating the secondary display as the main display.

Unless they specifically try to do otherwise, apps will always open on whatever the primary display is. That's definitionally one of the characteristics of the primary display. (It's a pretty low level part of the Quartz API, specifically the CGConfigureDisplayOrigin call, so this behavior is unconfigurable if the app itself doesn't let you configure it.)

I'd suggest maybe asking about the things that are making it annoying for you ("messes with other things" as you put it in your comment) to not keep your main display as the primary display when you connect, because those may be configurable; this behavior is not.

I do have a couple tricks for you that might help, though:

Mirroring and then un-mirroring displays causes all windows too large to fit on the smaller screen to be resized to fit and gets all the windows onto the primary display. It isn't the perfect solution, I know, since you want things on the secondary display, but it can be a useful workaround when combined with the next trick, especially if you know the keyboard shortcut: ⌘-F1. Press it, let the system switch to mirroring, and press it again. All your windows will be resized to the smallest display and will be on the primary display.

Another very useful tool for working around the issue is the BetterTouchTool, which lets you set "Center Window on Next Monitor" and "Maximize Window to Next Monitor" gestures. I assign these to four- and five-finger clicks, respectively, and then I can quickly pop a window from one monitor to the other just by mashing on the trackpad. (If you don't use a trackpad when you're connected to the big display, BTT can do gestures with other pointing devices, too.)

These two tricks together have made working with constantly-changing resolutions not perfect, but at least tolerable. If I want to get all my windows onto the secondary display (I'm giving a training session, say, and want the menubar to be visible to students but I want all my windows not related to the training to be on the other display), I do the mirror/unmirror trick and then four-finger-smack the trackpad a bunch of times until the windows are all popped over.

Finally, if you like to fiddle, you could take a look at this Applescript which moves all windows to primary via a different method. Unlike the mirroring method, which moves windows to primary as a side-effect, this one does it explicitly, so you could modify it to move windows to your preferred main, secondary, display. But it isn't easy, which may give you an idea of why everything's fighting you against this usage. Here's the crucial line of this Applescript:

set position of window x to {0, 22}

Since the menubar is 22 display coordinates (what used to be "pixels" before Retina displays) high, and screens and windows have their origin points at the top-left, this line moves window x right below and flush-left with the menubar. In order to adapt this script so it would instead move all windows to the upper-left of the secondary display, you'd need to figure out its coordinates, and use that as the x value. In the arrangement you show in your screenshot, the "0" there will be replaced by a negative number, since you're to the left of the menubar. It would take some fiddling to get right, especially if you wanted the script to work regardless of the arrangement.

This is all kludgey, I know; but you're going to have to accept kludges if you want your main display and primary displays to be different. That's why I'd really strongly recommend you try to address what's keeping you from letting the other display be primary rather than fighting this particular battle.