Browse Source

Merge branch 'master' into fixes/8480-classes-reentrancy

pull/8492/head
Dariusz Komosiński 4 years ago
committed by GitHub
parent
commit
e826934233
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      native/Avalonia.Native/src/OSX/AvnView.mm
  2. 6
      native/Avalonia.Native/src/OSX/rendertarget.mm
  3. 7
      src/Avalonia.Base/Controls/IPseudoClasses.cs
  4. 6
      src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml
  5. 4
      src/Avalonia.Controls/Window.cs
  6. 14
      tests/Avalonia.Benchmarks/Program.cs
  7. 27
      tests/Avalonia.Controls.UnitTests/WindowTests.cs
  8. 6
      tests/Avalonia.IntegrationTests.Appium/macos-clean-build-test.sh
  9. 14
      tests/Avalonia.UnitTests/MockWindowingPlatform.cs

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

@ -127,7 +127,11 @@
[self updateRenderTarget]; [self updateRenderTarget];
auto reason = [self inLiveResize] ? ResizeUser : _resizeReason; auto reason = [self inLiveResize] ? ResizeUser : _resizeReason;
_parent->BaseEvents->Resized(AvnSize{newSize.width, newSize.height}, reason);
if(_parent->IsShown())
{
_parent->BaseEvents->Resized(AvnSize{newSize.width, newSize.height}, reason);
}
} }
} }

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

@ -13,6 +13,7 @@
{ {
@public IOSurfaceRef surface; @public IOSurfaceRef surface;
@public AvnPixelSize size; @public AvnPixelSize size;
@public bool hasContent;
@public float scale; @public float scale;
ComPtr<IAvnGlContext> _context; ComPtr<IAvnGlContext> _context;
GLuint _framebuffer, _texture, _renderbuffer; GLuint _framebuffer, _texture, _renderbuffer;
@ -41,6 +42,7 @@
self->scale = scale; self->scale = scale;
self->size = size; self->size = size;
self->_context = context; self->_context = context;
self->hasContent = false;
return self; return self;
} }
@ -92,6 +94,7 @@
_context->MakeCurrent(release.getPPV()); _context->MakeCurrent(release.getPPV());
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glFlush(); glFlush();
self->hasContent = true;
} }
-(void) dealloc -(void) dealloc
@ -170,6 +173,8 @@ static IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(IOSurfaceRenderTarget* ta
@synchronized (lock) { @synchronized (lock) {
if(_layer == nil) if(_layer == nil)
return; return;
if(!surface->hasContent)
return;
[CATransaction begin]; [CATransaction begin];
[_layer setContents: nil]; [_layer setContents: nil];
if(surface != nil) if(surface != nil)
@ -213,6 +218,7 @@ static IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(IOSurfaceRenderTarget* ta
memcpy(pSurface + y*sstride, pFb + y*fstride, wbytes); memcpy(pSurface + y*sstride, pFb + y*fstride, wbytes);
} }
IOSurfaceUnlock(surf, 0, nil); IOSurfaceUnlock(surf, 0, nil);
surface->hasContent = true;
[self updateLayer]; [self updateLayer];
return S_OK; return S_OK;
} }

7
src/Avalonia.Base/Controls/IPseudoClasses.cs

@ -19,5 +19,12 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
/// <param name="name">The pseudoclass name.</param> /// <param name="name">The pseudoclass name.</param>
bool Remove(string name); bool Remove(string name);
/// <summary>
/// Returns whether a pseudoclass is present in the collection.
/// </summary>
/// <param name="name">The pseudoclass name.</param>
/// <returns>Whether the pseudoclass is present.</returns>
bool Contains(string name);
} }
} }

6
src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml

@ -7,7 +7,7 @@
<StreamGeometry x:Key="DataGridSortIconDescendingPath">M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z</StreamGeometry> <StreamGeometry x:Key="DataGridSortIconDescendingPath">M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z</StreamGeometry>
<StreamGeometry x:Key="DataGridSortIconAscendingPath">M1965 947l-941 -941l-941 941l90 90l787 -787v1798h128v-1798l787 787z</StreamGeometry> <StreamGeometry x:Key="DataGridSortIconAscendingPath">M1965 947l-941 -941l-941 941l90 90l787 -787v1798h128v-1798l787 787z</StreamGeometry>
<StreamGeometry x:Key="DataGridRowGroupHeaderIconClosedPath">M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z</StreamGeometry> <StreamGeometry x:Key="DataGridRowGroupHeaderIconClosedPath">M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z</StreamGeometry>
<StreamGeometry x:Key="DataGridRowGroupHeaderIconOpenedPath">M1939 1581l90 -90l-1005 -1005l-1005 1005l90 90l915 -915z</StreamGeometry> <StreamGeometry x:Key="DataGridRowGroupHeaderIconOpenedPath">M109 486 19 576 1024 1581 2029 576 1939 486 1024 1401z</StreamGeometry>
<SolidColorBrush x:Key="DataGridColumnHeaderForegroundBrush" Color="{DynamicResource SystemBaseMediumColor}" /> <SolidColorBrush x:Key="DataGridColumnHeaderForegroundBrush" Color="{DynamicResource SystemBaseMediumColor}" />
<SolidColorBrush x:Key="DataGridColumnHeaderBackgroundBrush" Color="{DynamicResource SystemAltHighColor}" /> <SolidColorBrush x:Key="DataGridColumnHeaderBackgroundBrush" Color="{DynamicResource SystemAltHighColor}" />
@ -499,12 +499,12 @@
</Style> </Style>
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton /template/ Path"> <Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton /template/ Path">
<Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconOpenedPath}" /> <Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconClosedPath}" />
<Setter Property="Stretch" Value="Uniform" /> <Setter Property="Stretch" Value="Uniform" />
</Style> </Style>
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton:checked /template/ Path"> <Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton:checked /template/ Path">
<Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconClosedPath}" /> <Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconOpenedPath}" />
<Setter Property="Stretch" Value="UniformToFill" /> <Setter Property="Stretch" Value="UniformToFill" />
</Style> </Style>

4
src/Avalonia.Controls/Window.cs

@ -681,8 +681,8 @@ namespace Avalonia.Controls
IsVisible = true; IsVisible = true;
var initialSize = new Size( var initialSize = new Size(
double.IsNaN(Width) ? ClientSize.Width : Width, double.IsNaN(Width) ? Math.Max(MinWidth, ClientSize.Width) : Width,
double.IsNaN(Height) ? ClientSize.Height : Height); double.IsNaN(Height) ? Math.Max(MinHeight, ClientSize.Height) : Height);
if (initialSize != ClientSize) if (initialSize != ClientSize)
{ {

14
tests/Avalonia.Benchmarks/Program.cs

@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running; using BenchmarkDotNet.Running;
namespace Avalonia.Benchmarks namespace Avalonia.Benchmarks
@ -19,7 +21,17 @@ namespace Avalonia.Benchmarks
.ThenBy(t => t.Name) .ThenBy(t => t.Name)
.ToArray(); .ToArray();
var benchmarkSwitcher = new BenchmarkSwitcher(benchmarks); var benchmarkSwitcher = new BenchmarkSwitcher(benchmarks);
benchmarkSwitcher.Run(args); IConfig config = null;
if (args.Contains("--debug"))
{
config = new DebugInProcessConfig();
var a = new List<string>(args);
a.Remove("--debug");
args = a.ToArray();
}
benchmarkSwitcher.Run(args, config);
} }
} }
} }

27
tests/Avalonia.Controls.UnitTests/WindowTests.cs

@ -540,6 +540,33 @@ namespace Avalonia.Controls.UnitTests
Assert.Equal(window.Position, expectedPosition); Assert.Equal(window.Position, expectedPosition);
} }
} }
[Fact]
public void Window_Should_Be_Sized_To_MinSize_If_InitialSize_Less_Than_MinSize()
{
var screen1 = new Mock<Screen>(1.75, new PixelRect(new PixelSize(1920, 1080)), new PixelRect(new PixelSize(1920, 966)), true);
var screens = new Mock<IScreenImpl>();
screens.Setup(x => x.AllScreens).Returns(new Screen[] { screen1.Object });
screens.Setup(x => x.ScreenFromPoint(It.IsAny<PixelPoint>())).Returns(screen1.Object);
var windowImpl = MockWindowingPlatform.CreateWindowMock(400, 300);
windowImpl.Setup(x => x.DesktopScaling).Returns(1.75);
windowImpl.Setup(x => x.RenderScaling).Returns(1.75);
windowImpl.Setup(x => x.Screen).Returns(screens.Object);
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var window = new Window(windowImpl.Object);
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
window.MinWidth = 720;
window.MinHeight = 480;
window.Show();
Assert.Equal(new PixelPoint(330, 63), window.Position);
Assert.Equal(new Size(720, 480), window.Bounds.Size);
}
}
[Fact] [Fact]
public void Window_Should_Be_Centered_Relative_To_Owner_When_WindowStartupLocation_Is_CenterOwner() public void Window_Should_Be_Centered_Relative_To_Owner_When_WindowStartupLocation_Is_CenterOwner()

6
tests/Avalonia.IntegrationTests.Appium/macos-clean-build-test.sh

@ -3,7 +3,13 @@
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
cd "$SCRIPT_DIR"/../.. || exit cd "$SCRIPT_DIR"/../.. || exit
git clean -xdf git clean -xdf
pkill node
appium &
pkill IntegrationTestApp
./build.sh CompileNative ./build.sh CompileNative
./samples/IntegrationTestApp/bundle.sh ./samples/IntegrationTestApp/bundle.sh
open -n ./samples/IntegrationTestApp/bin/Debug/net6.0/osx-arm64/publish/IntegrationTestApp.app open -n ./samples/IntegrationTestApp/bin/Debug/net6.0/osx-arm64/publish/IntegrationTestApp.app
pkill IntegrationTestApp
dotnet test tests/Avalonia.IntegrationTests.Appium/ -l "console;verbosity=detailed" dotnet test tests/Avalonia.IntegrationTests.Appium/ -l "console;verbosity=detailed"
pkill IntegrationTestApp
pkill node

14
tests/Avalonia.UnitTests/MockWindowingPlatform.cs

@ -21,11 +21,11 @@ namespace Avalonia.UnitTests
_popupImpl = popupImpl; _popupImpl = popupImpl;
} }
public static Mock<IWindowImpl> CreateWindowMock() public static Mock<IWindowImpl> CreateWindowMock(double initialWidth = 800, double initialHeight = 600)
{ {
var windowImpl = new Mock<IWindowImpl>(); var windowImpl = new Mock<IWindowImpl>();
var position = new PixelPoint(); var position = new PixelPoint();
var clientSize = new Size(800, 600); var clientSize = new Size(initialWidth, initialHeight);
windowImpl.SetupAllProperties(); windowImpl.SetupAllProperties();
windowImpl.Setup(x => x.ClientSize).Returns(() => clientSize); windowImpl.Setup(x => x.ClientSize).Returns(() => clientSize);
@ -55,12 +55,18 @@ namespace Avalonia.UnitTests
windowImpl.Setup(x => x.Resize(It.IsAny<Size>(), It.IsAny<PlatformResizeReason>())) windowImpl.Setup(x => x.Resize(It.IsAny<Size>(), It.IsAny<PlatformResizeReason>()))
.Callback<Size, PlatformResizeReason>((x, y) => .Callback<Size, PlatformResizeReason>((x, y) =>
{ {
clientSize = x.Constrain(s_screenSize); var constrainedSize = x.Constrain(s_screenSize);
windowImpl.Object.Resized?.Invoke(clientSize, y);
if (constrainedSize != clientSize)
{
clientSize = constrainedSize;
windowImpl.Object.Resized?.Invoke(clientSize, y);
}
}); });
windowImpl.Setup(x => x.Show(true, It.IsAny<bool>())).Callback(() => windowImpl.Setup(x => x.Show(true, It.IsAny<bool>())).Callback(() =>
{ {
windowImpl.Object.Resized?.Invoke(windowImpl.Object.ClientSize, PlatformResizeReason.Unspecified);
windowImpl.Object.Activated?.Invoke(); windowImpl.Object.Activated?.Invoke();
}); });

Loading…
Cancel
Save