Problem
Settle captures the relative front-to-back order correctly, but macOS does not always apply the same order during restore. The current quiet, single-pass approach activates application groups and raises their windows without waiting for each activation to become effective. App activation is asynchronous, so lower layers can be reordered differently from the saved layout.
Observed case
Layout: 20 Jun 2026, 22:06
Saved stackingIndex values (smaller means closer to the front):
- Finder —
15
- Notes —
16
- Safari —
17
Expected front-to-back order: Finder → Notes → Safari.
Observed after restore: Finder → Safari → Notes. The frontmost window is correct, but the two lower application layers are swapped. The composite snapshot and persisted layout data retain the expected order, so the defect is in restoration rather than capture.
macOS constraints investigated
AXRaise on a background application may return success without changing its global WindowServer order.
- Sending all
AXRaise calls immediately does not reliably order windows across applications.
- Setting
AXFocused alone has the same limitation.
- Direct
SLSOrderWindow / CGSOrderWindow calls are rejected for windows owned by other processes with kCGErrorFailure (1000).
- Repeated raise-and-verify passes add visible noise and still do not guarantee application-layer order.
- Activating applications back-to-front works when each activation is allowed to complete before continuing.
Proposed setting
Add an optional Settings preference such as Reliable window ordering.
Default: off, preserving the current quieter best-effort restoration.
When enabled:
- Group matched windows by application.
- Determine application group order from the smallest saved
stackingIndex in each group.
- Process application groups from back to front.
- Activate each application once.
- Wait until
NSWorkspace.shared.frontmostApplication confirms the expected process, with a short timeout.
- Raise that application's windows from back to front.
- Finish by focusing the saved frontmost window.
The setting description must clearly warn that reliable ordering briefly changes application focus during restoration.
Acceptance criteria
- The preference is persisted and defaults to disabled.
- UI copy is localized in English, Spanish, Catalan, French, and German.
- Disabled mode preserves the current quiet behavior.
- Enabled mode synchronizes each application activation before processing the next group.
- Timeouts prevent a non-activatable application from blocking the full restore.
- Unit tests cover preference persistence, group ordering, activation timeout/continuation, and enabled/disabled behavior.
- Manual validation covers at least three overlapping apps and confirms the saved application-layer order.
- README and CHANGELOG document the optional behavior and its focus-change tradeoff.
Problem
Settle captures the relative front-to-back order correctly, but macOS does not always apply the same order during restore. The current quiet, single-pass approach activates application groups and raises their windows without waiting for each activation to become effective. App activation is asynchronous, so lower layers can be reordered differently from the saved layout.
Observed case
Layout:
20 Jun 2026, 22:06Saved
stackingIndexvalues (smaller means closer to the front):151617Expected front-to-back order: Finder → Notes → Safari.
Observed after restore: Finder → Safari → Notes. The frontmost window is correct, but the two lower application layers are swapped. The composite snapshot and persisted layout data retain the expected order, so the defect is in restoration rather than capture.
macOS constraints investigated
AXRaiseon a background application may return success without changing its global WindowServer order.AXRaisecalls immediately does not reliably order windows across applications.AXFocusedalone has the same limitation.SLSOrderWindow/CGSOrderWindowcalls are rejected for windows owned by other processes withkCGErrorFailure (1000).Proposed setting
Add an optional Settings preference such as Reliable window ordering.
Default: off, preserving the current quieter best-effort restoration.
When enabled:
stackingIndexin each group.NSWorkspace.shared.frontmostApplicationconfirms the expected process, with a short timeout.The setting description must clearly warn that reliable ordering briefly changes application focus during restoration.
Acceptance criteria