Browse Source
Fixed unnecessary window displacement on resize (#18004 )
* Added new test: changing window size should not change position
* Removed unnecessary window placement assignment to fix window position shifting due to incorrect workspace coordinate usage
* Fixed test because buttons went off the window on tiny screen resolutions
* Make test Windows specific
* Use `Bounds` instead of `Width` and `Height` properties as they are "requested" size rather than actual size (see #18060 )
repro/18104-drag-drop-flyout-placement
Melissa
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
27 additions and
7 deletions
samples/IntegrationTestApp/ShowWindowTest.axaml
samples/IntegrationTestApp/ShowWindowTest.axaml.cs
src/Windows/Avalonia.Win32/WindowImpl.cs
tests/Avalonia.IntegrationTests.Appium/WindowTests.cs
@ -53,7 +53,11 @@
<Label Grid.Row="11" Content="MeasuredWith:" />
<TextBlock Grid.Column="1" Grid.Row="11" Name="CurrentMeasuredWithText" Text="{Binding #MyBorder.MeasuredWith}" />
<Button Name="HideButton" Grid.Row="12" Command="{Binding $parent[Window].Hide}">Hide</Button>
<StackPanel Orientation="Horizontal" Grid.Row="12">
<Button Name="HideButton" Command="{Binding $parent[Window].Hide}">Hide</Button>
<Button Name="AddToWidth" Click="AddToWidth_Click">Add to Width</Button>
<Button Name="AddToHeight" Click="AddToHeight_Click">Add to Height</Button>
</StackPanel>
</Grid>
</integrationTestApp:MeasureBorder>
@ -2,6 +2,7 @@ using System;
using System.Runtime.InteropServices ;
using Avalonia ;
using Avalonia.Controls ;
using Avalonia.Interactivity ;
using Avalonia.Threading ;
namespace IntegrationTestApp
@ -70,5 +71,8 @@ namespace IntegrationTestApp
{
_ orderTextBox ! . Text = MacOSIntegration . GetOrderedIndex ( this ) . ToString ( ) ;
}
private void AddToWidth_Click ( object? sender , RoutedEventArgs e ) = > Width = Bounds . Width + 1 0 ;
private void AddToHeight_Click ( object? sender , RoutedEventArgs e ) = > Height = Bounds . Height + 1 0 ;
}
}
@ -608,12 +608,6 @@ namespace Avalonia.Win32
return ;
}
}
else
{
var position = Position ;
windowPlacement . NormalPosition . left = position . X ;
windowPlacement . NormalPosition . top = position . Y ;
}
windowPlacement . NormalPosition . right = windowPlacement . NormalPosition . left + windowWidth ;
windowPlacement . NormalPosition . bottom = windowPlacement . NormalPosition . top + windowHeight ;
@ -349,6 +349,24 @@ namespace Avalonia.IntegrationTests.Appium
}
}
[PlatformFact(TestPlatforms.Windows)]
public void Changing_Size_Should_Not_Change_Position ( )
{
using ( OpenWindow ( ) )
{
var info = GetWindowInfo ( ) ;
Session . FindElementByAccessibilityId ( "AddToWidth" ) . SendClick ( ) ;
Session . FindElementByAccessibilityId ( "AddToHeight" ) . SendClick ( ) ;
var updatedInfo = GetWindowInfo ( ) ;
Assert . Equal ( info . Position , updatedInfo . Position ) ;
Assert . Equal ( info . FrameSize
. WithWidth ( info . FrameSize . Width + 1 0 )
. WithHeight ( info . FrameSize . Height + 1 0 ) , updatedInfo . FrameSize ) ;
}
}
public static TheoryData < Size ? , ShowWindowMode , WindowStartupLocation , bool > StartupLocationData ( )
{
var sizes = new Size ? [ ] { null , new Size ( 4 0 0 , 3 0 0 ) } ;