Engineering 7 min read By Minh Nguyen

How We Built 120Hz Window-Close Shaders on macOS Without Disabling SIP

How do you incinerate a macOS window at 120fps when Apple does not expose the compositor? Here is the Swift 6, ScreenCaptureKit, and Metal architecture behind CloseMotion.

Architecture diagram of CloseMotion 120Hz window-close pipeline: AXUIElement, ScreenCaptureKit, CAMetalLayer, and teardown
The 4-stage pipeline that renders 120Hz Metal shaders on macOS without touching WindowServer or disabling SIP.

The constraint: no compositor hooks, no SIP workarounds

When we started building CloseMotion, we set one hard rule: the app had to ship as a normal, Apple-notarized macOS binary. No disabling System Integrity Protection, no private SkyLight injection, and no fragile hacks that break on the next macOS point release.

That constraint forces an interesting architecture problem. When a user clicks the red close button or presses Command+W, the target app is about to destroy its window immediately. If you capture too late, there are no pixels left to animate. If you block the event too long, the Mac feels laggy.

Step 1: Telling a real window close apart from a browser tab

Listening for Command+W globally with a CGEvent tap is easy, but firing a full-window fire shader every time someone closes a browser tab would make the app unusable within five minutes.

Before triggering an animation, CloseMotion queries the focused window through the macOS Accessibility API (AXUIElement) and checks whether the app is actually closing a multi-tab document or the window container itself. For mouse clicks, we verify that the pointer hit the actual AXCloseButton of the window rather than an arbitrary red circle inside a webpage or canvas.

Step 2: Single-frame capture with ScreenCaptureKit

Apple deprecated CGWindowListCreateImage in favor of ScreenCaptureKit. Using SCScreenshotManager and an SCContentFilter scoped strictly to the closing window ID lets us capture a clean, Retina-resolution snapshot of just that window, including its rounded corners and shadow bounds, without capturing the rest of the desktop.

Because the texture stays in memory and goes straight into a Metal MTLTexture, there is no disk I/O and no encoding overhead. As soon as the animation completes, the texture reference is released.

Step 3: 120Hz Metal rendering with CADisplayLink

On MacBook Pro and Studio Display setups, 60fps animations look noticeably stepped next to ProMotion UI transitions. We render each effect into a transparent, non-activating NSWindow backed by a CAMetalLayer and driven by CADisplayLink.

Dimensional Katana shader slicing a macOS Maps window with glowing blade trails extending beyond the original window bounds
Notice the glowing slash trails extending outside the original window frame thanks to padded overlay actor bounds.

Each shader is written in Metal Shading Language (MSL) using procedural noise and distance fields rather than heavy video textures. That keeps the entire app bundle tiny and lets users tweak accent colors, intensity, and speed in real time.

Step 4: Tearing down everything at idle

The most important optimization in a Menu Bar utility is doing nothing when the user is not triggering it. When the effect timeline reaches 1.0, CloseMotion invalidates the CADisplayLink, orders out and releases the overlay window, and drops the captured Metal texture. While you are coding, writing, or browsing, the Metal pipeline is completely idle.

CloseMotion for macOS 14+

Try 120Hz GPU window close effects for free

3 full shaders free forever with no account. One-time $5.99 Early Bird upgrade for all 12 effects and 36 variants across 3 Macs.