Skip to content

When a display disappears, even for a moment during sleep, macOS moves its windows to a screen that's still there. When the display comes back, macOS usually leaves them where they are.

  • Check first: whether the monitors themselves moved (that's a different fix), and the free Desktop and Spaces settings below.
  • To get windows back: save the layout and restore it, by hand or automatically when the monitors reconnect. Several apps do this, Universal Display Magnet among them.
Pick a workspace on this simulated desk and watch each window go back to its monitor and Desktop. It runs in your browser and moves nothing on your Mac.

Two problems that look like one

Before you fix the windows, check the screens. Move the pointer off each edge of each monitor.

  • The pointer leaves at the wrong edge, or the menu bar moved: macOS changed the display arrangement. Fix that first with the monitor arrangement guide; restoring windows onto a wrong arrangement puts them in the wrong place.
  • The screens are right, the windows aren't: read on.

Why windows move

  • A monitor drops off during sleep. Some monitors and docks disconnect completely when they sleep. macOS sees a display removed and gathers its windows onto the screens that remain.
  • Displays wake at different times. For a few seconds only one screen exists, and windows land there.
  • Desktops rearrange themselves. macOS can reorder Desktops by how recently you used them, so windows appear to move between Spaces.
  • Apps place their own windows. Some apps reopen windows where they last saved them, whatever the screens look like.

Free checks first

  1. Stop Desktops reordering. In System Settings → Desktop & Dock, under Mission Control, turn off Automatically rearrange Spaces based on most recent use.
  2. Keep each Desktop on its display. In the same section, Displays have separate Spaces gives each monitor its own Desktops. Leave it set the way you use it; changing it takes effect after you log out.
  3. Assign apps to a Desktop. Control-click an app in the Dock, choose Options, then pick a Desktop under Assign To. That app's windows open there.
  4. Look at the monitor's own settings. Power-saving and automatic input options can make a monitor disconnect while asleep. If yours has them, try turning them off.
  5. Test without the dock. If windows stay put with the monitors connected directly, the dock or adapter is dropping the display. Check its maker for a firmware update.

These help, but macOS has no setting to save where every window was and put it back later. For that you need an app.

Save and restore your layout

Several Mac apps save window layouts and restore them, some automatically when a display connects: Rectangle Pro, Moom, Display Maid, Stay and ShiftPlus among them. The comparison page sets out what each one documents.

Universal Display Magnet is one of these options. It saves which monitor, which Desktop or full-screen Space and where each window was, for each set of monitors. The workspaces page shows the whole feature. Here's how it handles the sleep and reconnect case:

  1. Allow access. Turn on Universal Display Magnet under System Settings → Privacy & Security → Device Control and Data Access (Accessibility on older versions of macOS). It never asks to record your screen.
  2. Save a workspace. Lay out your windows, then choose Save Workspace… in the menu bar. Choose which apps to include, set a shortcut if you like, and turn on Also restore the monitor arrangement and resolutions if you want the screens put back too.
  3. Let snapshots run. The app keeps an automatic snapshot of window positions every few minutes and as the screens go to sleep, separately for each set of monitors.
  4. Sleep, wake or reconnect. When a monitor setup reconnects, or the Mac wakes with its displays changed, the app restores what you chose under When a display setup reconnects, restore in Settings: Last automatic snapshot (the default), Most recent saved layout or Don't restore.
  5. Restore by hand any time. Click a workspace in the menu bar, or press ⌃⌥⌘R to restore the latest window layout.

To put windows back on their Desktop, the app uses the macOS Switch to Desktop shortcuts. Turn them on with Workspaces → Enable ⌃1…⌃0 if they're off. You'll see Desktops switch briefly during a restore.

What a restore can't do

  • Apps that aren't running. Automatic restores after wake or a reconnect never open apps; they move the windows of apps that are open. Restoring a saved workspace opens the workspace's apps that aren't running, then moves their windows. Restoring a window layout by hand, such as the latest snapshot with ⌃⌥⌘R, opens missing apps only if Open apps that aren't running when restoring manually is on in Settings; it's off until you turn it on.
  • Documents, tabs and sessions. Only the app opens. It shows the windows it reopens by itself, and those are moved into place. Unsaved documents, browser tabs and project state aren't part of a workspace.
  • Windows that no longer exist. Saved windows are matched to open ones by app and, where it can, by window title. A window you closed is skipped, and the result tells you how many windows were restored.
  • Scrolling Windows. While the optional Scrolling Windows is on, automatic snapshots and restores pause. A manual workspace restore turns Scrolling Windows off first.
  • Every app, Space and dock. Some apps move their own windows after they're placed, and some docks drop a display long enough to start the shuffle again. A restore puts back what macOS lets it move; it isn't a guarantee for every setup.

Where this has been tested

Universal Display Magnet requires macOS 14 or later and is verified on every version from 14 to 27, on Apple silicon and Intel Macs. To install it and save a first workspace, see getting started.

Questions, answered

Why do all my windows end up on my laptop screen after sleep?
Your external monitor most likely disconnected while asleep, so macOS moved its windows to the only screen left. When the monitor came back, macOS didn't move them back.
Can macOS save and restore window positions by itself?
Not as a saved layout. You can assign an app to a Desktop and stop Desktops reordering, but restoring every window to its monitor needs an app.
Will Universal Display Magnet reopen my documents and browser tabs?
No. It moves windows that exist. Restoring a saved workspace opens its apps that aren't running, and a manual restore of a window layout can too if you turn on Open apps that aren't running when restoring manually. Either way, only the app opens; it shows whatever windows it reopens itself.
Does it need Screen Recording permission?
No. It needs Device Control and Data Access (Accessibility on older versions of macOS) to see and move windows. Nothing is captured from the screen.
My monitors are in the wrong order too. What do I fix first?
The monitors. Follow the monitor arrangement guide, then restore the windows.

Snap your desk into place

One-time purchase · Three Macs · macOS 14 or later