What macOS does when a display disconnects
A window can't live on a screen that no longer exists. The moment you unplug a monitor, close a dock connection, or the display goes to sleep in a way the Mac reads as "disconnected", macOS moves every window from that display onto the remaining ones, usually your laptop's built-in screen. Windows that were bigger than the laptop screen are shrunk to fit. That part is unavoidable and is the same on every Mac.
Why they don't always go back
When the monitor returns, macOS tries to move windows back to where they were. In practice that often fails, and you'll usually see one of these patterns:
- The display looks "new". Plugging into a different dock, port or adapter can make the Mac treat the same monitor as a different display, so it has nothing to restore.
- You used the laptop in between. If you moved or resized windows while the monitor was away, macOS treats the new positions as where they belong now.
- Identical monitors. Two monitors of the same model can report the same identity. The Mac can mix them up and swap your layout between them.
- Sleep and wake. Some monitors and docks drop off for a moment when the Mac sleeps, which counts as a disconnect, so windows get gathered up overnight.
- Each app handles it differently. Some apps restore their own window positions on relaunch, others don't, and some open new windows wherever the pointer is.
How to reduce the shuffling with built-in settings
- Plug into the same port every time. Use the same cable, dock and Mac port for each monitor so macOS sees the same display arrangement each time.
- Check your arrangement once. Open Apple menu › System Settings › Displays and click Arrange. Drag the displays to match where they sit on your desk, and drag the menu bar to the display you want as the main one.
- Pick your main display. In Displays, click the monitor's name and set Use as to Main display. The main display holds the menu bar and is where new windows tend to open.
- Assign apps to a display. If you use Spaces, Control-click an app's icon in the Dock, choose Options, and under Assign To pick Desktop on Display and a number. That app then opens on that display.
- Keep "Displays have separate Spaces" consistent. It's in System Settings › Desktop & Dock, under Mission Control. Turning it on or off changes how windows and Spaces behave on each display, so pick one and leave it.
- Update macOS and your dock's firmware. Display handling improves between macOS versions, and many docks get firmware updates that fix disconnects on sleep.
What helps, at a glance
| Situation | Why windows move | What to try |
|---|---|---|
| Different dock or port each day | The monitor looks like a new display | Use the same dock and port, or a tool that recognizes monitors by hardware ID |
| Two identical monitors | The Mac can't tell them apart reliably | Keep each cable in the same port; check Arrange after reconnecting |
| Windows piled up after sleep | The monitor or dock dropped off while asleep | Update dock firmware; try a different cable or port |
| Some apps always open on the laptop | They open where the main display or pointer is | Set the main display; assign the app in Dock › Options › Assign To |
Can macOS remember a layout per monitor setup?
Not as a feature you control. macOS has no "save this window layout" setting, and its window tiling (in macOS Sequoia and later) arranges windows on one screen but doesn't remember where they go for each combination of monitors. That's the gap layout apps fill: they save a layout per setup and put windows back when that setup reappears.