Browse Source

Merge pull request #8574 from AvaloniaUI/fixes/win32-consistent-minimize-restore-window-size

Win32: Retain window position and size when docked and then minimized and restored.
pull/8715/head
Dan Walmsley 4 years ago
committed by GitHub
parent
commit
2737c50387
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/Windows/Avalonia.Win32/WindowImpl.cs
  2. 39
      tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

3
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -285,11 +285,12 @@ namespace Avalonia.Win32
set
{
if (IsWindowVisible(_hwnd))
if (IsWindowVisible(_hwnd) && _lastWindowState != value)
{
ShowWindow(value, value != WindowState.Minimized); // If the window is minimized, it shouldn't be activated
}
_lastWindowState = value;
_showWindowState = value;
}
}

39
tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

@ -1,7 +1,9 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Avalonia.Controls;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Interactions;
using Xunit;
@ -55,6 +57,43 @@ namespace Avalonia.IntegrationTests.Appium
}
}
}
[PlatformFact(TestPlatforms.Windows)]
public void OnWindows_Docked_Windows_Retain_Size_Position_When_Restored()
{
using (OpenWindow(new Size(400, 400), ShowWindowMode.NonOwned, WindowStartupLocation.Manual))
{
var windowState = _session.FindElementByAccessibilityId("WindowState");
Assert.Equal("Normal", windowState.GetComboBoxValue());
var window = _session.FindElements(By.XPath("//Window")).First();
new Actions(_session)
.KeyDown(Keys.Meta)
.SendKeys(Keys.Left)
.KeyUp(Keys.Meta)
.Perform();
var original = GetWindowInfo();
windowState.Click();
_session.FindElementByName("Minimized").SendClick();
new Actions(_session)
.KeyDown(Keys.Alt)
.SendKeys(Keys.Tab)
.KeyUp(Keys.Alt)
.Perform();
var current = GetWindowInfo();
Assert.Equal(original.Position, current.Position);
Assert.Equal(original.FrameSize, current.FrameSize);
}
}
[Theory]

Loading…
Cancel
Save