Browse Source

[OSX] GetFrameSize - explicitly detect when native side didnt touch result object to signal null.

pull/8154/head
Dan Walmsley 4 years ago
parent
commit
3e8ce3deb1
  1. 6
      native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
  2. 8
      src/Avalonia.Native/WindowImplBase.cs
  3. 2
      src/Avalonia.Native/avn.idl

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

@ -205,11 +205,7 @@ HRESULT WindowBaseImpl::GetFrameSize(AvnSize *ret) {
if (ret == nullptr)
return E_POINTER;
if(Window == nullptr){
ret->Width = 0;
ret->Height = 0;
}
else {
if(Window != nullptr){
auto frame = [Window frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;

8
src/Avalonia.Native/WindowImplBase.cs

@ -116,8 +116,12 @@ namespace Avalonia.Native
{
if (_native != null)
{
var s = _native.FrameSize;
return s.Width == 0 && s.Height == 0 ? null : new Size(s.Width, s.Height);
unsafe
{
var s = new AvnSize { Width = -1, Height = -1 };
_native.GetFrameSize(&s);
return s.Width < 0 && s.Height < 0 ? null : new Size(s.Width, s.Height);
}
}
return default;

2
src/Avalonia.Native/avn.idl

@ -504,7 +504,7 @@ interface IAvnWindowBase : IUnknown
HRESULT Close();
HRESULT Activate();
HRESULT GetClientSize(AvnSize*ret);
HRESULT GetFrameSize(AvnSize*ret);
HRESULT GetFrameSize(AvnSize*result);
HRESULT GetScaling(double*ret);
HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize);
HRESULT Resize(double width, double height, AvnPlatformResizeReason reason);

Loading…
Cancel
Save