浏览代码

add osx implementation to get nsview and nswindow.

Dan Walmsley 6 年之前
父节点
当前提交
c41ef36628
共有 2 个文件被更改,包括 52 次插入0 次删除
  1. 4 0
      native/Avalonia.Native/inc/avalonia-native.h
  2. 48 0
      native/Avalonia.Native/src/OSX/window.mm

+ 4 - 0
native/Avalonia.Native/inc/avalonia-native.h

@@ -212,6 +212,10 @@ AVNCOM(IAvnWindowBase, 02) : IUnknown
     virtual HRESULT GetSoftwareFramebuffer(AvnFramebuffer*ret) = 0;
     virtual HRESULT GetSoftwareFramebuffer(AvnFramebuffer*ret) = 0;
     virtual HRESULT SetMainMenu(IAvnAppMenu* menu) = 0;
     virtual HRESULT SetMainMenu(IAvnAppMenu* menu) = 0;
     virtual HRESULT ObtainMainMenu(IAvnAppMenu** retOut) = 0;
     virtual HRESULT ObtainMainMenu(IAvnAppMenu** retOut) = 0;
+    virtual HRESULT GetNSWindowHandle(void** ret) = 0;
+    virtual HRESULT GetNSWindowHandleRetained(void** ret) = 0;
+    virtual HRESULT GetNSViewHandle(void** ret) = 0;
+    virtual HRESULT GetNSViewHandleRetained(void** ret) = 0;
     virtual bool TryLock() = 0;
     virtual bool TryLock() = 0;
     virtual void Unlock() = 0;
     virtual void Unlock() = 0;
 };
 };

+ 48 - 0
native/Avalonia.Native/src/OSX/window.mm

@@ -83,6 +83,54 @@ public:
         [Window setContentView: View];
         [Window setContentView: View];
     }
     }
     
     
+    virtual HRESULT GetNSWindowHandle(void** ret) override
+    {
+        if (ret == nullptr)
+        {
+            return E_POINTER;
+        }
+        
+        *ret =  (__bridge void*)Window;
+        
+        return S_OK;
+    }
+    
+    virtual HRESULT GetNSWindowHandleRetained(void** ret) override
+    {
+        if (ret == nullptr)
+        {
+            return E_POINTER;
+        }
+        
+        *ret =  (__bridge_retained void*)Window;
+        
+        return S_OK;
+    }
+    
+    virtual HRESULT GetNSViewHandle(void** ret) override
+    {
+        if (ret == nullptr)
+        {
+            return E_POINTER;
+        }
+        
+        *ret =  (__bridge void*)View;
+        
+        return S_OK;
+    }
+    
+    virtual HRESULT GetNSViewHandleRetained(void** ret) override
+    {
+        if (ret == nullptr)
+        {
+            return E_POINTER;
+        }
+        
+        *ret =  (__bridge_retained void*)View;
+        
+        return S_OK;
+    }
+    
     virtual AvnWindow* GetNSWindow() override
     virtual AvnWindow* GetNSWindow() override
     {
     {
         return Window;
         return Window;