Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos: Don't reopen hidden window when parent clicked. #8618

Merged
merged 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
{
if(Window != nullptr)
{
if (![Window isMiniaturized])
if ([Window isVisible] && ![Window isMiniaturized])
{
if(IsDialog())
{
Expand Down
1 change: 1 addition & 0 deletions samples/IntegrationTestApp/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void RestoreAll()

foreach (var window in lifetime.Windows)
{
window.Show();
if (window.WindowState == WindowState.Minimized)
window.WindowState = WindowState.Normal;
}
Expand Down
3 changes: 2 additions & 1 deletion samples/IntegrationTestApp/ShowWindowTest.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
x:Class="IntegrationTestApp.ShowWindowTest"
Name="SecondaryWindow"
Title="Show Window Test">
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Label Grid.Column="0" Grid.Row="1">Client Size</Label>
<TextBox Name="ClientSize" Grid.Column="1" Grid.Row="1" IsReadOnly="True"
Text="{Binding ClientSize, Mode=OneWay}"/>
Expand Down Expand Up @@ -31,5 +31,6 @@
<ComboBoxItem>Maximized</ComboBoxItem>
<ComboBoxItem>Fullscreen</ComboBoxItem>
</ComboBox>
<Button Name="HideButton" Grid.Row="8" Command="{Binding $parent[Window].Hide}">Hide</Button>
</Grid>
</Window>
29 changes: 29 additions & 0 deletions tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,35 @@ public void Minimize_Button_Minimizes_Window(ShowWindowMode mode)
}
}

[PlatformFact(TestPlatforms.MacOS)]
public void Hidden_Child_Window_Is_Not_Reshown_When_Parent_Clicked()
{
var mainWindow = _session.FindElementByAccessibilityId("MainWindow");

// We don't use dispose to close the window here, because it seems that hiding and re-showing a window
// causes Appium to think it's a different window.
OpenWindow(null, ShowWindowMode.Owned, WindowStartupLocation.Manual);

var secondaryWindow = FindWindow(_session, "SecondaryWindow");
var hideButton = secondaryWindow.FindElementByAccessibilityId("HideButton");

hideButton.Click();

var windows = _session.FindElementsByXPath("XCUIElementTypeWindow");
Assert.Single(windows);

mainWindow.Click();

windows = _session.FindElementsByXPath("XCUIElementTypeWindow");
Assert.Single(windows);

_session.FindElementByAccessibilityId("RestoreAll").Click();

// Close the window manually.
secondaryWindow = FindWindow(_session, "SecondaryWindow");
secondaryWindow.GetChromeButtons().close.Click();
}

private IDisposable OpenWindow(PixelSize? size, ShowWindowMode mode, WindowStartupLocation location)
{
var sizeTextBox = _session.FindElementByAccessibilityId("ShowWindowSize");
Expand Down