Browse Source

Merge branch 'master' into rndr4

pull/8105/head
Dan Walmsley 4 years ago
committed by GitHub
parent
commit
4b8460abd5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      native/Avalonia.Native/inc/rendertarget.h
  2. 4
      native/Avalonia.Native/src/OSX/AutoFitContentView.h
  3. 6
      native/Avalonia.Native/src/OSX/AutoFitContentView.mm
  4. 30
      native/Avalonia.Native/src/OSX/Avalonia.Native.OSX.xcodeproj/project.pbxproj
  5. 11
      native/Avalonia.Native/src/OSX/AvnPanelWindow.mm
  6. 10
      native/Avalonia.Native/src/OSX/AvnView.h
  7. 10
      native/Avalonia.Native/src/OSX/AvnView.mm
  8. 216
      native/Avalonia.Native/src/OSX/AvnWindow.mm
  9. 4
      native/Avalonia.Native/src/OSX/INSWindowHolder.h
  10. 9
      native/Avalonia.Native/src/OSX/PopupImpl.h
  11. 68
      native/Avalonia.Native/src/OSX/PopupImpl.mm
  12. 1
      native/Avalonia.Native/src/OSX/ResizeScope.h
  13. 2
      native/Avalonia.Native/src/OSX/ResizeScope.mm
  14. 1
      native/Avalonia.Native/src/OSX/SystemDialogs.mm
  15. 25
      native/Avalonia.Native/src/OSX/WindowBaseImpl.h
  16. 134
      native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
  17. 1
      native/Avalonia.Native/src/OSX/WindowImpl.h
  18. 69
      native/Avalonia.Native/src/OSX/WindowImpl.mm
  19. 17
      native/Avalonia.Native/src/OSX/WindowInterfaces.h
  20. 21
      native/Avalonia.Native/src/OSX/WindowProtocol.h
  21. 3
      native/Avalonia.Native/src/OSX/automation.h
  22. 7
      native/Avalonia.Native/src/OSX/automation.mm
  23. 1
      native/Avalonia.Native/src/OSX/main.mm
  24. 1
      native/Avalonia.Native/src/OSX/menu.mm
  25. 2
      samples/ControlCatalog/ViewModels/MainWindowViewModel.cs
  26. 3
      src/Avalonia.Base/Threading/ThreadSafeObjectPool.cs
  27. 7
      src/Avalonia.Native/WindowImpl.cs
  28. 1
      src/Avalonia.Native/avn.idl

5
native/Avalonia.Native/inc/rendertarget.h

@ -1,3 +1,8 @@
#pragma once
#include "com.h"
#include "comimpl.h"
#include "avalonia-native.h"
@protocol IRenderTarget @protocol IRenderTarget
-(void) setNewLayer: (CALayer*) layer; -(void) setNewLayer: (CALayer*) layer;

4
native/Avalonia.Native/src/OSX/AutoFitContentView.h

@ -3,8 +3,10 @@
// Copyright (c) 2022 Avalonia. All rights reserved. // Copyright (c) 2022 Avalonia. All rights reserved.
// //
#pragma once
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "avalonia-native.h" #include "avalonia-native.h"
@interface AutoFitContentView : NSView @interface AutoFitContentView : NSView
-(AutoFitContentView* _Nonnull) initWithContent: (NSView* _Nonnull) content; -(AutoFitContentView* _Nonnull) initWithContent: (NSView* _Nonnull) content;

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

@ -4,7 +4,9 @@
// //
#include "AvnView.h" #include "AvnView.h"
#import "AutoFitContentView.h" #include "AutoFitContentView.h"
#include "WindowInterfaces.h"
#include "WindowProtocol.h"
@implementation AutoFitContentView @implementation AutoFitContentView
{ {
@ -83,7 +85,7 @@
_settingSize = true; _settingSize = true;
[super setFrameSize:newSize]; [super setFrameSize:newSize];
auto window = objc_cast<AvnWindow>([self window]); auto window = static_cast<id <AvnWindowProtocol>>([self window]);
// TODO get actual titlebar size // TODO get actual titlebar size

30
native/Avalonia.Native/src/OSX/Avalonia.Native.OSX.xcodeproj/project.pbxproj

@ -9,16 +9,22 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
18391068E48EF96E3DB5FDAB /* ResizeScope.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18391E45702740FE9DD69695 /* ResizeScope.mm */; }; 18391068E48EF96E3DB5FDAB /* ResizeScope.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18391E45702740FE9DD69695 /* ResizeScope.mm */; };
1839125F057B0A4EB1760058 /* WindowImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 183919BF108EB72A029F7671 /* WindowImpl.mm */; }; 1839125F057B0A4EB1760058 /* WindowImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 183919BF108EB72A029F7671 /* WindowImpl.mm */; };
183914E50CF6D2EFC1667F7C /* WindowInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391DB45C7D892E61BF388C /* WindowInterfaces.h */; };
1839151F32D1BB1AB51A7BB6 /* AvnPanelWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18391884C7476DA4E53A492D /* AvnPanelWindow.mm */; };
183916173528EC2737DBE5E1 /* WindowBaseImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 183915BFF0E234CD3604A7CD /* WindowBaseImpl.h */; }; 183916173528EC2737DBE5E1 /* WindowBaseImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 183915BFF0E234CD3604A7CD /* WindowBaseImpl.h */; };
1839171DCC651B0638603AC4 /* INSWindowHolder.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391BBB7782C296D424071F /* INSWindowHolder.h */; }; 1839171DCC651B0638603AC4 /* INSWindowHolder.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391BBB7782C296D424071F /* INSWindowHolder.h */; };
1839179A55FC1421BEE83330 /* WindowBaseImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18391676ECF0E983F4964357 /* WindowBaseImpl.mm */; }; 1839179A55FC1421BEE83330 /* WindowBaseImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18391676ECF0E983F4964357 /* WindowBaseImpl.mm */; };
183919D91DB9AAB5D700C2EA /* WindowImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391CD090AA776E7E841AC9 /* WindowImpl.h */; }; 183919D91DB9AAB5D700C2EA /* WindowImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391CD090AA776E7E841AC9 /* WindowImpl.h */; };
18391AA7E0BBA74D184C5734 /* AutoFitContentView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1839166350F32661F3ABD70F /* AutoFitContentView.mm */; }; 18391AA7E0BBA74D184C5734 /* AutoFitContentView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1839166350F32661F3ABD70F /* AutoFitContentView.mm */; };
18391AC16726CBC45856233B /* AvnWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1839155B28B20FFB672D29C6 /* AvnWindow.mm */; };
18391AC65ADD7DDD33FBE737 /* PopupImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 183910513F396141938832B5 /* PopupImpl.h */; };
18391C28BF1823B5464FDD36 /* ResizeScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 1839171D898F9BFC1373631A /* ResizeScope.h */; }; 18391C28BF1823B5464FDD36 /* ResizeScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 1839171D898F9BFC1373631A /* ResizeScope.h */; };
18391CF07316F819E76B617C /* IWindowStateChanged.h in Headers */ = {isa = PBXBuildFile; fileRef = 183913C6BFD6856BD42D19FD /* IWindowStateChanged.h */; }; 18391CF07316F819E76B617C /* IWindowStateChanged.h in Headers */ = {isa = PBXBuildFile; fileRef = 183913C6BFD6856BD42D19FD /* IWindowStateChanged.h */; };
18391D4EB311BC7EF8B8C0A6 /* AvnView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1839132D0E2454D911F1D1F9 /* AvnView.mm */; }; 18391D4EB311BC7EF8B8C0A6 /* AvnView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1839132D0E2454D911F1D1F9 /* AvnView.mm */; };
18391D8CD1756DC858DC1A09 /* PopupImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 18391BB698579F40F1783F31 /* PopupImpl.mm */; };
18391E1381E2D5BFD60265A9 /* AutoFitContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391654EF0E7AB3D3AB4071 /* AutoFitContentView.h */; }; 18391E1381E2D5BFD60265A9 /* AutoFitContentView.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391654EF0E7AB3D3AB4071 /* AutoFitContentView.h */; };
18391ED5F611FF62C45F196D /* AvnView.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391D1669284AD2EC9E866A /* AvnView.h */; }; 18391ED5F611FF62C45F196D /* AvnView.h in Headers */ = {isa = PBXBuildFile; fileRef = 18391D1669284AD2EC9E866A /* AvnView.h */; };
18391F1E2411C79405A9943A /* WindowProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 1839122E037567BDD1D09DEB /* WindowProtocol.h */; };
1A002B9E232135EE00021753 /* app.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A002B9D232135EE00021753 /* app.mm */; }; 1A002B9E232135EE00021753 /* app.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A002B9D232135EE00021753 /* app.mm */; };
1A1852DC23E05814008F0DED /* deadlock.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1852DB23E05814008F0DED /* deadlock.mm */; }; 1A1852DC23E05814008F0DED /* deadlock.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1852DB23E05814008F0DED /* deadlock.mm */; };
1A3E5EA823E9E83B00EDE661 /* rendertarget.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E5EA723E9E83B00EDE661 /* rendertarget.mm */; }; 1A3E5EA823E9E83B00EDE661 /* rendertarget.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E5EA723E9E83B00EDE661 /* rendertarget.mm */; };
@ -40,24 +46,29 @@
AB00E4F72147CA920032A60A /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB00E4F62147CA920032A60A /* main.mm */; }; AB00E4F72147CA920032A60A /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB00E4F62147CA920032A60A /* main.mm */; };
AB1E522C217613570091CD71 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB1E522B217613570091CD71 /* OpenGL.framework */; }; AB1E522C217613570091CD71 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB1E522B217613570091CD71 /* OpenGL.framework */; };
AB661C1E2148230F00291242 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB661C1D2148230F00291242 /* AppKit.framework */; }; AB661C1E2148230F00291242 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB661C1D2148230F00291242 /* AppKit.framework */; };
AB661C202148286E00291242 /* window.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB661C1F2148286E00291242 /* window.mm */; };
AB8F7D6B21482D7F0057DBA5 /* platformthreading.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */; }; AB8F7D6B21482D7F0057DBA5 /* platformthreading.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */; };
BC11A5BE2608D58F0017BAD0 /* automation.h in Headers */ = {isa = PBXBuildFile; fileRef = BC11A5BC2608D58F0017BAD0 /* automation.h */; }; BC11A5BE2608D58F0017BAD0 /* automation.h in Headers */ = {isa = PBXBuildFile; fileRef = BC11A5BC2608D58F0017BAD0 /* automation.h */; };
BC11A5BF2608D58F0017BAD0 /* automation.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC11A5BD2608D58F0017BAD0 /* automation.mm */; }; BC11A5BF2608D58F0017BAD0 /* automation.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC11A5BD2608D58F0017BAD0 /* automation.mm */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
183910513F396141938832B5 /* PopupImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopupImpl.h; sourceTree = "<group>"; };
1839122E037567BDD1D09DEB /* WindowProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowProtocol.h; sourceTree = "<group>"; };
1839132D0E2454D911F1D1F9 /* AvnView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AvnView.mm; sourceTree = "<group>"; }; 1839132D0E2454D911F1D1F9 /* AvnView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AvnView.mm; sourceTree = "<group>"; };
183913C6BFD6856BD42D19FD /* IWindowStateChanged.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IWindowStateChanged.h; sourceTree = "<group>"; }; 183913C6BFD6856BD42D19FD /* IWindowStateChanged.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IWindowStateChanged.h; sourceTree = "<group>"; };
1839155B28B20FFB672D29C6 /* AvnWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AvnWindow.mm; sourceTree = "<group>"; };
183915BFF0E234CD3604A7CD /* WindowBaseImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBaseImpl.h; sourceTree = "<group>"; }; 183915BFF0E234CD3604A7CD /* WindowBaseImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowBaseImpl.h; sourceTree = "<group>"; };
18391654EF0E7AB3D3AB4071 /* AutoFitContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoFitContentView.h; sourceTree = "<group>"; }; 18391654EF0E7AB3D3AB4071 /* AutoFitContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoFitContentView.h; sourceTree = "<group>"; };
1839166350F32661F3ABD70F /* AutoFitContentView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFitContentView.mm; sourceTree = "<group>"; }; 1839166350F32661F3ABD70F /* AutoFitContentView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoFitContentView.mm; sourceTree = "<group>"; };
18391676ECF0E983F4964357 /* WindowBaseImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowBaseImpl.mm; sourceTree = "<group>"; }; 18391676ECF0E983F4964357 /* WindowBaseImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowBaseImpl.mm; sourceTree = "<group>"; };
1839171D898F9BFC1373631A /* ResizeScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeScope.h; sourceTree = "<group>"; }; 1839171D898F9BFC1373631A /* ResizeScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResizeScope.h; sourceTree = "<group>"; };
18391884C7476DA4E53A492D /* AvnPanelWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AvnPanelWindow.mm; sourceTree = "<group>"; };
183919BF108EB72A029F7671 /* WindowImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowImpl.mm; sourceTree = "<group>"; }; 183919BF108EB72A029F7671 /* WindowImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowImpl.mm; sourceTree = "<group>"; };
18391BB698579F40F1783F31 /* PopupImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PopupImpl.mm; sourceTree = "<group>"; };
18391BBB7782C296D424071F /* INSWindowHolder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = INSWindowHolder.h; sourceTree = "<group>"; }; 18391BBB7782C296D424071F /* INSWindowHolder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = INSWindowHolder.h; sourceTree = "<group>"; };
18391CD090AA776E7E841AC9 /* WindowImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowImpl.h; sourceTree = "<group>"; }; 18391CD090AA776E7E841AC9 /* WindowImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowImpl.h; sourceTree = "<group>"; };
18391D1669284AD2EC9E866A /* AvnView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvnView.h; sourceTree = "<group>"; }; 18391D1669284AD2EC9E866A /* AvnView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvnView.h; sourceTree = "<group>"; };
18391DB45C7D892E61BF388C /* WindowInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowInterfaces.h; sourceTree = "<group>"; };
18391E45702740FE9DD69695 /* ResizeScope.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResizeScope.mm; sourceTree = "<group>"; }; 18391E45702740FE9DD69695 /* ResizeScope.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResizeScope.mm; sourceTree = "<group>"; };
1A002B9D232135EE00021753 /* app.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = app.mm; sourceTree = "<group>"; }; 1A002B9D232135EE00021753 /* app.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = app.mm; sourceTree = "<group>"; };
1A1852DB23E05814008F0DED /* deadlock.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = deadlock.mm; sourceTree = "<group>"; }; 1A1852DB23E05814008F0DED /* deadlock.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = deadlock.mm; sourceTree = "<group>"; };
@ -72,7 +83,6 @@
37A4E71A2178846A00EACBCD /* headers */ = {isa = PBXFileReference; lastKnownFileType = folder; name = headers; path = ../../inc; sourceTree = "<group>"; }; 37A4E71A2178846A00EACBCD /* headers */ = {isa = PBXFileReference; lastKnownFileType = folder; name = headers; path = ../../inc; sourceTree = "<group>"; };
37A517B22159597E00FBA241 /* Screens.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Screens.mm; sourceTree = "<group>"; }; 37A517B22159597E00FBA241 /* Screens.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Screens.mm; sourceTree = "<group>"; };
37C09D8721580FE4006A6758 /* SystemDialogs.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemDialogs.mm; sourceTree = "<group>"; }; 37C09D8721580FE4006A6758 /* SystemDialogs.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemDialogs.mm; sourceTree = "<group>"; };
37C09D8A21581EF2006A6758 /* window.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = window.h; sourceTree = "<group>"; };
37DDA9AF219330F8002E132B /* AvnString.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AvnString.mm; sourceTree = "<group>"; }; 37DDA9AF219330F8002E132B /* AvnString.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AvnString.mm; sourceTree = "<group>"; };
37DDA9B121933371002E132B /* AvnString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AvnString.h; sourceTree = "<group>"; }; 37DDA9B121933371002E132B /* AvnString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AvnString.h; sourceTree = "<group>"; };
37E2330E21583241000CB7E2 /* KeyTransform.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyTransform.mm; sourceTree = "<group>"; }; 37E2330E21583241000CB7E2 /* KeyTransform.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyTransform.mm; sourceTree = "<group>"; };
@ -86,7 +96,6 @@
AB00E4F62147CA920032A60A /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; }; AB00E4F62147CA920032A60A /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
AB1E522B217613570091CD71 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; AB1E522B217613570091CD71 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
AB661C1D2148230F00291242 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; AB661C1D2148230F00291242 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
AB661C1F2148286E00291242 /* window.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = window.mm; sourceTree = "<group>"; };
AB661C212148288600291242 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; }; AB661C212148288600291242 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
AB7A61EF2147C815003C5833 /* libAvalonia.Native.OSX.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libAvalonia.Native.OSX.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; AB7A61EF2147C815003C5833 /* libAvalonia.Native.OSX.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libAvalonia.Native.OSX.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = platformthreading.mm; sourceTree = "<group>"; }; AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = platformthreading.mm; sourceTree = "<group>"; };
@ -142,8 +151,6 @@
AB661C212148288600291242 /* common.h */, AB661C212148288600291242 /* common.h */,
379860FE214DA0C000CD0246 /* KeyTransform.h */, 379860FE214DA0C000CD0246 /* KeyTransform.h */,
37E2330E21583241000CB7E2 /* KeyTransform.mm */, 37E2330E21583241000CB7E2 /* KeyTransform.mm */,
AB661C1F2148286E00291242 /* window.mm */,
37C09D8A21581EF2006A6758 /* window.h */,
AB00E4F62147CA920032A60A /* main.mm */, AB00E4F62147CA920032A60A /* main.mm */,
37155CE3233C00EB0034DCE9 /* menu.h */, 37155CE3233C00EB0034DCE9 /* menu.h */,
520624B222973F4100C4DCEF /* menu.mm */, 520624B222973F4100C4DCEF /* menu.mm */,
@ -166,6 +173,12 @@
18391D1669284AD2EC9E866A /* AvnView.h */, 18391D1669284AD2EC9E866A /* AvnView.h */,
1839166350F32661F3ABD70F /* AutoFitContentView.mm */, 1839166350F32661F3ABD70F /* AutoFitContentView.mm */,
18391654EF0E7AB3D3AB4071 /* AutoFitContentView.h */, 18391654EF0E7AB3D3AB4071 /* AutoFitContentView.h */,
18391884C7476DA4E53A492D /* AvnPanelWindow.mm */,
1839122E037567BDD1D09DEB /* WindowProtocol.h */,
1839155B28B20FFB672D29C6 /* AvnWindow.mm */,
18391DB45C7D892E61BF388C /* WindowInterfaces.h */,
18391BB698579F40F1783F31 /* PopupImpl.mm */,
183910513F396141938832B5 /* PopupImpl.h */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -193,6 +206,9 @@
18391C28BF1823B5464FDD36 /* ResizeScope.h in Headers */, 18391C28BF1823B5464FDD36 /* ResizeScope.h in Headers */,
18391ED5F611FF62C45F196D /* AvnView.h in Headers */, 18391ED5F611FF62C45F196D /* AvnView.h in Headers */,
18391E1381E2D5BFD60265A9 /* AutoFitContentView.h in Headers */, 18391E1381E2D5BFD60265A9 /* AutoFitContentView.h in Headers */,
18391F1E2411C79405A9943A /* WindowProtocol.h in Headers */,
183914E50CF6D2EFC1667F7C /* WindowInterfaces.h in Headers */,
18391AC65ADD7DDD33FBE737 /* PopupImpl.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -271,12 +287,14 @@
1A465D10246AB61600C5858B /* dnd.mm in Sources */, 1A465D10246AB61600C5858B /* dnd.mm in Sources */,
AB00E4F72147CA920032A60A /* main.mm in Sources */, AB00E4F72147CA920032A60A /* main.mm in Sources */,
37C09D8821580FE4006A6758 /* SystemDialogs.mm in Sources */, 37C09D8821580FE4006A6758 /* SystemDialogs.mm in Sources */,
AB661C202148286E00291242 /* window.mm in Sources */,
1839179A55FC1421BEE83330 /* WindowBaseImpl.mm in Sources */, 1839179A55FC1421BEE83330 /* WindowBaseImpl.mm in Sources */,
1839125F057B0A4EB1760058 /* WindowImpl.mm in Sources */, 1839125F057B0A4EB1760058 /* WindowImpl.mm in Sources */,
18391068E48EF96E3DB5FDAB /* ResizeScope.mm in Sources */, 18391068E48EF96E3DB5FDAB /* ResizeScope.mm in Sources */,
18391D4EB311BC7EF8B8C0A6 /* AvnView.mm in Sources */, 18391D4EB311BC7EF8B8C0A6 /* AvnView.mm in Sources */,
18391AA7E0BBA74D184C5734 /* AutoFitContentView.mm in Sources */, 18391AA7E0BBA74D184C5734 /* AutoFitContentView.mm in Sources */,
1839151F32D1BB1AB51A7BB6 /* AvnPanelWindow.mm in Sources */,
18391AC16726CBC45856233B /* AvnWindow.mm in Sources */,
18391D8CD1756DC858DC1A09 /* PopupImpl.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

11
native/Avalonia.Native/src/OSX/AvnPanelWindow.mm

@ -0,0 +1,11 @@
//
// Created by Dan Walmsley on 06/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved.
//
#pragma once
#define IS_NSPANEL
#include "AvnWindow.mm"

10
native/Avalonia.Native/src/OSX/AvnView.h

@ -2,17 +2,15 @@
// Created by Dan Walmsley on 05/05/2022. // Created by Dan Walmsley on 05/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved. // Copyright (c) 2022 Avalonia. All rights reserved.
// //
#pragma once
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include "window.h" #include "common.h"
#import "comimpl.h" #include "WindowImpl.h"
#import "common.h" #include "KeyTransform.h"
#import "WindowImpl.h"
#import "KeyTransform.h"
@class AvnAccessibilityElement; @class AvnAccessibilityElement;

10
native/Avalonia.Native/src/OSX/AvnView.mm

@ -4,8 +4,9 @@
// //
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import "AvnView.h" #include "AvnView.h"
#include "automation.h" #include "automation.h"
#import "WindowInterfaces.h"
@implementation AvnView @implementation AvnView
{ {
@ -194,7 +195,12 @@
- (bool) ignoreUserInput:(bool)trigerInputWhenDisabled - (bool) ignoreUserInput:(bool)trigerInputWhenDisabled
{ {
auto parentWindow = objc_cast<AvnWindow>([self window]); if(_parent == nullptr)
{
return TRUE;
}
auto parentWindow = _parent->GetWindowProtocol();
if(parentWindow == nil || ![parentWindow shouldTryToHandleEvents]) if(parentWindow == nil || ![parentWindow shouldTryToHandleEvents])
{ {

216
native/Avalonia.Native/src/OSX/window.mm → native/Avalonia.Native/src/OSX/AvnWindow.mm

@ -1,16 +1,34 @@
//
// Created by Dan Walmsley on 06/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved.
//
#import <AppKit/AppKit.h>
#import "WindowProtocol.h"
#import "WindowBaseImpl.h"
#ifdef IS_NSPANEL
#define BASE_CLASS NSPanel
#define CLASS_NAME AvnPanel
#else
#define BASE_CLASS NSWindow
#define CLASS_NAME AvnWindow
#endif
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include "common.h" #include "common.h"
#import "window.h"
#include "menu.h" #include "menu.h"
#include "automation.h" #include "automation.h"
#import "WindowBaseImpl.h" #include "WindowBaseImpl.h"
#include "WindowImpl.h" #include "WindowImpl.h"
#include "AvnView.h" #include "AvnView.h"
#include "WindowInterfaces.h"
#include "PopupImpl.h"
@implementation AvnWindow @implementation CLASS_NAME
{ {
ComPtr<WindowBaseImpl> _parent; ComPtr<WindowBaseImpl> _parent;
bool _canBecomeKeyAndMain;
bool _closed; bool _closed;
bool _isEnabled; bool _isEnabled;
bool _isExtended; bool _isExtended;
@ -66,7 +84,7 @@
- (void)pollModalSession:(nonnull NSModalSession)session - (void)pollModalSession:(nonnull NSModalSession)session
{ {
auto response = [NSApp runModalSession:session]; auto response = [NSApp runModalSession:session];
if(response == NSModalResponseContinue) if(response == NSModalResponseContinue)
{ {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
@ -85,18 +103,18 @@
if(_menu != nullptr) if(_menu != nullptr)
{ {
auto appMenuItem = ::GetAppMenuItem(); auto appMenuItem = ::GetAppMenuItem();
if(appMenuItem != nullptr) if(appMenuItem != nullptr)
{ {
auto appMenu = [appMenuItem menu]; auto appMenu = [appMenuItem menu];
[appMenu removeItem:appMenuItem]; [appMenu removeItem:appMenuItem];
[_menu insertItem:appMenuItem atIndex:0]; [_menu insertItem:appMenuItem atIndex:0];
[_menu setHasGlobalMenuItem:true]; [_menu setHasGlobalMenuItem:true];
} }
[NSApp setMenu:_menu]; [NSApp setMenu:_menu];
} }
else else
@ -108,22 +126,22 @@
-(void) showAppMenuOnly -(void) showAppMenuOnly
{ {
auto appMenuItem = ::GetAppMenuItem(); auto appMenuItem = ::GetAppMenuItem();
if(appMenuItem != nullptr) if(appMenuItem != nullptr)
{ {
auto appMenu = ::GetAppMenu(); auto appMenu = ::GetAppMenu();
auto nativeAppMenu = dynamic_cast<AvnAppMenu*>(appMenu); auto nativeAppMenu = dynamic_cast<AvnAppMenu*>(appMenu);
[[appMenuItem menu] removeItem:appMenuItem]; [[appMenuItem menu] removeItem:appMenuItem];
if(_menu != nullptr) if(_menu != nullptr)
{ {
[_menu setHasGlobalMenuItem:false]; [_menu setHasGlobalMenuItem:false];
} }
[nativeAppMenu->GetNative() addItem:appMenuItem]; [nativeAppMenu->GetNative() addItem:appMenuItem];
[NSApp setMenu:nativeAppMenu->GetNative()]; [NSApp setMenu:nativeAppMenu->GetNative()];
} }
} }
@ -134,27 +152,27 @@
{ {
menu = [AvnMenu new]; menu = [AvnMenu new];
} }
_menu = menu; _menu = menu;
} }
-(void) setCanBecomeKeyAndMain -(CLASS_NAME*) initWithParent: (WindowBaseImpl*) parent contentRect: (NSRect)contentRect styleMask: (NSWindowStyleMask)styleMask;
{ {
_canBecomeKeyAndMain = true; // https://jameshfisher.com/2020/07/10/why-is-the-contentrect-of-my-nswindow-ignored/
} // create nswindow with specific contentRect, otherwise we wont be able to resize the window
// until several ms after the window is physically on the screen.
self = [super initWithContentRect:contentRect styleMask: styleMask backing:NSBackingStoreBuffered defer:false];
-(AvnWindow*) initWithParent: (WindowBaseImpl*) parent
{
self = [super init];
[self setReleasedWhenClosed:false]; [self setReleasedWhenClosed:false];
_parent = parent; _parent = parent;
[self setDelegate:self]; [self setDelegate:self];
_closed = false; _closed = false;
_isEnabled = true; _isEnabled = true;
[self backingScaleFactor]; [self backingScaleFactor];
[self setOpaque:NO]; [self setOpaque:NO];
[self setBackgroundColor: [NSColor clearColor]]; [self setBackgroundColor: [NSColor clearColor]];
_isExtended = false; _isExtended = false;
return self; return self;
} }
@ -162,12 +180,12 @@
- (BOOL)windowShouldClose:(NSWindow *)sender - (BOOL)windowShouldClose:(NSWindow *)sender
{ {
auto window = dynamic_cast<WindowImpl*>(_parent.getRaw()); auto window = dynamic_cast<WindowImpl*>(_parent.getRaw());
if(window != nullptr) if(window != nullptr)
{ {
return !window->WindowEvents->Closing(); return !window->WindowEvents->Closing();
} }
return true; return true;
} }
@ -191,27 +209,26 @@
-(BOOL)canBecomeKeyWindow -(BOOL)canBecomeKeyWindow
{ {
if (_canBecomeKeyAndMain) // If the window has a child window being shown as a dialog then don't allow it to become the key window.
for(NSWindow* uch in [self childWindows])
{ {
// If the window has a child window being shown as a dialog then don't allow it to become the key window. auto ch = static_cast<id <AvnWindowProtocol>>(uch);
for(NSWindow* uch in [self childWindows]) if(ch == nil)
{ continue;
auto ch = objc_cast<AvnWindow>(uch); if (ch.isDialog)
if(ch == nil) return false;
continue;
if (ch.isDialog)
return false;
}
return true;
} }
return false; return true;
} }
-(BOOL)canBecomeMainWindow -(BOOL)canBecomeMainWindow
{ {
return _canBecomeKeyAndMain; #ifdef IS_NSPANEL
return false;
#else
return true;
#endif
} }
-(bool)shouldTryToHandleEvents -(bool)shouldTryToHandleEvents
@ -227,7 +244,7 @@
-(void)becomeKeyWindow -(void)becomeKeyWindow
{ {
[self showWindowMenuWithAppMenu]; [self showWindowMenuWithAppMenu];
if(_parent != nullptr) if(_parent != nullptr)
{ {
_parent->BaseEvents->Activated(); _parent->BaseEvents->Activated();
@ -238,7 +255,8 @@
-(void) restoreParentWindow; -(void) restoreParentWindow;
{ {
auto parent = objc_cast<AvnWindow>([self parentWindow]); auto parent = [self parentWindow];
if(parent != nil) if(parent != nil)
{ {
[parent removeChildWindow:self]; [parent removeChildWindow:self];
@ -248,7 +266,7 @@
- (void)windowDidMiniaturize:(NSNotification *)notification - (void)windowDidMiniaturize:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->WindowStateChanged(); parent->WindowStateChanged();
@ -258,7 +276,7 @@
- (void)windowDidDeminiaturize:(NSNotification *)notification - (void)windowDidDeminiaturize:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->WindowStateChanged(); parent->WindowStateChanged();
@ -268,7 +286,7 @@
- (void)windowDidResize:(NSNotification *)notification - (void)windowDidResize:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->WindowStateChanged(); parent->WindowStateChanged();
@ -278,7 +296,7 @@
- (void)windowWillExitFullScreen:(NSNotification *)notification - (void)windowWillExitFullScreen:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->StartStateTransition(); parent->StartStateTransition();
@ -288,22 +306,22 @@
- (void)windowDidExitFullScreen:(NSNotification *)notification - (void)windowDidExitFullScreen:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->EndStateTransition(); parent->EndStateTransition();
if(parent->Decorations() != SystemDecorationsFull && parent->WindowState() == Maximized) if(parent->Decorations() != SystemDecorationsFull && parent->WindowState() == Maximized)
{ {
NSRect screenRect = [[self screen] visibleFrame]; NSRect screenRect = [[self screen] visibleFrame];
[self setFrame:screenRect display:YES]; [self setFrame:screenRect display:YES];
} }
if(parent->WindowState() == Minimized) if(parent->WindowState() == Minimized)
{ {
[self miniaturize:nullptr]; [self miniaturize:nullptr];
} }
parent->WindowStateChanged(); parent->WindowStateChanged();
} }
} }
@ -311,7 +329,7 @@
- (void)windowWillEnterFullScreen:(NSNotification *)notification - (void)windowWillEnterFullScreen:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->StartStateTransition(); parent->StartStateTransition();
@ -321,7 +339,7 @@
- (void)windowDidEnterFullScreen:(NSNotification *)notification - (void)windowDidEnterFullScreen:(NSNotification *)notification
{ {
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->());
if(parent != nullptr) if(parent != nullptr)
{ {
parent->EndStateTransition(); parent->EndStateTransition();
@ -338,20 +356,20 @@
{ {
if(_parent) if(_parent)
_parent->BaseEvents->Deactivated(); _parent->BaseEvents->Deactivated();
[self showAppMenuOnly]; [self showAppMenuOnly];
[super resignKeyWindow]; [super resignKeyWindow];
} }
- (void)windowDidMove:(NSNotification *)notification - (void)windowDidMove:(NSNotification *)notification
{ {
AvnPoint position; AvnPoint position;
if(_parent != nullptr) if(_parent != nullptr)
{ {
auto cparent = dynamic_cast<WindowImpl*>(_parent.getRaw()); auto cparent = dynamic_cast<WindowImpl*>(_parent.getRaw());
if(cparent != nullptr) if(cparent != nullptr)
{ {
if(cparent->WindowState() == Maximized) if(cparent->WindowState() == Maximized)
@ -359,7 +377,7 @@
cparent->SetWindowState(Normal); cparent->SetWindowState(Normal);
} }
} }
_parent->GetPosition(&position); _parent->GetPosition(&position);
_parent->BaseEvents->PositionChanged(position); _parent->BaseEvents->PositionChanged(position);
} }
@ -374,7 +392,7 @@
- (void)sendEvent:(NSEvent *)event - (void)sendEvent:(NSEvent *)event
{ {
[super sendEvent:event]; [super sendEvent:event];
/// This is to detect non-client clicks. This can only be done on Windows... not popups, hence the dynamic_cast. /// This is to detect non-client clicks. This can only be done on Windows... not popups, hence the dynamic_cast.
if(_parent != nullptr && dynamic_cast<WindowImpl*>(_parent.getRaw()) != nullptr) if(_parent != nullptr && dynamic_cast<WindowImpl*>(_parent.getRaw()) != nullptr)
{ {
@ -385,95 +403,39 @@
AvnView* view = _parent->View; AvnView* view = _parent->View;
NSPoint windowPoint = [event locationInWindow]; NSPoint windowPoint = [event locationInWindow];
NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil]; NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil];
if (!NSPointInRect(viewPoint, view.bounds)) if (!NSPointInRect(viewPoint, view.bounds))
{ {
auto avnPoint = [AvnView toAvnPoint:windowPoint]; auto avnPoint = [AvnView toAvnPoint:windowPoint];
auto point = [self translateLocalPoint:avnPoint]; auto point = [self translateLocalPoint:avnPoint];
AvnVector delta = { 0, 0 }; AvnVector delta = { 0, 0 };
_parent->BaseEvents->RawMouseEvent(NonClientLeftButtonDown, static_cast<uint32>([event timestamp] * 1000), AvnInputModifiersNone, point, delta); _parent->BaseEvents->RawMouseEvent(NonClientLeftButtonDown, static_cast<uint32>([event timestamp] * 1000), AvnInputModifiersNone, point, delta);
} }
} }
break; break;
case NSEventTypeMouseEntered: case NSEventTypeMouseEntered:
{ {
_parent->UpdateCursor(); _parent->UpdateCursor();
} }
break; break;
case NSEventTypeMouseExited: case NSEventTypeMouseExited:
{ {
[[NSCursor arrowCursor] set]; [[NSCursor arrowCursor] set];
} }
break; break;
default: default:
break; break;
} }
} }
} }
@end - (void)disconnectParent {
_parent = nullptr;
class PopupImpl : public virtual WindowBaseImpl, public IAvnPopup
{
private:
BEGIN_INTERFACE_MAP()
INHERIT_INTERFACE_MAP(WindowBaseImpl)
INTERFACE_MAP_ENTRY(IAvnPopup, IID_IAvnPopup)
END_INTERFACE_MAP()
virtual ~PopupImpl(){}
ComPtr<IAvnWindowEvents> WindowEvents;
PopupImpl(IAvnWindowEvents* events, IAvnGlContext* gl) : WindowBaseImpl(events, gl)
{
WindowEvents = events;
[Window setLevel:NSPopUpMenuWindowLevel];
}
protected:
virtual NSWindowStyleMask GetStyle() override
{
return NSWindowStyleMaskBorderless;
}
virtual HRESULT Resize(double x, double y, AvnPlatformResizeReason reason) override
{
START_COM_CALL;
@autoreleasepool
{
if (Window != nullptr)
{
[Window setContentSize:NSSize{x, y}];
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(lastPositionSet))];
}
return S_OK;
}
}
public:
virtual bool ShouldTakeFocusOnShow() override
{
return false;
}
};
extern IAvnPopup* CreateAvnPopup(IAvnWindowEvents*events, IAvnGlContext* gl)
{
@autoreleasepool
{
IAvnPopup* ptr = dynamic_cast<IAvnPopup*>(new PopupImpl(events, gl));
return ptr;
}
} }
extern IAvnWindow* CreateAvnWindow(IAvnWindowEvents*events, IAvnGlContext* gl) @end
{
@autoreleasepool
{
IAvnWindow* ptr = (IAvnWindow*)new WindowImpl(events, gl);
return ptr;
}
}

4
native/Avalonia.Native/src/OSX/INSWindowHolder.h

@ -10,8 +10,8 @@
struct INSWindowHolder struct INSWindowHolder
{ {
virtual AvnWindow* _Nonnull GetNSWindow () = 0; virtual NSWindow* _Nonnull GetNSWindow () = 0;
virtual AvnView* _Nonnull GetNSView () = 0; virtual NSView* _Nonnull GetNSView () = 0;
}; };
#endif //AVALONIA_NATIVE_OSX_INSWINDOWHOLDER_H #endif //AVALONIA_NATIVE_OSX_INSWINDOWHOLDER_H

9
native/Avalonia.Native/src/OSX/PopupImpl.h

@ -0,0 +1,9 @@
//
// Created by Dan Walmsley on 06/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved.
//
#ifndef AVALONIA_NATIVE_OSX_POPUPIMPL_H
#define AVALONIA_NATIVE_OSX_POPUPIMPL_H
#endif //AVALONIA_NATIVE_OSX_POPUPIMPL_H

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

@ -0,0 +1,68 @@
//
// Created by Dan Walmsley on 06/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved.
//
#include "WindowInterfaces.h"
#include "AvnView.h"
#include "WindowImpl.h"
#include "automation.h"
#include "menu.h"
#include "common.h"
#import "WindowBaseImpl.h"
#import "WindowProtocol.h"
#import <AppKit/AppKit.h>
#include "PopupImpl.h"
class PopupImpl : public virtual WindowBaseImpl, public IAvnPopup
{
private:
BEGIN_INTERFACE_MAP()
INHERIT_INTERFACE_MAP(WindowBaseImpl)
INTERFACE_MAP_ENTRY(IAvnPopup, IID_IAvnPopup)
END_INTERFACE_MAP()
virtual ~PopupImpl(){}
ComPtr<IAvnWindowEvents> WindowEvents;
PopupImpl(IAvnWindowEvents* events, IAvnGlContext* gl) : WindowBaseImpl(events, gl)
{
WindowEvents = events;
[Window setLevel:NSPopUpMenuWindowLevel];
}
protected:
virtual NSWindowStyleMask GetStyle() override
{
return NSWindowStyleMaskBorderless;
}
virtual HRESULT Resize(double x, double y, AvnPlatformResizeReason reason) override
{
START_COM_CALL;
@autoreleasepool
{
if (Window != nullptr)
{
[Window setContentSize:NSSize{x, y}];
[Window setFrameTopLeftPoint:ToNSPoint(ConvertPointY(lastPositionSet))];
}
return S_OK;
}
}
public:
virtual bool ShouldTakeFocusOnShow() override
{
return false;
}
};
extern IAvnPopup* CreateAvnPopup(IAvnWindowEvents*events, IAvnGlContext* gl)
{
@autoreleasepool
{
IAvnPopup* ptr = dynamic_cast<IAvnPopup*>(new PopupImpl(events, gl));
return ptr;
}
}

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

@ -6,7 +6,6 @@
#ifndef AVALONIA_NATIVE_OSX_RESIZESCOPE_H #ifndef AVALONIA_NATIVE_OSX_RESIZESCOPE_H
#define AVALONIA_NATIVE_OSX_RESIZESCOPE_H #define AVALONIA_NATIVE_OSX_RESIZESCOPE_H
#include "window.h"
#include "avalonia-native.h" #include "avalonia-native.h"
@class AvnView; @class AvnView;

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

@ -5,7 +5,7 @@
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include "ResizeScope.h" #include "ResizeScope.h"
#import "AvnView.h" #include "AvnView.h"
ResizeScope::ResizeScope(AvnView *view, AvnPlatformResizeReason reason) { ResizeScope::ResizeScope(AvnView *view, AvnPlatformResizeReason reason) {
_view = view; _view = view;

1
native/Avalonia.Native/src/OSX/SystemDialogs.mm

@ -1,5 +1,4 @@
#include "common.h" #include "common.h"
#include "window.h"
#include "INSWindowHolder.h" #include "INSWindowHolder.h"
class SystemDialogs : public ComSingleObject<IAvnSystemDialogs, &IID_IAvnSystemDialogs> class SystemDialogs : public ComSingleObject<IAvnSystemDialogs, &IID_IAvnSystemDialogs>

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

@ -6,10 +6,12 @@
#ifndef AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H #ifndef AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H
#define AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H #define AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H
#import "rendertarget.h" #include "rendertarget.h"
#include "INSWindowHolder.h" #include "INSWindowHolder.h"
@class AutoFitContentView; @class AutoFitContentView;
@class AvnMenu;
@protocol AvnWindowProtocol;
class WindowBaseImpl : public virtual ComObject, class WindowBaseImpl : public virtual ComObject,
public virtual IAvnWindowBase, public virtual IAvnWindowBase,
@ -24,18 +26,19 @@ BEGIN_INTERFACE_MAP()
INTERFACE_MAP_ENTRY(IAvnWindowBase, IID_IAvnWindowBase) INTERFACE_MAP_ENTRY(IAvnWindowBase, IID_IAvnWindowBase)
END_INTERFACE_MAP() END_INTERFACE_MAP()
virtual ~WindowBaseImpl() { virtual ~WindowBaseImpl();
View = NULL;
Window = NULL;
}
AutoFitContentView *StandardContainer; AutoFitContentView *StandardContainer;
AvnView *View; AvnView *View;
AvnWindow *Window; NSWindow * Window;
ComPtr<IAvnWindowBaseEvents> BaseEvents; ComPtr<IAvnWindowBaseEvents> BaseEvents;
ComPtr<IAvnGlContext> _glContext; ComPtr<IAvnGlContext> _glContext;
NSObject <IRenderTarget> *renderTarget; NSObject <IRenderTarget> *renderTarget;
AvnPoint lastPositionSet; AvnPoint lastPositionSet;
NSSize lastSize;
NSSize lastMinSize;
NSSize lastMaxSize;
AvnMenu* lastMenu;
NSString *_lastTitle; NSString *_lastTitle;
bool _shown; bool _shown;
@ -51,9 +54,9 @@ BEGIN_INTERFACE_MAP()
virtual HRESULT ObtainNSViewHandleRetained(void **ret) override; virtual HRESULT ObtainNSViewHandleRetained(void **ret) override;
virtual AvnWindow *GetNSWindow() override; virtual NSWindow *GetNSWindow() override;
virtual AvnView *GetNSView() override; virtual NSView *GetNSView() override;
virtual HRESULT Show(bool activate, bool isDialog) override; virtual HRESULT Show(bool activate, bool isDialog) override;
@ -111,11 +114,17 @@ BEGIN_INTERFACE_MAP()
virtual bool IsDialog(); virtual bool IsDialog();
id<AvnWindowProtocol> GetWindowProtocol ();
protected: protected:
virtual NSWindowStyleMask GetStyle(); virtual NSWindowStyleMask GetStyle();
void UpdateStyle(); void UpdateStyle();
private:
void CreateNSWindow (bool isDialog);
void CleanNSWindow ();
void InitialiseNSWindow ();
}; };
#endif //AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H #endif //AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H

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

@ -5,13 +5,21 @@
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#include "common.h" #include "common.h"
#import "window.h" #include "AvnView.h"
#import "AvnView.h"
#include "menu.h" #include "menu.h"
#include "automation.h" #include "automation.h"
#import "cursor.h" #include "cursor.h"
#include "ResizeScope.h" #include "ResizeScope.h"
#import "AutoFitContentView.h" #include "AutoFitContentView.h"
#import "WindowProtocol.h"
#import "WindowInterfaces.h"
#include "WindowBaseImpl.h"
WindowBaseImpl::~WindowBaseImpl() {
View = nullptr;
Window = nullptr;
}
WindowBaseImpl::WindowBaseImpl(IAvnWindowBaseEvents *events, IAvnGlContext *gl) { WindowBaseImpl::WindowBaseImpl(IAvnWindowBaseEvents *events, IAvnGlContext *gl) {
_shown = false; _shown = false;
@ -22,17 +30,15 @@ WindowBaseImpl::WindowBaseImpl(IAvnWindowBaseEvents *events, IAvnGlContext *gl)
View = [[AvnView alloc] initWithParent:this]; View = [[AvnView alloc] initWithParent:this];
StandardContainer = [[AutoFitContentView new] initWithContent:View]; StandardContainer = [[AutoFitContentView new] initWithContent:View];
Window = [[AvnWindow alloc] initWithParent:this];
[Window setContentView:StandardContainer];
lastPositionSet.X = 100; lastPositionSet.X = 100;
lastPositionSet.Y = 100; lastPositionSet.Y = 100;
lastSize = NSSize { 100, 100 };
lastMaxSize = NSSize { CGFLOAT_MAX, CGFLOAT_MAX};
lastMinSize = NSSize { 0, 0 };
_lastTitle = @""; _lastTitle = @"";
[Window setStyleMask:NSWindowStyleMaskBorderless]; Window = nullptr;
[Window setBackingType:NSBackingStoreBuffered]; lastMenu = nullptr;
[Window setOpaque:false];
} }
HRESULT WindowBaseImpl::ObtainNSViewHandle(void **ret) { HRESULT WindowBaseImpl::ObtainNSViewHandle(void **ret) {
@ -59,11 +65,11 @@ HRESULT WindowBaseImpl::ObtainNSViewHandleRetained(void **ret) {
return S_OK; return S_OK;
} }
AvnWindow *WindowBaseImpl::GetNSWindow() { NSWindow *WindowBaseImpl::GetNSWindow() {
return Window; return Window;
} }
AvnView *WindowBaseImpl::GetNSView() { NSView *WindowBaseImpl::GetNSView() {
return View; return View;
} }
@ -83,6 +89,9 @@ HRESULT WindowBaseImpl::Show(bool activate, bool isDialog) {
START_COM_CALL; START_COM_CALL;
@autoreleasepool { @autoreleasepool {
CreateNSWindow(isDialog);
InitialiseNSWindow();
SetPosition(lastPositionSet); SetPosition(lastPositionSet);
UpdateStyle(); UpdateStyle();
@ -125,7 +134,8 @@ HRESULT WindowBaseImpl::Hide() {
@autoreleasepool { @autoreleasepool {
if (Window != nullptr) { if (Window != nullptr) {
[Window orderOut:Window]; [Window orderOut:Window];
[Window restoreParentWindow];
[GetWindowProtocol() restoreParentWindow];
} }
return S_OK; return S_OK;
@ -225,8 +235,13 @@ HRESULT WindowBaseImpl::SetMinMaxSize(AvnSize minSize, AvnSize maxSize) {
START_COM_CALL; START_COM_CALL;
@autoreleasepool { @autoreleasepool {
[Window setContentMinSize:ToNSSize(minSize)]; lastMinSize = ToNSSize(minSize);
[Window setContentMaxSize:ToNSSize(maxSize)]; lastMaxSize = ToNSSize(maxSize);
if(Window != nullptr) {
[Window setContentMinSize:lastMinSize];
[Window setContentMaxSize:lastMaxSize];
}
return S_OK; return S_OK;
} }
@ -243,8 +258,8 @@ HRESULT WindowBaseImpl::Resize(double x, double y, AvnPlatformResizeReason reaso
auto resizeBlock = ResizeScope(View, reason); auto resizeBlock = ResizeScope(View, reason);
@autoreleasepool { @autoreleasepool {
auto maxSize = [Window contentMaxSize]; auto maxSize = lastMaxSize;
auto minSize = [Window contentMinSize]; auto minSize = lastMinSize;
if (x < minSize.width) { if (x < minSize.width) {
x = minSize.width; x = minSize.width;
@ -267,8 +282,11 @@ HRESULT WindowBaseImpl::Resize(double x, double y, AvnPlatformResizeReason reaso
BaseEvents->Resized(AvnSize{x, y}, reason); BaseEvents->Resized(AvnSize{x, y}, reason);
} }
[Window setContentSize:NSSize{x, y}]; lastSize = NSSize {x, y};
[Window invalidateShadow];
if(Window != nullptr) {
[Window setContentSize:lastSize];
}
} }
@finally { @finally {
_inResize = false; _inResize = false;
@ -293,12 +311,14 @@ HRESULT WindowBaseImpl::SetMainMenu(IAvnMenu *menu) {
auto nativeMenu = dynamic_cast<AvnAppMenu *>(menu); auto nativeMenu = dynamic_cast<AvnAppMenu *>(menu);
auto nsmenu = nativeMenu->GetNative(); lastMenu = nativeMenu->GetNative();
[Window applyMenu:nsmenu]; if(Window != nullptr) {
[GetWindowProtocol() applyMenu:lastMenu];
if ([Window isKeyWindow]) { if ([Window isKeyWindow]) {
[Window showWindowMenuWithAppMenu]; [GetWindowProtocol() showWindowMenuWithAppMenu];
}
} }
return S_OK; return S_OK;
@ -502,4 +522,68 @@ NSWindowStyleMask WindowBaseImpl::GetStyle() {
void WindowBaseImpl::UpdateStyle() { void WindowBaseImpl::UpdateStyle() {
[Window setStyleMask:GetStyle()]; [Window setStyleMask:GetStyle()];
} }
void WindowBaseImpl::CleanNSWindow() {
if(Window != nullptr) {
[GetWindowProtocol() disconnectParent];
[Window close];
Window = nullptr;
}
}
void WindowBaseImpl::CreateNSWindow(bool isDialog) {
if (isDialog) {
if (![Window isKindOfClass:[AvnPanel class]]) {
CleanNSWindow();
Window = [[AvnPanel alloc] initWithParent:this contentRect:NSRect{0, 0, lastSize} styleMask:GetStyle()];
}
} else {
if (![Window isKindOfClass:[AvnWindow class]]) {
CleanNSWindow();
Window = [[AvnWindow alloc] initWithParent:this contentRect:NSRect{0, 0, lastSize} styleMask:GetStyle()];
}
}
}
void WindowBaseImpl::InitialiseNSWindow() {
if(Window != nullptr) {
[Window setContentView:StandardContainer];
[Window setStyleMask:NSWindowStyleMaskBorderless];
[Window setBackingType:NSBackingStoreBuffered];
[Window setContentSize:lastSize];
[Window setContentMinSize:lastMinSize];
[Window setContentMaxSize:lastMaxSize];
[Window setOpaque:false];
if (lastMenu != nullptr) {
[GetWindowProtocol() applyMenu:lastMenu];
if ([Window isKeyWindow]) {
[GetWindowProtocol() showWindowMenuWithAppMenu];
}
}
}
}
id <AvnWindowProtocol> WindowBaseImpl::GetWindowProtocol() {
if(Window == nullptr)
{
return nullptr;
}
return static_cast<id <AvnWindowProtocol>>(Window);
}
extern IAvnWindow* CreateAvnWindow(IAvnWindowEvents*events, IAvnGlContext* gl)
{
@autoreleasepool
{
IAvnWindow* ptr = (IAvnWindow*)new WindowImpl(events, gl);
return ptr;
}
}

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

@ -6,7 +6,6 @@
#ifndef AVALONIA_NATIVE_OSX_WINDOWIMPL_H #ifndef AVALONIA_NATIVE_OSX_WINDOWIMPL_H
#define AVALONIA_NATIVE_OSX_WINDOWIMPL_H #define AVALONIA_NATIVE_OSX_WINDOWIMPL_H
#import "WindowBaseImpl.h" #import "WindowBaseImpl.h"
#include "IWindowStateChanged.h" #include "IWindowStateChanged.h"

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

@ -4,10 +4,10 @@
// //
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import "window.h" #include "AutoFitContentView.h"
#import "AutoFitContentView.h" #include "AvnView.h"
#import "AvnView.h"
#include "automation.h" #include "automation.h"
#include "WindowProtocol.h"
WindowImpl::WindowImpl(IAvnWindowEvents *events, IAvnGlContext *gl) : WindowBaseImpl(events, gl) { WindowImpl::WindowImpl(IAvnWindowEvents *events, IAvnGlContext *gl) : WindowBaseImpl(events, gl) {
_isClientAreaExtended = false; _isClientAreaExtended = false;
@ -20,7 +20,6 @@ WindowImpl::WindowImpl(IAvnWindowEvents *events, IAvnGlContext *gl) : WindowBase
_lastWindowState = Normal; _lastWindowState = Normal;
_actualWindowState = Normal; _actualWindowState = Normal;
WindowEvents = events; WindowEvents = events;
[Window setCanBecomeKeyAndMain];
[Window disableCursorRects]; [Window disableCursorRects];
[Window setTabbingMode:NSWindowTabbingModeDisallowed]; [Window setTabbingMode:NSWindowTabbingModeDisallowed];
[Window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; [Window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
@ -56,8 +55,20 @@ HRESULT WindowImpl::Show(bool activate, bool isDialog) {
@autoreleasepool { @autoreleasepool {
_isDialog = isDialog; _isDialog = isDialog;
bool created = Window == nullptr;
WindowBaseImpl::Show(activate, isDialog); WindowBaseImpl::Show(activate, isDialog);
if(created)
{
if(_isClientAreaExtended)
{
[GetWindowProtocol() setIsExtended:true];
SetExtendClientArea(true);
}
}
HideOrShowTrafficLights(); HideOrShowTrafficLights();
return SetWindowState(_lastWindowState); return SetWindowState(_lastWindowState);
@ -68,7 +79,7 @@ HRESULT WindowImpl::SetEnabled(bool enable) {
START_COM_CALL; START_COM_CALL;
@autoreleasepool { @autoreleasepool {
[Window setEnabled:enable]; [GetWindowProtocol() setEnabled:enable];
return S_OK; return S_OK;
} }
} }
@ -328,37 +339,39 @@ HRESULT WindowImpl::SetExtendClientArea(bool enable) {
@autoreleasepool { @autoreleasepool {
_isClientAreaExtended = enable; _isClientAreaExtended = enable;
if (enable) { if(Window != nullptr) {
Window.titleVisibility = NSWindowTitleHidden; if (enable) {
Window.titleVisibility = NSWindowTitleHidden;
[Window setTitlebarAppearsTransparent:true]; [Window setTitlebarAppearsTransparent:true];
auto wantsTitleBar = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome); auto wantsTitleBar = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome);
if (wantsTitleBar) { if (wantsTitleBar) {
[StandardContainer ShowTitleBar:true]; [StandardContainer ShowTitleBar:true];
} else { } else {
[StandardContainer ShowTitleBar:false]; [StandardContainer ShowTitleBar:false];
} }
if (_extendClientHints & AvnOSXThickTitleBar) { if (_extendClientHints & AvnOSXThickTitleBar) {
Window.toolbar = [NSToolbar new]; Window.toolbar = [NSToolbar new];
Window.toolbar.showsBaselineSeparator = false; Window.toolbar.showsBaselineSeparator = false;
} else {
Window.toolbar = nullptr;
}
} else { } else {
Window.titleVisibility = NSWindowTitleVisible;
Window.toolbar = nullptr; Window.toolbar = nullptr;
[Window setTitlebarAppearsTransparent:false];
View.layer.zPosition = 0;
} }
} else {
Window.titleVisibility = NSWindowTitleVisible;
Window.toolbar = nullptr;
[Window setTitlebarAppearsTransparent:false];
View.layer.zPosition = 0;
}
[Window setIsExtended:enable]; [GetWindowProtocol() setIsExtended:enable];
HideOrShowTrafficLights(); HideOrShowTrafficLights();
UpdateStyle(); UpdateStyle();
}
return S_OK; return S_OK;
} }
@ -383,7 +396,7 @@ HRESULT WindowImpl::GetExtendTitleBarHeight(double *ret) {
return E_POINTER; return E_POINTER;
} }
*ret = [Window getExtendedTitleBarHeight]; *ret = [GetWindowProtocol() getExtendedTitleBarHeight];
return S_OK; return S_OK;
} }
@ -508,7 +521,7 @@ bool WindowImpl::IsDialog() {
} }
NSWindowStyleMask WindowImpl::GetStyle() { NSWindowStyleMask WindowImpl::GetStyle() {
unsigned long s = NSWindowStyleMaskBorderless; unsigned long s = this->_isDialog ? NSWindowStyleMaskUtilityWindow : NSWindowStyleMaskBorderless;
switch (_decorations) { switch (_decorations) {
case SystemDecorationsNone: case SystemDecorationsNone:

17
native/Avalonia.Native/src/OSX/WindowInterfaces.h

@ -0,0 +1,17 @@
//
// Created by Dan Walmsley on 06/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#include "WindowProtocol.h"
#include "WindowBaseImpl.h"
@interface AvnWindow : NSWindow <AvnWindowProtocol, NSWindowDelegate>
-(AvnWindow* _Nonnull) initWithParent: (WindowBaseImpl* _Nonnull) parent contentRect: (NSRect)contentRect styleMask: (NSWindowStyleMask)styleMask;
@end
@interface AvnPanel : NSPanel <AvnWindowProtocol, NSWindowDelegate>
-(AvnPanel* _Nonnull) initWithParent: (WindowBaseImpl* _Nonnull) parent contentRect: (NSRect)contentRect styleMask: (NSWindowStyleMask)styleMask;
@end

21
native/Avalonia.Native/src/OSX/window.h → native/Avalonia.Native/src/OSX/WindowProtocol.h

@ -1,15 +1,15 @@
#ifndef window_h //
#define window_h // Created by Dan Walmsley on 06/05/2022.
// Copyright (c) 2022 Avalonia. All rights reserved.
//
#import "avalonia-native.h" #pragma once
@class AvnMenu; #import <AppKit/AppKit.h>
class WindowBaseImpl; @class AvnMenu;
@interface AvnWindow : NSWindow <NSWindowDelegate> @protocol AvnWindowProtocol
-(AvnWindow* _Nonnull) initWithParent: (WindowBaseImpl* _Nonnull) parent;
-(void) setCanBecomeKeyAndMain;
-(void) pollModalSession: (NSModalSession _Nonnull) session; -(void) pollModalSession: (NSModalSession _Nonnull) session;
-(void) restoreParentWindow; -(void) restoreParentWindow;
-(bool) shouldTryToHandleEvents; -(bool) shouldTryToHandleEvents;
@ -20,7 +20,6 @@ class WindowBaseImpl;
-(double) getExtendedTitleBarHeight; -(double) getExtendedTitleBarHeight;
-(void) setIsExtended:(bool)value; -(void) setIsExtended:(bool)value;
-(void) disconnectParent;
-(bool) isDialog; -(bool) isDialog;
@end @end
#endif /* window_h */

3
native/Avalonia.Native/src/OSX/automation.h

@ -1,5 +1,6 @@
#import <Cocoa/Cocoa.h> #pragma once
#import <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
class IAvnAutomationPeer; class IAvnAutomationPeer;

7
native/Avalonia.Native/src/OSX/automation.mm

@ -1,9 +1,8 @@
#include "common.h" #include "common.h"
#import "automation.h" #include "automation.h"
#import "window.h"
#include "AvnString.h" #include "AvnString.h"
#import "INSWindowHolder.h" #include "INSWindowHolder.h"
#import "AvnView.h" #include "AvnView.h"
@interface AvnAccessibilityElement (Events) @interface AvnAccessibilityElement (Events)
- (void) raiseChildrenChanged; - (void) raiseChildrenChanged;

1
native/Avalonia.Native/src/OSX/main.mm

@ -1,7 +1,6 @@
//This file will contain actual IID structures //This file will contain actual IID structures
#define COM_GUIDS_MATERIALIZE #define COM_GUIDS_MATERIALIZE
#include "common.h" #include "common.h"
#include "window.h"
static NSString* s_appTitle = @"Avalonia"; static NSString* s_appTitle = @"Avalonia";

1
native/Avalonia.Native/src/OSX/menu.mm

@ -1,7 +1,6 @@
#include "common.h" #include "common.h"
#include "menu.h" #include "menu.h"
#import "window.h"
#include "KeyTransform.h" #include "KeyTransform.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h> /* For kVK_ constants, and TIS functions. */ #include <Carbon/Carbon.h> /* For kVK_ constants, and TIS functions. */

2
samples/ControlCatalog/ViewModels/MainWindowViewModel.cs

@ -18,7 +18,7 @@ namespace ControlCatalog.ViewModels
private WindowState _windowState; private WindowState _windowState;
private WindowState[] _windowStates; private WindowState[] _windowStates;
private int _transparencyLevel; private int _transparencyLevel;
private ExtendClientAreaChromeHints _chromeHints; private ExtendClientAreaChromeHints _chromeHints = ExtendClientAreaChromeHints.PreferSystemChrome;
private bool _extendClientAreaEnabled; private bool _extendClientAreaEnabled;
private bool _systemTitleBarEnabled; private bool _systemTitleBarEnabled;
private bool _preferSystemChromeEnabled; private bool _preferSystemChromeEnabled;

3
src/Avalonia.Base/Threading/ThreadSafeObjectPool.cs

@ -5,12 +5,11 @@ namespace Avalonia.Threading
public class ThreadSafeObjectPool<T> where T : class, new() public class ThreadSafeObjectPool<T> where T : class, new()
{ {
private Stack<T> _stack = new Stack<T>(); private Stack<T> _stack = new Stack<T>();
private object _lock = new object();
public static ThreadSafeObjectPool<T> Default { get; } = new ThreadSafeObjectPool<T>(); public static ThreadSafeObjectPool<T> Default { get; } = new ThreadSafeObjectPool<T>();
public T Get() public T Get()
{ {
lock (_lock) lock (_stack)
{ {
if(_stack.Count == 0) if(_stack.Count == 0)
return new T(); return new T();

7
src/Avalonia.Native/WindowImpl.cs

@ -107,6 +107,13 @@ namespace Avalonia.Native
private bool _isExtended; private bool _isExtended;
public bool IsClientAreaExtendedToDecorations => _isExtended; public bool IsClientAreaExtendedToDecorations => _isExtended;
public override void Show(bool activate, bool isDialog)
{
base.Show(activate, isDialog);
InvalidateExtendedMargins();
}
protected override bool ChromeHitTest (RawPointerEventArgs e) protected override bool ChromeHitTest (RawPointerEventArgs e)
{ {
if(_isExtended) if(_isExtended)

1
src/Avalonia.Native/avn.idl

@ -2,6 +2,7 @@
@clr-access internal @clr-access internal
@clr-map bool int @clr-map bool int
@cpp-preamble @@ @cpp-preamble @@
#pragma once
#include "com.h" #include "com.h"
#include "stddef.h" #include "stddef.h"
@@ @@

Loading…
Cancel
Save