Repository navigation
feat(windowing): Custom title bars on macOS and caption button colors on Win32 - #25203
Conversation
Verified on Skia macOS, fixes pushedTested on .NET 11 RC1, Works
Found and fixed
Fixes 1 and 2 were pushed to #25190, with the fix and test in separate commits. The tests are Win32-only there; this PR enables them on macOS. Fix 3 is a single commit here and has no automated test, because it needs real input. Runtime tests on macOS (title bar, AppWindow, InputNonClientPointerSource, InputActivationListener, XamlRoot): 24 passed, 3 failed, 5 skipped.
Still needs a check at the Mac:
Region log, before → after🤖 Generated with Claude Code |
Verified the caption-button commits on Skia macOS (
|
d6993e1 to
6429f01
Compare
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25203/docs/index.html |
|
Claude finished @MartinZikmund's task in 22s —— View job Review summaryVerdict: ship, pending a Mac check and the screenshot-diff review. I found nothing blocking and posted no inline comments. Issues by severity: blocker 0, major 0, minor 0, nit 1. This was a light pass, not a full read of the diff. I could not build or run anything here, so the points below come from reading the code, with no compile or runtime validation of my own. What I looked at
On the
Cross-cutting notes
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25203/wasm-skia-net9/index.html |
|
The build 239416 found UI Test snapshots differences: Details
|
|
|
74acb64 to
823512b
Compare
|
Claude finished @MartinZikmund's task in 15s —— View job Review summaryVerdict: ship, pending the on-Mac checks and the screenshot-diff review. I found nothing blocking and posted no inline comments. Issues by severity: blocker 0, major 0, minor 0, nit 0. This was a light pass. The checkout has no merge base with
Cross-cutting concerns
|
🤖 Addressed PR comments up to this point
|
Unit tests for the inset and region-to-action math. macOS runtime tests for LeftInset, the default and SetTitleBar drag regions, Passthrough precedence through the native hit-test path, and a TitleBar smoke test. The existing TitleBar Passthrough test now also runs on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…m the start The wrapper converted the initial host size and position to physical pixels before setting RasterizationScale, which is still 0 at that point. AppWindow.Size, ClientSize and Position therefore read 0 until the window was next resized or moved. A later scale change (moving to another screen) also left them in the old scale. Set the scale first, and recompute both from the last logical values when the scale changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…ctivation Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…affic lights - SetBorderAndTitleBar(true, false) now keeps the native frame (shadow, rounded corners, resizing) and hides the title bar and all three traffic lights, so apps can draw their own caption buttons like on Windows. Previously it dropped NSWindowStyleMaskTitled. LeftInset becomes 0. Only hasBorder: false as well makes the window untitled. - IsMinimizable/IsMaximizable/IsResizable disable (not hide) the minimize/zoom buttons, re-applied when AppKit recreates the buttons. - Minimize/Maximize/Close no longer depend on a visible native button: miniaturize:/zoom: replace performMiniaturize:/performZoom:, which beep without one (performZoom: also un-zoomed an already zoomed window), and Close asks the delegate itself when there is no usable close button. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…ttable on Skia Getting any of them threw NotImplementedException on every Skia target, so title bar code shared with WinAppSDK crashed on Uno desktop. They are now stored values. Skia desktop hosts don't apply them: macOS draws its title bar and traffic lights itself, and Win32 doesn't use them yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Native button disabling from IsMinimizable/IsMaximizable/IsResizable, SetBorderAndTitleBar(true, false) hiding the traffic lights (LeftInset 0, content under the bar, app Caption region drags), presenter commands and Close with the title bar hidden, the collapsed XAML caption container, and settable AppWindowTitleBar colors on every platform. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…n macOS Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A press on a drag region activates the app and window before dragging, as HTCAPTION does on Win32. Skipping AppKit had also skipped its click-to-focus. - The non-client regions apply whether or not the content is extended into the title bar, as on Win32. - The first click into an inactive app over XAML in the title bar band only activates it, instead of letting AppKit's transparent titlebar start a drag or zoom on top of the element. - PointerActivated also covers a click that activates the app, where the current event is the app activation, and no longer covers a window made key by code from another window's press handler. - Entering and leaving full screen refreshes the insets, which could miss the last resize of the transition. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… keep Minimize before activation - Extending into, or hiding, the title bar resizes the content view without a windowDidResize, and the paused Metal view does not report its new drawable size. The XAML content therefore kept its old size. Report it explicitly for every rendering path. - miniaturize: does nothing on a window that isn't shown yet, so record the Minimized state that uno_window_activate applies later (the replaced performMiniaturize: override used to). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…restoring from the Dock Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
AppKit keeps the content size when the full-size content view style is toggled, so hiding the title bar (SetBorderAndTitleBar(true, false)) or extending into it shrank the window by the title bar height instead of letting the content grow under it. Win32 keeps the outer size, so restore the frame after the style change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tended Like CWindowChrome::OnTitleBarSizeChanged in WinUI. The rect was registered regardless, so after turning ExtendsContentIntoTitleBar off the element's area kept dragging the window, on Win32 and now on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closing a minimized secondary window trips the known macOS crash where a closed UNOWindow is freed mid-close (releasedWhenClosed under ARC), which segfaulted a later test. Restore it first, with a timeout that allows for the slow Dock animation on CI VMs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…mes key windowDidBecomeKey compared NSApp.currentEvent.window to self. The current event can be stale and point at a secondary window that was already closed and freed (a closed UNOWindow is released mid-close), and -[NSEvent window] hands it back retained and autoreleased. The next pool drain then segfaulted in objc_release: the macOS runtime tests crashed during window and full-screen tests. Compare window numbers instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
CI VMs never complete the restore from the Dock, and the minimized window was left behind. Given_AppWindow already covers Minimize. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…aption buttons The XAML caption buttons that WindowChrome draws on Skia Win32 now follow ButtonForeground/BackgroundColor, the Hover, Pressed and Inactive variants, the way the system caption buttons do on WinAppSDK: - null means the theme default, and changes apply immediately. - The inactive colors apply while the window is deactivated. - The Close button keeps its system hover and pressed colors. - Only the background colors keep their alpha channel. As CWindowChrome does, the first Window.ExtendsContentIntoTitleBar opt-in sets ButtonBackgroundColor and ButtonInactiveBackgroundColor to Transparent. The caption button template no longer sets colors from visual states. Its setters targeted a nonexistent "Path" element, so the hover and pressed glyph colors (white on the red Close hover) were never applied. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
…aption buttons Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7
Master's Given_UnitTestUIThread guard requires [UITestClass] on every unit test class with tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
823512b to
ef48a0d
Compare
|
Claude finished @MartinZikmund's task in 43s —— View job Review summaryVerdict: ship, pending the on-Mac checks and the screenshot-diff review. I found nothing blocking and posted no inline comments. Issues by severity: blocker 0, major 0, minor 0, nit 1. This was a light pass, not a full read of the diff. The checkout has no merge base with
Cross-cutting concerns
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25203/docs/index.html |
1 similar comment
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25203/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25203/wasm-skia-net9/index.html |
|
The build 239429 found UI Test snapshots differences: Details
|
|
/azp run |
GitHub Issue: closes #25247, closes #24065; related #15789, #24864, #19392, #22420, #21714
PR Type:
✨ Feature
What changed? 🚀
On Skia macOS, custom title bars did nothing:
ExtendsContentIntoTitleBaronly logged "customization is not supported":AppWindowTitleBar.IsCustomizationSupported()was Windows-only.SetTitleBarandInputNonClientPointerSourceregions were ignored, because the host had noINativeInputNonClientPointerSource.LeftInsetstayed 0.Window.Activatednever reportedDeactivatedor re-activation.The WinUI
TitleBarcontrol made working on Skia by #25190 therefore could not act as a real title bar on macOS. This PR adds that, following WinUI semantics and keeping the native traffic lights.It also makes the
AppWindowTitleBarbutton colors work on Skia Win32, where Uno draws the caption buttons in XAML (see Caption button colors on Win32).Before / after on macOS
ExtendsContentIntoTitleBarNSWindowStyleMaskFullSizeContentView, transparent titlebar, hidden title.WindowChromeskips its XAML min/max/close buttons via the newNativeWindowWrapperBase.HasNativeCaptionButtonsAppWindowTitleBar.Height(Standard 32 / Tall 48), using Electron'strafficLightPositiontechnique. Re-applied after AppKit relayouts: resize, key change, full-screen exit, title and style changesPreferredHeightOption.CollapsedWindowChromedoes for its XAML buttons)LeftInset/RightInsetLeftInset= traffic-light width plus matching trailing spacing, in physical px like WinUI. RTL system layouts put it inRightInset. 0 in full screenLeftInset > 0,RightInset == 0, reset on un-extend)SetTitleBar/InputNonClientPointerSourceMacOSWindowWrapperimplementsINativeInputNonClientPointerSourceon the sharedNonClientRegionSet, which has the same Passthrough-first precedence as the #25190 Win32 fixperformWindowDragWithEvent:AppleActionOnDoubleClick: Maximize/Fill →zoom:, Minimize, None; legacyAppleMiniaturizeOnDoubleClick)SetTitleBar)AppWindowTitleBar.Height, matching WinUI's default and Win32'sGetDefaultCaptionRegionRectActivatedfired oncewindowDidBecomeKey/windowDidResignKey→ActivationState(PointerActivatedwhen a mouse-down made the window key). This feedsWindow.Activated,InputActivationListenerand TitleBar's inactive visualsContentIslandEnvironmentAppWindow.Size/ClientSize/PositionRasterizationScaleafter converting the initial size/position. It now sets it first and recomputes both on scale changeGiven_AppWindow.When_Activated_ClientSize_Is_Physical_Content_Size(found when CI showed the default drag strip as 0 px wide)IsMinimizable/IsMaximizable/IsResizable= falseSetBorderAndTitleBar(true, false)NSWindowStyleMaskTitled: no rounded corners, no native frameLeftInset0, so apps draw their own caption buttons like on Windows.(false, false)still makes the window untitled. Toggling at runtime re-applies and re-reports the insets, soTitleBarre-padsLeftInset0 and back, content grows under the hidden bar, an app Caption region dragswindowDidResize, and the paused Metal view does not report its new drawable sizeMinimize()/Maximize()usedperformMiniaturize:/performZoom:andClose()usedperformClose:. Those need a visible button and only beep without one;performZoom:also un-zoomed an already zoomed windowminiaturize:,zoom:(only when not already zoomed), and forClose()with no usable close button the delegate is asked and thencloseis calledAppWindowTitleBar.Button*Color,BackgroundColor,ForegroundColor,Inactive*Color,IconShowOptionsNotImplementedExceptionon every Skia target, Win32 included, so shared title bar code crashedButton*Colorproperties are applied (next section)Caption buttons on macOS: native, not XAML
On Win32, Uno draws min/max/close itself in XAML (
WindowChrome), because Windows stops drawing them once the content extends into the title bar. macOS keeps drawing the native traffic lights over a full-size, transparent-titlebar content view, so this PR keeps them. Drawing them in XAML would lose the group hover glyphs, the zoom long-press tiling menu, option-click, full screen, accessibility and appearance changes.WindowChromeis shared, so its template still contains the XAML caption buttons. On macOS (HasNativeCaptionButtons) they stayCollapsedand are never registered as non-client regions or insets; a runtime test asserts both.SetBorderAndTitleBar(true, false), draw XAML buttons and callMinimize()/Maximize()/Restore()/Close(). Or keep the native buttons and useIsMinimizable/IsMaximizable/IsResizableto disable them.Caption button colors on Win32
On Skia Win32,
WindowChromedraws min/max/close in XAML while the content extends into the title bar. Those buttons now follow theAppWindowTitleBarbutton colors, matching how WinAppSDK's system caption buttons handle them:ButtonForegroundColor/ButtonBackgroundColorwhile activeButtonInactiveForegroundColor/ButtonInactiveBackgroundColorwhile deactivatedWindow.ActivatedButtonHover*/ButtonPressed*PointerOver/PressedstatesCloseButton*theme brushesnull= defaultWindowCaption*theme resources and follows theme changesAppWindowTitleBarraises an internal change eventWindow.ExtendsContentIntoTitleBar = truesetsButtonBackgroundColorandButtonInactiveBackgroundColortoTransparent, once per windowCWindowChrome::ConfigureWindowChromeThe
WindowCaptionButtontemplate no longer sets colors from its visual states. Those setters targeted aPathelement that doesn't exist in Uno'sFontIcon-based template, so hover/pressed glyph colors (white glyph on the red Close hover) were never applied.WindowChromenow setsBackground/Foregroundper state in code.Not applied yet on Win32:
BackgroundColor,ForegroundColor,InactiveBackgroundColor,InactiveForegroundColor(the title bar itself is app content when extended) andIconShowOptions.Not applicable on macOS (documented, no-op)
AppWindowTitleBar.Button*Color,BackgroundColor/ForegroundColor,IconShowOptions: settable and readable, but not applied. The traffic lights and the system title bar are drawn by AppKit, with no recoloring API.NonClientRegionKind.Close/Minimize/Maximizeand the border kinds: no macOS equivalent over the content, so they stay client.Icondrags likeCaption, because macOS has no system menu.Docs
doc/articles/features/windows-ui-xaml-window.md: support notes now include macOS, plus "macOS specifics" and "Caption button colors on Windows" sections.Shared code
refactor(input): Win32's region dictionary and precedence loop moved intoUno.UI.UI.Input.Internal.NonClientRegionSet, used by both hosts.MacOSTitleBarMathholds the inset and region→action math as a pure helper, linked intoUno.UI.UnitTestslike the Win32/X11 pointer math.WinUI parity note
As found in #25190, WinUI reports insets in physical pixels and
TitleBar.UpdatePaddinguses them as DIPs. On a 2x Retina screen the TitleBar's left padding column is therefore about twice the traffic-light width (~132 DIP). This is kept for parity, the same way Win32 at 250% is.Validation
Given_NonClientRegionSetandGiven_MacOSTitleBarMath, 19/19 pass.SamplesAppnet10.0-desktop):Given_InputNonClientPointerSource(including the realWM_NCHITTESTtest on the refactored path),Given_InputActivationListener,Given_TitleBar,Given_AppWindow,Given_AppWindowTitleBar. 14 passed; the macOS-only tests skip.Given_AppWindowTitleBar, Skia Win32, all pass locally on net11.0-desktop): colors set/changed/reset to null (alpha handling), hover and pressed colors with Close keeping system colors, inactive colors after another window activates.When_Window_Extends_Caption_Button_Backgrounds_Default_To_Transparentruns on Win32, macOS and native WinUI. The existingGiven_TitleBartests still pass on Win32.SkiaMacOSonly):Given_AppWindowTitleBar: insets, Collapsed, default drag strip, no XAML caption regions (and the XAML caption container is Collapsed), presenter options disabling the native buttons, hidden title bar (buttons hidden,LeftInset0, content under it, app Caption drags), presenter commands (Maximize/Restore/Minimize) and Close with the title bar hidden. Restoring from the Dock is manual-only, because CI VMs block the main thread for seconds on the minimize animation.Given_AppWindowTitleBar.When_Colors_Set_They_Are_Keptruns on all platforms.Given_InputNonClientPointerSource.When_Passthrough_Overlaps_Caption_On_MacOS_Passthrough_Is_Client.Given_InputActivationListener.When_Key_Window_Changes_Activation_Follows.Given_AppWindow.When_Activated_ClientSize_Is_Physical_Content_Size(Win32 + macOS; passes on Win32 locally).Given_TitleBar.When_Extended_Into_TitleBar_On_MacOS_Content_Avoids_Traffic_Lights_And_Drags.Given_TitleBar.When_Content_Set_Interactive_Elements_Are_Passthroughnow also runs on macOS.Needs manual verification on a Mac
ExtendsContentIntoTitleBar = true: content draws under the title bar, no title text, traffic lights visible and clickable (close/minimize/zoom, hover glyphs, option-click zoom).AppWindow.Title. Toggling extend off restores the stock titlebar.TitleBar+SetTitleBar: back, pane toggle,Content(e.g. AutoSuggestBox, including typing) andRightHeaderbuttons get clicks in the top 28pt band without moving or zooming the window. Dragging the title text area moves the window.Window.ActivatedreportsDeactivated/PointerActivated.PreferredHeightOption = Collapsedhides the traffic lights.OverlappedPresenter.SetBorderAndTitleBar(true, false)and back keeps a consistent state.IsMinimizable/IsMaximizable/IsResizable = false: the matching traffic light is greyed out and does nothing; the zoom long-press menu and green-button full screen respect it. Toggling back re-enables them.SetBorderAndTitleBar(true, false): all traffic lights are gone, and the window keeps its shadow, rounded corners and edge resizing. XAML custom buttons callingMinimize(),Maximize()/Restore()andWindow.Close()work, including restoring from the Dock. Full screen entered from a custom button (AppWindow.SetPresenter(FullScreen)) and exited works. Toggling back to(true, true)brings the native buttons back at the right position, and aTitleBarre-pads.ButtonForegroundColoretc. doesn't throw and changes nothing.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_013yZfe9CjkLZqGRwjwfXyQ7