MacOSIntegration.cs 848 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using Avalonia.Controls;
  4. namespace IntegrationTestApp
  5. {
  6. public static class MacOSIntegration
  7. {
  8. [DllImport("/usr/lib/libobjc.dylib", EntryPoint = "sel_registerName")]
  9. private static extern IntPtr GetHandle(string name);
  10. [DllImport("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
  11. private static extern long Int64_objc_msgSend(IntPtr receiver, IntPtr selector);
  12. private static readonly IntPtr s_orderedIndexSelector;
  13. static MacOSIntegration()
  14. {
  15. s_orderedIndexSelector = GetHandle("orderedIndex");;
  16. }
  17. public static long GetOrderedIndex(Window window)
  18. {
  19. return Int64_objc_msgSend(window.PlatformImpl!.Handle!.Handle, s_orderedIndexSelector);
  20. }
  21. }
  22. }