Skip to content

Move the macOS window buttons in from the window edge - #56

Merged
chrislaupama merged 3 commits into
mainfrom
window-button-inset
Nov 14, 2026
Merged

chrislaupama merged 3 commits into
mainfrom
window-button-inset

Conversation

@chrislaupama

@chrislaupama chrislaupama commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

What

On macOS the main window's close, minimise and zoom buttons sat at AppKit's default position, 9 pt from the window's top-left corner: tight against the edge and above the header's title row.

They now sit on the header's title row, 17 pt clear of the left and top edges at 100 % interface zoom (close button centred 24 pt from the corner), and the inset follows View › Zoom like the rest of the header.

  • New crates/dstudio-app/src/window_buttons.rs: grows the titlebar container so the buttons stay clickable and moves the three buttons, keeping AppKit's own spacing between them. Skipped in full screen. No-op off macOS.
  • AppKit lays the titlebar out again on resize, focus and display changes, so the placement is re-applied on those window events, after an interface zoom change, and on NSWindowDidExitFullScreenNotification (winit's last resize of a full-screen exit arrives while the window is still in full screen). When the buttons are already in place it only reads frames.
  • Two small unit tests for the placement maths (17 pt at 100 %, follows zoom).

Checked on macOS (debug build, 1x display): close button at 17 pt / 17 pt after launch, after resizing (1200×760, 1500×900), switching apps and back, minimise and restore, Zoom In (18 pt at 105 %) and Reset Zoom, and after three full-screen exits (toggle and green button). Hovering still shows the button glyphs.

Screenshots

Top-left corner, before and after:

Window buttons before and after

Before (9 pt) After (17 pt)
Main window before Main window after

Benchmarks

No render-path change: the placement runs only on resize, focus, display, zoom and full-screen-exit events, never per frame.

Docs

  • README.md is still accurate
  • PROGRESS.md and docs/ need no change

The close, minimise and zoom buttons sat at AppKit's default 9 pt from the
top-left corner, tight against the edge and above the header's title row.
Centre them on the title row instead: 17 pt clear of the left and top edges
at 100 % interface zoom, following the zoom like the rest of the header.
AppKit lays the titlebar out again on resize, focus and display changes, so
the placement is re-applied on those window events.
…de error

winit's last resize of the full-screen exit arrives while the window is still
in full screen, so AppKit's own layout put the buttons back at the top edge
until the next focus change. Observe NSWindowDidExitFullScreenNotification and
place them again then (and once more after the next layout pass).

The placement maths is only used by the macOS path and the tests, so allow
dead code on other platforms.
@chrislaupama
chrislaupama marked this pull request as ready for review November 14, 2026 03:51
@chrislaupama
chrislaupama merged commit b87d7e9 into main Nov 14, 2026
16 checks passed
@chrislaupama
chrislaupama deleted the window-button-inset branch November 14, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant