Window management

From fanfan-de/anybox · View interactive version

Window management is an AI agent skill from the GitHub repository fanfan-de/anybox. Customize macOS SwiftUI windows and scene behavior. Use when tuning window chrome, drag regions, placement, restoration, launch behavior, or borderless windows.

How to use this skill

Skill file

Window Management

Overview

Use this skill to tailor each SwiftUI window to its job. Start by identifying

which scene owns the window (Window, WindowGroup, or a dedicated utility

scene), then customize the toolbar/title area, background material, resize and

restoration behavior, and initial or zoomed placement.

Prefer scene and window modifiers over ad hoc AppKit bridges when SwiftUI offers

the behavior directly. Keep each window purpose-built: a main browser window, an

About window, and a media player window usually want different chrome,

resizability, restoration, and placement rules.

These APIs are macOS 15+ SwiftUI window/scene customizations. For older

deployment targets, expect to use more AppKit bridging or availability guards.

Workflow

  1. Inspect the relevant scene declaration and classify the window role:

main app navigation, inspector/detail utility, About/support window, media

playback window, welcome window, or a borderless custom surface.

  1. Adjust toolbar and title presentation to match the content.
  2. If the toolbar background or entire toolbar is hidden, make sure the window

still has a usable drag region.

  1. Refine window behavior for that role: minimize availability, restoration,

resize expectations, and whether the window should appear at launch.

  1. Set default placement for newly opened windows and ideal placement for zoom

behavior when content and display size matter.

  1. Build and launch the app with build-run-debug to verify the result in

a real foreground .app bundle.

  1. If SwiftUI scene/window modifiers are not enough, switch to appkit-interop

for a narrow NSWindow bridge rather than spreading AppKit through the view

tree.

Toolbar And Title

with the window for accessibility and menus, but not be visibly drawn in the

title bar.

media or hero content should visually extend to the top edge of the window.

title and toolbar background. If the toolbar should disappear entirely, use

.toolbarVisibility(.hidden, for: .windowToolbar) instead.

layering new SwiftUI toolbar APIs on top.

still use it for accessibility and menu items. These are visual changes only.

Drag Regions

WindowDragGesture() to extend the draggable area into your content.

that does not steal gestures from real controls.

between the video content and the controls so AVKit or transport controls keep

receiving input.

and immediately dragging a background window still activates and moves it.

Background And Materials

or About window should replace the default window background with a subtle

frosted material.

colors.

is part of the design.

Window Behavior

such as a custom About window where minimizing adds little value.

the window's content has one intended size.

next launch, such as About panels, transient support/info windows, or

first-run welcome surfaces.

reopening prior size and position is desirable.

setting. Use restorationBehavior(...) only when a specific window should

intentionally opt into or out of that system behavior.

on launch, such as a welcome window, and choose that behavior intentionally

rather than relying on side effects from scene creation order.

Window Placement

initial size and optional position of newly opened windows.

the content's ideal size.

after accounting for the menu bar and Dock.

when media or document content may be larger than the display. If no position

is provided, the window is centered by default.

happens when the user chooses Zoom from the Window menu or Option-clicks the

green toolbar button. For media windows, preserve aspect ratio and grow to the

largest size that fits the display.

player windows or document windows from content dimensions.

Borderless And Specialized Windows

make sure the content still provides a clear drag/move affordance and visible

context.

standard titlebar affordances is worth the custom presentation.

the window feel invisible or hard to move.

For concrete window modifier examples, read references/api-snippets.md.

Review Checklist

menus.

or window control placement.

support click-then-drag activation from the background.

from the user's system-wide setting.

context.defaultDisplay.visibleRect when content/display size matters.

Guardrails

Keep the underlying window title meaningful.

lost drag affordance.

user explicitly wants a fresh-start app every launch.

player windows.

.windowMinimizeBehavior, .restorationBehavior, .defaultWindowPlacement,

.windowIdealPlacement, .windowStyle, or .defaultLaunchBehavior already

solve the problem.

When To Use Other Skills

and inspector architecture.

Liquid Glass, or system material adoption.

NSPanel, or responder-chain control.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.