Skip to content

Navigation Menu

Sign in
Sign up

feat(platform): let apps offset the window-control cluster - #312

Open
alvgaona wants to merge 2 commits into
vercel-labs:main from
alvgaona:feat/window-controls-offset
Open

feat(platform): let apps offset the window-control cluster #312
alvgaona wants to merge 2 commits into
vercel-labs:main from
alvgaona:feat/window-controls-offset

Conversation

@alvgaona

@alvgaona alvgaona commented Aug 10, 2026
edited
Loading

Copy link
Copy Markdown

Problem

I have been experimenting quite a lot with Native SDK and its macOS window management and configuration. I've reached a pain point which is that I cannot accommodate the traffic lights properly while using the property .titlebar = "hidden_inset" in app.zon.

I wanted to have squarer corners—which hidden_inset would provide to me—and I wasn't able to do it because Native SDK does not (or did not) expose offset controls for the window. Below I provide some visual examples.

This first image is with .titlebar = "hidden_inset_tall which has rounder corners and aligns the traffic lights somewhat nice for my use case.

2026年08月10日 at 22 11 59@2x

The second image is .titlebar = "hidden_inset" which gives us squarer corners but doesn't fit the alignment. Also, it has very tight padding around traffic lights.

2026年08月10日 at 22 17 45@2x

Fix

So now this PR tackles this issue right at its core by allowing to perfectly place the traffic lights where the user needs it to be placed. The properties exposed are:

  • window_controls_offset_x (default: 0)
  • window_controls_offset_y (default: 0)

The offset is pixel-based and the origin is at the top left corner with +x to the right and +y downwards.

Note

The PR was LLM assisted, in particular the file appkit_host.m where I lack experience in. I tried making the changes align the code base style and structure to the best of my ability while making this feature completely additive without removing or modifying production code.

jhodges10 reacted with heart emoji

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@alvgaona is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread src/platform/types.zig

Copy link
Copy Markdown
Contributor

Thanks for working on this @alvgaona! I was running into the same problem.

alvgaona reacted with heart emoji

A titlebar style fixes both the band's height and where the system
centres the window controls in it. An app whose own header is a
different height than any offered band therefore cannot line its content
up with them — the only lever was picking a different band, which
changes the window's whole shape (on macOS 26 the tall band also rounds
the window corner harder).
`WindowOptions.window_controls_offset` decouples the two: keep the band
you want and put the controls on your own centreline. Declared in
app.zon as `.window_controls_offset_x` / `_y`, positive right and down,
zero (the default) leaving the platform's placement untouched.
macOS moves the three `standardWindowButton` views; every other platform
ignores it, the same honest no-op `WindowChrome.insets` already reports
on the edge a platform does not use.
The offset is REMEMBERED rather than applied once. AppKit relays those
views out on its own schedule — entering and leaving fullscreen — so the
host stores it and re-applies after each, and each apply sets an
absolute origin from a captured base rather than nudging what is there,
so repeated applies cannot walk the buttons across the titlebar.
Nothing to add for reporting: `chromeInsetsForWindowId:` already derives
`WindowChrome.buttons` by unioning the real button frames, so an app
centring against the cluster sees the moved position with no second
source of truth.
The conversion to WindowOptions dropped the field, so imperatively
created windows always got the default (0, 0) offset. The null platform
now captures the offset at create, and a test covers both a window that
declares one and a window that does not.
alvgaona force-pushed the feat/window-controls-offset branch from d6541a7 to 98296c4 Compare August 23, 2026 19:08

alvgaona commented Aug 23, 2026
edited
Loading

Copy link
Copy Markdown
Author

@ctate sorry for the tag but I'd like your feedback for this PR. Thanks!

@ctate ctate added the enhancement New feature or request label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vercel vercel[bot] vercel[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /