diff --git a/native/Avalonia.Native/inc/avalonia-native.h b/native/Avalonia.Native/inc/avalonia-native.h index 7f19409850..222135557c 100644 --- a/native/Avalonia.Native/inc/avalonia-native.h +++ b/native/Avalonia.Native/inc/avalonia-native.h @@ -209,8 +209,9 @@ enum AvnExtendClientAreaChromeHints AvnChromeHintsNoChrome, AvnChromeHintsSystemTitleBar = 0x01, AvnChromeHintsManagedChromeButtons = 0x02, - AvnChromeHintsPreferSystemChromeButtons = 0x04, + AvnChromeHintsSystemChromeButtons = 0x04, AvnChromeHintsOSXThickTitleBar = 0x08, + AvnChromeHintsDefault = AvnChromeHintsSystemTitleBar | AvnChromeHintsSystemChromeButtons, }; AVNCOM(IAvaloniaNativeFactory, 01) : IUnknown diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm index e17f378820..e593e7e6db 100644 --- a/native/Avalonia.Native/src/OSX/window.mm +++ b/native/Avalonia.Native/src/OSX/window.mm @@ -488,7 +488,7 @@ private: WindowImpl(IAvnWindowEvents* events, IAvnGlContext* gl) : WindowBaseImpl(events, gl) { _isClientAreaExtended = false; - _extendClientHints = AvnChromeHintsSystemTitleBar; + _extendClientHints = AvnChromeHintsDefault; _fullScreenActive = false; _canResize = true; _decorations = SystemDecorationsFull; @@ -507,8 +507,17 @@ private: if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")]) { NSView *titlebarView = [subview subviews][0]; for (id button in titlebarView.subviews) { - if ([button isKindOfClass:[NSButton class]]) { - [button setHidden: (_decorations != SystemDecorationsFull)]; + if ([button isKindOfClass:[NSButton class]]) + { + if(_isClientAreaExtended) + { + [button setHidden: !(_extendClientHints & AvnChromeHintsSystemChromeButtons)]; + } + else + { + [button setHidden: (_decorations != SystemDecorationsFull)]; + } + [button setWantsLayer:true]; } } @@ -806,6 +815,8 @@ private: [Window setIsExtended:enable]; + HideOrShowTrafficLights(); + UpdateStyle(); return S_OK; diff --git a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs index 1c485aa6a9..939f44d772 100644 --- a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs +++ b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs @@ -70,6 +70,11 @@ namespace ControlCatalog.ViewModels { ChromeHints = ExtendClientAreaChromeHints.NoChrome | ExtendClientAreaChromeHints.OSXThickTitleBar; + if(x.Item1) + { + ChromeHints |= ExtendClientAreaChromeHints.SystemChromeButtons; + } + if(x.Item2) { ChromeHints |= ExtendClientAreaChromeHints.ManagedChromeButtons; diff --git a/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs b/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs index b59d0ffe2e..022b609699 100644 --- a/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs +++ b/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs @@ -9,9 +9,11 @@ namespace Avalonia.Platform Default = SystemTitleBar, SystemTitleBar = 0x01, ManagedChromeButtons = 0x02, - PreferSystemChromeButtons = 0x04, + SystemChromeButtons = 0x04, OSXThickTitleBar = 0x08, + + PreferSystemChromeButtons = 0x10, AdaptiveChromeWithTitleBar = SystemTitleBar | PreferSystemChromeButtons, AdaptiveChromeWithoutTitleBar = PreferSystemChromeButtons, diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index 8146a712a3..e881251ae9 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/src/Avalonia.Native/WindowImpl.cs @@ -149,6 +149,11 @@ namespace Avalonia.Native public void SetExtendClientAreaChromeHints(ExtendClientAreaChromeHints hints) { + if(hints.HasFlag(ExtendClientAreaChromeHints.PreferSystemChromeButtons)) + { + hints |= ExtendClientAreaChromeHints.SystemChromeButtons; + } + _native.SetExtendClientAreaHints ((AvnExtendClientAreaChromeHints)hints); }