Browse Source

[OSX] fix SetParent

pull/8211/head
Dan Walmsley 4 years ago
parent
commit
0a4b3386d5
  1. 1
      native/Avalonia.Native/src/OSX/WindowImpl.h
  2. 13
      native/Avalonia.Native/src/OSX/WindowImpl.mm

1
native/Avalonia.Native/src/OSX/WindowImpl.h

@ -22,6 +22,7 @@ private:
bool _transitioningWindowState;
bool _isClientAreaExtended;
bool _isDialog;
WindowImpl* _lastParent;
AvnExtendClientAreaChromeHints _extendClientHints;
FORWARD_IUNKNOWN()

13
native/Avalonia.Native/src/OSX/WindowImpl.mm

@ -20,6 +20,7 @@ WindowImpl::WindowImpl(IAvnWindowEvents *events, IAvnGlContext *gl) : WindowBase
_lastWindowState = Normal;
_actualWindowState = Normal;
_lastTitle = @"";
_lastParent = nullptr;
WindowEvents = events;
}
@ -61,6 +62,11 @@ void WindowImpl::OnInitialiseNSWindow(){
[GetWindowProtocol() setIsExtended:true];
SetExtendClientArea(true);
}
if(_lastParent != nullptr)
{
SetParent(_lastParent);
}
}
HRESULT WindowImpl::Show(bool activate, bool isDialog) {
@ -97,6 +103,10 @@ HRESULT WindowImpl::SetParent(IAvnWindow *parent) {
if (cparent == nullptr)
return E_INVALIDARG;
_lastParent = cparent;
if(Window != nullptr){
// If one tries to show a child window with a minimized parent window, then the parent window will be
// restored but macOS isn't kind enough to *tell* us that, so the window will be left in a non-interactive
// state. Detect this and explicitly restore the parent window ourselves to avoid this situation.
@ -107,6 +117,7 @@ HRESULT WindowImpl::SetParent(IAvnWindow *parent) {
[cparent->Window addChildWindow:Window ordered:NSWindowAbove];
UpdateStyle();
}
return S_OK;
}
@ -535,7 +546,7 @@ NSWindowStyleMask WindowImpl::GetStyle() {
break;
case SystemDecorationsFull:
s = s | NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskBorderless;
s = s | NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
if (_canResize) {
s = s | NSWindowStyleMaskResizable;

Loading…
Cancel
Save