Skip to content

Commit 0cad29b

Browse files
authored
Merge pull request AvaloniaUI#8165 from AvaloniaUI/fixes/position-osx
Fix more OSX regressions
2 parents db20d69 + 55d8bd3 commit 0cad29b

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

native/Avalonia.Native/src/OSX/PopupImpl.mm

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,6 @@ virtual NSWindowStyleMask GetStyle() override
3333
return NSWindowStyleMaskBorderless;
3434
}
3535

36-
virtual HRESULT Resize(double x, double y, AvnPlatformResizeReason reason) override
37-
{
38-
START_COM_CALL;
39-
40-
@autoreleasepool
41-
{
42-
if (Window != nullptr)
43-
{
44-
[Window setContentSize:NSSize{x, y}];
45-
46-
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(lastPositionSet))];
47-
}
48-
49-
return S_OK;
50-
}
51-
}
52-
5336
public:
5437
virtual bool ShouldTakeFocusOnShow() override
5538
{

native/Avalonia.Native/src/OSX/WindowBaseImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ BEGIN_INTERFACE_MAP()
3535
ComPtr<IAvnGlContext> _glContext;
3636
NSObject <IRenderTarget> *renderTarget;
3737
AvnPoint lastPositionSet;
38+
bool hasPosition;
3839
NSSize lastSize;
3940
NSSize lastMinSize;
4041
NSSize lastMaxSize;

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
View = [[AvnView alloc] initWithParent:this];
3030
StandardContainer = [[AutoFitContentView new] initWithContent:View];
3131

32-
lastPositionSet.X = -1;
33-
lastPositionSet.Y = -1;
32+
lastPositionSet = { 0, 0 };
33+
hasPosition = false;
3434
lastSize = NSSize { 100, 100 };
3535
lastMaxSize = NSSize { CGFLOAT_MAX, CGFLOAT_MAX};
3636
lastMinSize = NSSize { 0, 0 };
@@ -91,9 +91,12 @@
9191
CreateNSWindow(isDialog);
9292
InitialiseNSWindow();
9393

94-
if(lastPositionSet.X >= 0 && lastPositionSet.Y >= 0)
94+
if(hasPosition)
9595
{
9696
SetPosition(lastPositionSet);
97+
} else
98+
{
99+
[Window center];
97100
}
98101

99102
UpdateStyle();
@@ -287,12 +290,12 @@
287290
}
288291

289292
@try {
293+
lastSize = NSSize {x, y};
294+
290295
if (!_shown) {
291296
BaseEvents->Resized(AvnSize{x, y}, reason);
292297
}
293298

294-
lastSize = NSSize {x, y};
295-
296299
if(Window != nullptr) {
297300
[Window setContentSize:lastSize];
298301
}
@@ -384,6 +387,7 @@
384387

385388
@autoreleasepool {
386389
lastPositionSet = point;
390+
hasPosition = true;
387391

388392
if(Window != nullptr) {
389393
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(point))];
@@ -576,7 +580,6 @@
576580
[Window setContentMaxSize:lastMaxSize];
577581

578582
[Window setOpaque:false];
579-
[Window center];
580583

581584
if (lastMenu != nullptr) {
582585
[GetWindowProtocol() applyMenu:lastMenu];

0 commit comments

Comments
 (0)