Skip to content

feat(macos): add traffic light position customization - #22128

Open
Illustar0 wants to merge 2 commits into
AvaloniaUI:mainfrom
Illustar0:feat/macos-traffic-light-position
Open

feat(macos): add traffic light position customization#22128
Illustar0 wants to merge 2 commits into
AvaloniaUI:mainfrom
Illustar0:feat/macos-traffic-light-position

Conversation

@Illustar0

Copy link
Copy Markdown
Contributor

What does the pull request do?

Adds support for customizing macOS traffic light button positions through MacOSProperties.TrafficLightPosition, including XAML usage.

API

/// <summary>
/// Defines the <c>TrafficLightPosition</c> attached property.
/// </summary>
public static readonly AttachedProperty<Point?> TrafficLightPositionProperty;

/// <summary>
/// Gets the top-leading position of the native macOS window buttons.
/// </summary>
/// <param name="window">The window.</param>
/// <returns>The position in logical units, or <see langword="null"/> when using the system layout.</returns>
public static Point? GetTrafficLightPosition(Window window);

/// <summary>
/// Sets the top-leading position of the native macOS window buttons.
/// </summary>
/// <param name="window">The window.</param>
/// <param name="value">The position in logical units, or <see langword="null"/> to use the system layout.</param>
public static void SetTrafficLightPosition(Window window, Point? value);

Usage

<Window
    ExtendClientAreaToDecorationsHint="True"
    WindowDecorations="Full"
    MacOSProperties.TrafficLightPosition="14,18" />

What is the current behavior?

The macOS traffic light buttons always use the system-provided position. Applications extending content into the title bar cannot align them with a custom title bar layout.

What is the updated/expected behavior with this PR?

Applications can specify the top-leading traffic light position in logical units. Setting the property to null restores the system layout.

How was the solution implemented (if it's not obvious)?

The native implementation keeps explicit System and Custom layout states. It preserves AppKit’s button sizes, spacing, RTL ordering, and tracking areas, while restoring system-owned layout for fullscreen and unsupported decoration modes.

Custom positioning is reapplied after AppKit title-bar layout changes, including initial display, resizing, appearance changes, and window-state transitions.

Electron and Zed implementations were researched to account for relevant AppKit behavior and known edge cases.

Checklist

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

Fixes #21119

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0069330-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@emmauss emmauss added the api-needs-review The PR adds new public APIs that should be reviewed. label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-needs-review The PR adds new public APIs that should be reviewed. feature os-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[macOS] Traffic lights position

4 participants