Browse Source

Addressed PR comments

pull/14909/head
Bartosz Korczyński 2 years ago
parent
commit
691541adf6
  1. 4
      native/Avalonia.Native/src/OSX/WindowImpl.mm
  2. 27
      samples/IntegrationTestApp/MacOSIntegration.cs
  3. 2
      samples/IntegrationTestApp/ShowWindowTest.axaml.cs
  4. 9
      src/Avalonia.Native/WindowImpl.cs
  5. 16
      tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

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

@ -373,7 +373,9 @@ HRESULT WindowImpl::GetWindowZOrder(long* zOrder) {
return E_POINTER;
}
*zOrder = [Window orderedIndex];
// negate the value to match expected z-order in Avalonia
// (top-most window should have the highest z-order value)
*zOrder = -[Window orderedIndex];
return S_OK;
}
}

27
samples/IntegrationTestApp/MacOSIntegration.cs

@ -1,27 +0,0 @@
using System;
using System.Runtime.InteropServices;
using Avalonia.Controls;
namespace IntegrationTestApp
{
public static class MacOSIntegration
{
[DllImport("/usr/lib/libobjc.dylib", EntryPoint = "sel_registerName")]
private static extern IntPtr GetHandle(string name);
[DllImport("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
private static extern long Int64_objc_msgSend(IntPtr receiver, IntPtr selector);
private static readonly IntPtr s_orderedIndexSelector;
static MacOSIntegration()
{
s_orderedIndexSelector = GetHandle("orderedIndex");;
}
public static long GetOrderedIndex(Window window)
{
return Int64_objc_msgSend(window.PlatformImpl!.Handle.Handle, s_orderedIndexSelector);
}
}
}

2
samples/IntegrationTestApp/ShowWindowTest.axaml.cs

@ -75,7 +75,7 @@ namespace IntegrationTestApp
private void TimerOnTick(object? sender, EventArgs e)
{
_orderTextBox!.Text = MacOSIntegration.GetOrderedIndex(this).ToString();
_orderTextBox!.Text = WindowZOrder.ToString();
}
}
}

9
src/Avalonia.Native/WindowImpl.cs

@ -103,14 +103,7 @@ namespace Avalonia.Native
public Thickness OffScreenMargin { get; } = new Thickness();
public IntPtr? ZOrder
{
get
{
// macOS returns z-order in reverse order - the topmost window has the lowest z-order
return new IntPtr(-_native.WindowZOrder.ToInt64());
}
}
public IntPtr? ZOrder => _native.WindowZOrder;
private bool _isExtended;
public bool IsClientAreaExtendedToDecorations => _isExtended;

16
tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

@ -52,7 +52,7 @@ namespace Avalonia.IntegrationTests.Appium
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
}
@ -75,7 +75,7 @@ namespace Avalonia.IntegrationTests.Appium
.Release()
.Perform();
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
}
@ -94,7 +94,7 @@ namespace Avalonia.IntegrationTests.Appium
using (OpenWindow(new PixelSize(200, 100), ShowWindowMode.Modal, WindowStartupLocation.Manual))
{
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
}
finally
@ -112,7 +112,7 @@ namespace Avalonia.IntegrationTests.Appium
{
mainWindow.SendClick();
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
}
@ -136,7 +136,7 @@ namespace Avalonia.IntegrationTests.Appium
{
mainWindow.SendClick();
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
// Exit fullscreen by menu shortcut Command+R
@ -159,7 +159,7 @@ namespace Avalonia.IntegrationTests.Appium
OpenWindow(null, ShowWindowMode.Modal, WindowStartupLocation.Manual).Dispose();
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
}
@ -212,7 +212,7 @@ namespace Avalonia.IntegrationTests.Appium
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(2, secondaryWindowIndex);
Assert.Equal(-2, secondaryWindowIndex);
var sendToBack = _session.FindElementByAccessibilityId("SendToBack");
sendToBack.Click();
@ -231,7 +231,7 @@ namespace Avalonia.IntegrationTests.Appium
var secondaryWindowIndex = GetWindowOrder("SecondaryWindow");
Assert.Equal(1, secondaryWindowIndex);
Assert.Equal(-1, secondaryWindowIndex);
}
}

Loading…
Cancel
Save