diff --git a/native/Avalonia.Native/src/OSX/AvnWindow.mm b/native/Avalonia.Native/src/OSX/AvnWindow.mm index 4c7341f8347..6611dcc73fc 100644 --- a/native/Avalonia.Native/src/OSX/AvnWindow.mm +++ b/native/Avalonia.Native/src/OSX/AvnWindow.mm @@ -171,9 +171,7 @@ -(CLASS_NAME*_Nonnull) initWithParent: (WindowBaseImpl*_Nonnull) parent content _closed = false; _isEnabled = true; - [self backingScaleFactor]; [self setOpaque:NO]; - [self setBackgroundColor: [NSColor clearColor]]; _isExtended = false; _isTransitioningToFullScreen = false; diff --git a/native/Avalonia.Native/src/OSX/WindowBaseImpl.h b/native/Avalonia.Native/src/OSX/WindowBaseImpl.h index 2baf3b09b5f..7fb002e54f3 100644 --- a/native/Avalonia.Native/src/OSX/WindowBaseImpl.h +++ b/native/Avalonia.Native/src/OSX/WindowBaseImpl.h @@ -90,7 +90,7 @@ BEGIN_INTERFACE_MAP() virtual HRESULT CreateNativeControlHost(IAvnNativeControlHost **retOut) override; - virtual HRESULT SetBlurEnabled(bool enable) override; + virtual HRESULT SetTransparencyMode(AvnWindowTransparencyMode mode) override; virtual HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, IAvnClipboard *clipboard, IAvnDndResultCallback *cb, diff --git a/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm b/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm index 77f53332cdf..9946ad9b10f 100644 --- a/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm +++ b/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm @@ -489,10 +489,11 @@ return S_OK; } -HRESULT WindowBaseImpl::SetBlurEnabled(bool enable) { +HRESULT WindowBaseImpl::SetTransparencyMode(AvnWindowTransparencyMode mode) { START_COM_CALL; - [StandardContainer ShowBlur:enable]; + [Window setBackgroundColor: (mode != Transparent ? [NSColor windowBackgroundColor] : [NSColor clearColor])]; + [StandardContainer ShowBlur: mode == Blur]; return S_OK; } diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 381741cea9d..b74e4ec3b44 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -501,19 +501,17 @@ public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) { if (TransparencyLevel != transparencyLevel) { - if (transparencyLevel >= WindowTransparencyLevel.Blur) - { + if (transparencyLevel > WindowTransparencyLevel.Transparent) transparencyLevel = WindowTransparencyLevel.AcrylicBlur; - } - - if(transparencyLevel == WindowTransparencyLevel.None) - { - transparencyLevel = WindowTransparencyLevel.Transparent; - } TransparencyLevel = transparencyLevel; - _native?.SetBlurEnabled((TransparencyLevel >= WindowTransparencyLevel.Blur).AsComBool()); + _native.SetTransparencyMode(transparencyLevel == WindowTransparencyLevel.None + ? AvnWindowTransparencyMode.Opaque + : transparencyLevel == WindowTransparencyLevel.Transparent + ? AvnWindowTransparencyMode.Transparent + : AvnWindowTransparencyMode.Blur); + TransparencyLevelChanged?.Invoke(TransparencyLevel); } } diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index b90e144eabf..8057b162f53 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -466,6 +466,13 @@ enum AvnAutomationControlType AutomationSeparator, } +enum AvnWindowTransparencyMode +{ + Opaque, + Transparent, + Blur +} + [uuid(809c652e-7396-11d2-9771-00a0c9b4d50c)] interface IAvaloniaNativeFactory : IUnknown { @@ -527,7 +534,7 @@ interface IAvnWindowBase : IUnknown HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut); HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, IAvnClipboard* clipboard, IAvnDndResultCallback* cb, [intptr]void* sourceHandle); - HRESULT SetBlurEnabled(bool enable); + HRESULT SetTransparencyMode(AvnWindowTransparencyMode mode); } [uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91), cpp-virtual-inherits]