Lock a Mac without your windows moving when you come back
Your windows move after the lock screen because locking lets the displays go to sleep, and many external monitors disconnect from the Mac while they sleep. macOS sees a screen disappear, moves its windows onto the displays that are left, and does not always move them back when the monitor wakes. To stop it, keep the displays awake during short breaks, either with a password-protected screen saver or with a privacy screen such as Shoji that covers everything without sleeping the displays, and save the full macOS lock for long absences.
If your windows also move when nothing has slept, the cause is more likely Spaces, which is covered below too.
Why locking moves your windows
Locking itself does not touch your windows. Press Control-Command-Q, or choose Lock Screen from the Apple menu, and macOS puts the lock screen in front of everything while your apps keep running behind it. The trouble starts a little later, when nobody touches the Mac and the displays turn off.
A built-in display simply goes dark. Many external monitors go further. When they enter their deepest power-saving state, they drop the video connection, so from the Mac’s side it looks as if the cable has been pulled. macOS then does what it always does when a display is unplugged: it gathers that display’s windows onto a screen that is still there, usually the laptop’s own, and shrinks any that are too big for it.
When you come back and unlock, the monitor wakes and reconnects. macOS tries to return each window to where it was, but if the monitor takes a moment too long, or comes back through a dock that reconnects it as if it were new, the windows stay where they were moved. That is the pile you find on your laptop screen.
A few signs point to this cause:
- It only happens with an external monitor connected.
- It happens after longer breaks, not after a few seconds.
- The windows end up on the built-in display, often resized.
- It is worse through a hub or dock than with a direct cable.
When it is Spaces, not windows
Sometimes nothing moved at all, and the desktops changed order instead. macOS can reorder Spaces by how recently you used them, so after a break the desktop you left may sit in a different spot, and it feels as if your windows went somewhere else.
- Open System Settings and choose Desktop & Dock.
- Scroll to the Mission Control section.
- Turn off “Automatically rearrange Spaces based on most recent use”.
If you keep certain apps on certain desktops, you can tie them there too. With more than one desktop set up, Control-click an app’s icon in the Dock, choose Options, and under Assign To pick This Desktop. The app then opens on that Space instead of wherever you happen to be.
Keep the displays awake for short breaks
Since the shuffle starts when the monitor sleeps, the most reliable fix is a break during which it never does. macOS can do this without any extra app: lock with the screen saver instead of the lock screen.
- Open System Settings and choose Lock Screen.
- Set “Require password after screen saver begins or display is turned off” to Immediately.
- On the same screen, set the display to turn off after a period longer than your usual break. A laptop has one setting for battery and one for the power adapter.
- Open Desktop & Dock, click Hot Corners near the bottom, and set one corner to Start Screen Saver.
Now, when you get up, push the pointer into that corner. The screen saver covers every display and keeps them lit, so the monitor stays connected and the windows stay put. When you come back, move the mouse or press a key, and macOS asks for Touch ID or your password before it shows the desktop.
Two caveats. Once the display timer runs out, the displays sleep as usual, so a long lunch can still bring the shuffle back. And a lit screen saver tells everyone nearby that the Mac is unattended. It is still locked behind it, but it is not discreet.
Check the monitor and the connection
If the screen saver route still leaves you dragging windows back, look at the hardware side.
- The monitor’s own menu. Many monitors have settings with names like deep sleep, auto standby, power saving or automatic input switching. Some of these make the monitor drop its connection when idle, and turning them off can keep it connected while it is dark. The names vary by maker, so look through the on-screen menu.
- The dock or hub. A monitor behind a dock reconnects through two devices instead of one. Try a direct cable for a day to see whether the problem changes, and check whether the dock’s maker offers a firmware update.
- Mac sleep. If the whole Mac sleeps, everything reconnects on wake, not just the monitor. On a laptop, the Battery section of System Settings has an Options button with a setting that prevents automatic sleeping on the power adapter when the display is off. Desktop Macs have a similar option in their energy settings.
A screen that covers everything and sleeps nothing
The screen saver trick works, but it was not designed for this, and it gives way to display sleep once its timer runs out. Shoji is made for exactly these short breaks. Press Command-L and a screen slides shut over everything on every display. It does not sleep the displays or shuffle windows. Touch ID, or your Mac password checked by macOS, opens it again, with every window exactly where you left it.
A few other details matter for the same breaks:
- Music keeps playing and downloads keep going behind it.
- While it is shut, the keyboard belongs to the lock, so nothing typed reaches your apps.
- If you plug in a monitor while it is locked, that monitor is covered the moment it wakes.
- Away timers can lock it for you if you forget, for example after five minutes, and they wait while a video or a call keeps the display awake. A hot corner can lock it too.
It is meant to sit alongside the macOS lock, not replace it. After an away time you choose, Shoji also turns on the real macOS lock. From then on macOS is in charge, with its usual display sleep, so the monitor and Spaces settings above still matter for long absences. Pick an away time slightly longer than your usual coffee or call, and the short breaks stay on the screen that leaves your layout alone.
What it does not do: it covers the screen, and it is not protection against malware, cameras or other apps recording the screen. It needs no Screen Recording, Accessibility or Full Disk Access permission, because it never captures the screen or reads windows. It runs on macOS 14 or later, on Apple silicon and Intel, costs $14 once, and is free for 24 hours, which is enough to see whether your windows stay where you left them.
Questions
Why do my windows always end up on the MacBook screen? Because the built-in display is the one that never disconnects. When an external monitor drops off during sleep, macOS moves its windows to the laptop screen, and they stay there if the monitor does not reconnect in time.
Does the screen saver really lock the Mac? Yes, as long as “Require password after screen saver begins or display is turned off” is set to Immediately in Lock Screen settings. Ending the screen saver then asks for Touch ID or your password before anything is shown. Require a password immediately after a Mac sleeps covers that setting in full.
Does keeping the displays awake use more power? Yes, a lit display draws more than a dark one. On battery, keep the display timer shorter or let the macOS lock take over sooner. At a desk with the charger plugged in, it matters much less.