Browse Source

[OSX] Use non-opaque window background for non-transparent windows

pull/9469/head
Nikita Tsukanov 3 years ago
parent
commit
bb1469dbff
  1. 2
      native/Avalonia.Native/src/OSX/AvnWindow.mm
  2. 2
      native/Avalonia.Native/src/OSX/WindowBaseImpl.h
  3. 5
      native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
  4. 16
      src/Avalonia.Native/WindowImplBase.cs
  5. 9
      src/Avalonia.Native/avn.idl

2
native/Avalonia.Native/src/OSX/AvnWindow.mm

@ -171,9 +171,7 @@
_closed = false;
_isEnabled = true;
[self backingScaleFactor];
[self setOpaque:NO];
[self setBackgroundColor: [NSColor clearColor]];
_isExtended = false;
_isTransitioningToFullScreen = false;

2
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,

5
native/Avalonia.Native/src/OSX/WindowBaseImpl.mm

@ -489,10 +489,11 @@ HRESULT WindowBaseImpl::CreateNativeControlHost(IAvnNativeControlHost **retOut)
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;
}

16
src/Avalonia.Native/WindowImplBase.cs

@ -501,19 +501,17 @@ namespace Avalonia.Native
{
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);
}
}

9
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]

Loading…
Cancel
Save