diff --git a/native/Avalonia.Native/src/OSX/window.h b/native/Avalonia.Native/src/OSX/window.h index 6a4ca2b8d8..b1f64bca88 100644 --- a/native/Avalonia.Native/src/OSX/window.h +++ b/native/Avalonia.Native/src/OSX/window.h @@ -34,7 +34,6 @@ class WindowBaseImpl; -(double) getScaling; -(double) getExtendedTitleBarHeight; -(void) setIsExtended:(bool)value; --(void) updateShadow; @end struct INSWindowHolder diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm index e7c144b2d3..eb63cbd9f9 100644 --- a/native/Avalonia.Native/src/OSX/window.mm +++ b/native/Avalonia.Native/src/OSX/window.mm @@ -50,7 +50,6 @@ public: [Window setBackingType:NSBackingStoreBuffered]; [Window setOpaque:false]; - [Window setContentView: StandardContainer]; } virtual HRESULT ObtainNSWindowHandle(void** ret) override @@ -112,6 +111,9 @@ public: { SetPosition(lastPositionSet); UpdateStyle(); + + [Window setContentView: StandardContainer]; + if(ShouldTakeFocusOnShow() && activate) { [Window makeKeyAndOrderFront:Window]; @@ -125,10 +127,6 @@ public: _shown = true; - dispatch_async(dispatch_get_main_queue(), ^{ - [Window updateShadow]; - }); - return S_OK; } } @@ -195,9 +193,11 @@ public: { if(ret == nullptr) return E_POINTER; + auto frame = [View frame]; ret->Width = frame.size.width; ret->Height = frame.size.height; + return S_OK; } } @@ -258,6 +258,11 @@ public: y = maxSize.height; } + if(!_shown) + { + BaseEvents->Resized(AvnSize{x,y}); + } + [Window setContentSize:NSSize{x, y}]; return S_OK; @@ -1842,19 +1847,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent double _lastScaling; } -- (void)updateShadow -{ - // Common problem in Cocoa where [invalidateShadow] does work, - // This hack forces Cocoa to invalidate the shadow. - - NSRect frame = [self frame]; - NSRect updatedFrame = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width + 1.0, frame.size.height + 1.0); - [self setFrame:updatedFrame display:YES]; - [self setFrame:frame display:YES]; - - [self invalidateShadow]; -} - -(void) setIsExtended:(bool)value; { _isExtended = value; @@ -2013,7 +2005,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent _lastScaling = [self backingScaleFactor]; [self setOpaque:NO]; [self setBackgroundColor: [NSColor clearColor]]; - [self invalidateShadow]; _isExtended = false; return self; } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 273ed790c3..700c3d9bad 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -668,10 +668,11 @@ namespace Avalonia.Controls Owner = parent; parent?.AddChild(this, false); - - PlatformImpl?.Show(ShowActivated); - Renderer?.Start(); + SetWindowStartupLocation(Owner?.PlatformImpl); + + PlatformImpl?.Show(ShowActivated); + Renderer?.Start(); } OnOpened(EventArgs.Empty); } @@ -739,6 +740,9 @@ namespace Avalonia.Controls PlatformImpl?.SetParent(owner.PlatformImpl); Owner = owner; owner.AddChild(this, true); + + SetWindowStartupLocation(owner.PlatformImpl); + PlatformImpl?.Show(ShowActivated); Renderer?.Start(); @@ -756,8 +760,6 @@ namespace Avalonia.Controls OnOpened(EventArgs.Empty); } - SetWindowStartupLocation(owner.PlatformImpl); - return result.Task; }