Why Mac windows move to the main screen after sleep
You leave the Mac for a while and come back to find everything piled onto the built-in display or the primary monitor. Nothing was unplugged and nothing was touched. The displays went to sleep, and that is enough for macOS to move the windows.
What happens to your displays when the Mac sleeps
There are two different things called sleep. Display sleep turns the screens off after a few minutes without activity; the Mac is still awake and working. System sleep puts the whole machine to sleep.
Either way, the external displays can disconnect and drop off the list of displays macOS is using. When you wake the Mac, they reconnect. To the system that is a display change in both directions, the same event as unplugging and replugging a cable.
This is the same behaviour as unplugging a monitor, described in full at Why your Mac moves windows when you unplug a monitor.
Why the windows end up on the main screen
A window has to be on a screen. While the external displays are away, macOS moves their windows onto whatever display is left, usually the built-in screen on a laptop or the primary monitor on a desktop.
When the externals come back, macOS sometimes moves the windows back and often does not. The displays also take longer to wake than the Mac does, so there is a moment when the Mac is awake with fewer displays than it expects, and macOS rehomes the windows in that gap.
What you can do with macOS alone
- Stop the displays sleeping. In System Settings › Lock Screen, set Turn display off on power adapter when inactive to Never, if that suits how you use the Mac. The displays then stop dropping for display sleep, though system sleep still does it.
- Assign apps to a display. Right-click an app in the Dock, choose Options › Assign To, and pick the display you want, so at least new windows open there.
- Wake the displays first. On some setups you can wake the monitors before the Mac, which gives macOS the displays it needs before it rehomes anything. It is unreliable, and it is not a fix.
macOS has no setting that puts the windows back. It moves them somewhere valid and moves on.
Which setups make it worse
- Docks and hubs. A dock connects its displays in stages, so macOS sees two or three display changes in quick succession and reshuffles at each one.
- A Mac mini or Mac Studio. There is no built-in display to fall back on, so windows land on whichever monitor comes back first, often the primary one.
- Two or more external displays. Every extra display is one more chance for the Mac and the monitors to disagree about when the setup is ready.
- Slow waking monitors. A monitor that takes several seconds to report itself widens the gap in which macOS rehomes windows.
What an app adds
What is missing is a memory of which window belonged to which display, and something that puts each window back once the displays have settled. Resettle learns that as you work and restores it after wake, when the display setup stops changing.
The threads on this are long. Apple's forum has a post titled Solution: Active apps and windows move from second monitor to primary monitor after the displays went to sleep. On a MacPowerUsers thread, Windows keep moving between screens after sleep, one person describes an UltraFine display whose windows go back to the iMac every time it sleeps.
- Waits for the displays to settle, then puts windows back once, instead of chasing every flicker.
- Separate layouts for each display setup, learned as you work, with nothing to save.
- Tells identical monitors apart, and the same model at home and at work.
- Full-screen windows go back to full screen on the right display.
Resettle restores the layout after the displays are back. It does not stop macOS moving the windows while they are away, and it cannot put back a window macOS never moved, such as an app that reopens at a spot of its own choosing. $14.99 once, one Mac, no free tier, with a 14-day refund.
Questions
Why do my windows move to the built-in display after sleep?
External displays can drop off while the Mac sleeps, and macOS moves their windows to the display that is left, which is usually the built-in screen. When the displays return, macOS often leaves the windows where it put them.
Does Resettle stop it or undo it?
It undoes it. Resettle waits for your displays to settle after wake, then moves each window back to the display it belongs on. It does not prevent macOS moving the windows while the displays are asleep.
Does this happen with the lid closed?
Yes, and it can be worse, because the built-in display is gone as well. Closing and opening the lid is another display change on top of the sleep.
Does this happen on a Mac mini or Mac Studio?
Yes. With no built-in display, windows fall back to whichever monitor comes back first, which is often the primary one.