← ClaudeAtlas

macos-window-activationlisted

Use when a qol plugin (alt-tab, launcher, window-actions) must bring ANOTHER app's window to the front on macOS, or make its own popup key. Covers why NSRunningApplication.activate is inert on macOS 14+, why SkyLight `_SLPSSetFrontProcessWithOptions` is necessary but silently ignored against actively-front apps, the `kAXFrontmost` app attribute that actually foregrounds a fighting app, the generation-guarded re-assert loop that beats the picker-teardown race, AXRaise/unminimize ordering, reading the true frontmost window via CGWindowList, dlopen-ing a private framework, and the click-gesture / modifier-drop focus pitfalls. Built from a reproduced alt-tab focus bug, not generic docs. For our own popup's focus use gpui-conventions ("Eagerly stealing OS window focus"); this skill is about foregrounding a foreign app.
qol-tools/qol-skills · ★ 0 · AI & Automation · score 62
Install: claude install-skill qol-tools/qol-skills
# macOS Window Activation & Focus Foregrounding another process's window on macOS is not `NSRunningApplication.activate`. That call is **non-authoritative** on modern macOS and loses to apps that re-assert frontmost. The reliable path talks to the WindowServer directly via private SkyLight symbols, the way AltTab.app does. ## The core gotcha: `activate(.ignoringOtherApps)` is inert on macOS 14+ `NSRunningApplication.activate(options: .activateIgnoringOtherApps)` (objc2: `activateWithOptions(NSApplicationActivationOptions::ActivateIgnoringOtherApps)`) is **deprecated and has no effect from macOS 14**. The Swift toolchain says so itself: ``` 'activateIgnoringOtherApps' was deprecated in macOS 14.0: ignoringOtherApps is deprecated in macOS 14 and will have no effect. ``` It can still **return `true`** while doing nothing forceful, so a `let ok = app.activate(...)` check is not success evidence. Reproduce against an app that re-asserts frontmost and classify failures by these durable shapes: - **Mode A** — target app never comes forward (the user's "selected app didn't focus"). - **Mode B** — right app, wrong window (a floating window like Teams' "Sharing Indicator" wins). ## The fix: authoritative activation via SkyLight Bring the process **and** a specific window to the front through the WindowServer. `_SLPSSetFrontProcessWithOptions` is authoritative; two synthetic event records then make the chosen window key. ```rust #[repr(C)] #[derive(Clone, Copy)] struct ProcessS