Skip to content

Commit 06c83fb

Browse files
authored
Merge pull request AvaloniaUI#8415 from AvaloniaUI/backport/8405
Backport macOS windowing fixes.
2 parents 277d94c + af05fce commit 06c83fb

File tree

18 files changed

+563
-47
lines changed

18 files changed

+563
-47
lines changed

Avalonia.sln

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsInteropTest", "sampl
237237
EndProject
238238
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlSamples", "samples\SampleControls\ControlSamples.csproj", "{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}"
239239
EndProject
240+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTestApp", "samples\IntegrationTestApp\IntegrationTestApp.csproj", "{D3867680-B9C7-43D6-BF2C-697EC9CF1151}"
241+
EndProject
240242
Global
241-
GlobalSection(SharedMSBuildProjectFiles) = preSolution
242-
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
243-
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 5
244-
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 5
245-
src\Shared\RenderHelpers\RenderHelpers.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 5
246-
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 5
247-
src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13
248-
EndGlobalSection
249243
GlobalSection(SolutionConfigurationPlatforms) = preSolution
250244
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
251245
Ad-Hoc|iPhone = Ad-Hoc|iPhone
@@ -2195,6 +2189,30 @@ Global
21952189
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}.Release|iPhone.Build.0 = Release|Any CPU
21962190
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
21972191
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
2192+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
2193+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
2194+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
2195+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
2196+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
2197+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
2198+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
2199+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|Any CPU.Build.0 = Debug|Any CPU
2200+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
2201+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhone.Build.0 = Debug|Any CPU
2202+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
2203+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
2204+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2205+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|Any CPU.Build.0 = Debug|Any CPU
2206+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhone.ActiveCfg = Debug|Any CPU
2207+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhone.Build.0 = Debug|Any CPU
2208+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
2209+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
2210+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|Any CPU.ActiveCfg = Release|Any CPU
2211+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|Any CPU.Build.0 = Release|Any CPU
2212+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhone.ActiveCfg = Release|Any CPU
2213+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhone.Build.0 = Release|Any CPU
2214+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
2215+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
21982216
EndGlobalSection
21992217
GlobalSection(SolutionProperties) = preSolution
22002218
HideSolutionNode = FALSE
@@ -2258,8 +2276,17 @@ Global
22582276
{C08E9894-AA92-426E-BF56-033E262CAD3E} = {9B9E3891-2366-4253-A952-D08BCEB71098}
22592277
{26A98DA1-D89D-4A95-8152-349F404DA2E2} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
22602278
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270} = {9B9E3891-2366-4253-A952-D08BCEB71098}
2279+
{D3867680-B9C7-43D6-BF2C-697EC9CF1151} = {9B9E3891-2366-4253-A952-D08BCEB71098}
22612280
EndGlobalSection
22622281
GlobalSection(ExtensibilityGlobals) = postSolution
22632282
SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A}
22642283
EndGlobalSection
2284+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
2285+
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
2286+
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 5
2287+
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 5
2288+
src\Shared\RenderHelpers\RenderHelpers.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 5
2289+
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 5
2290+
src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13
2291+
EndGlobalSection
22652292
EndGlobal

native/Avalonia.Native/src/OSX/WindowBaseImpl.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
if (ret == nullptr)
224224
return E_POINTER;
225225

226-
if(Window != nullptr){
226+
if(Window != nullptr && _shown){
227227
auto frame = [Window frame];
228228
ret->Width = frame.size.width;
229229
ret->Height = frame.size.height;

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,16 @@
118118
{
119119
if(Window != nullptr)
120120
{
121-
if(IsDialog())
121+
if (![Window isMiniaturized])
122122
{
123-
Activate();
124-
}
125-
else
126-
{
127-
[Window orderFront:nullptr];
123+
if(IsDialog())
124+
{
125+
Activate();
126+
}
127+
else
128+
{
129+
[Window orderFront:nullptr];
130+
}
128131
}
129132

130133
[Window invalidateShadow];
@@ -487,6 +490,8 @@
487490
}
488491

489492
if (_shown) {
493+
_actualWindowState = _lastWindowState;
494+
490495
switch (state) {
491496
case Maximized:
492497
if (currentState == FullScreen) {
@@ -544,7 +549,6 @@
544549
break;
545550
}
546551

547-
_actualWindowState = _lastWindowState;
548552
WindowEvents->WindowStateChanged(_actualWindowState);
549553
}
550554

samples/IntegrationTestApp/App.axaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Application xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
x:Class="IntegrationTestApp.App">
4+
<Application.Styles>
5+
<FluentTheme Mode="Light"/>
6+
</Application.Styles>
7+
</Application>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Avalonia;
2+
using Avalonia.Controls.ApplicationLifetimes;
3+
using Avalonia.Markup.Xaml;
4+
5+
namespace IntegrationTestApp
6+
{
7+
public class App : Application
8+
{
9+
public override void Initialize()
10+
{
11+
AvaloniaXamlLoader.Load(this);
12+
}
13+
14+
public override void OnFrameworkInitializationCompleted()
15+
{
16+
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
17+
{
18+
desktop.MainWindow = new MainWindow();
19+
}
20+
21+
base.OnFrameworkInitializationCompleted();
22+
}
23+
}
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>WinExe</OutputType>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<CFBundleName>IntegrationTestApp</CFBundleName>
10+
<CFBundleIdentifier>net.avaloniaui.avalonia.integrationtestapp</CFBundleIdentifier>
11+
<NSHighResolutionCapable>true</NSHighResolutionCapable>
12+
<CFBundleShortVersionString>1.0.0</CFBundleShortVersionString>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
21+
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
22+
</ItemGroup>
23+
24+
<Import Project="..\..\build\BuildTargets.targets" />
25+
<Import Project="..\..\build\SampleApp.props" />
26+
<Import Project="..\..\build\ReferenceCoreLibraries.props" />
27+
28+
</Project>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<Window xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
6+
x:Class="IntegrationTestApp.MainWindow"
7+
Name="MainWindow"
8+
Title="IntegrationTestApp">
9+
<NativeMenu.Menu>
10+
<NativeMenu>
11+
<NativeMenuItem Header="File">
12+
<NativeMenu>
13+
<NativeMenuItem Header="Open..."/>
14+
</NativeMenu>
15+
</NativeMenuItem>
16+
<NativeMenuItem Header="View">
17+
<NativeMenu/>
18+
</NativeMenuItem>
19+
</NativeMenu>
20+
</NativeMenu.Menu>
21+
<DockPanel>
22+
<NativeMenuBar DockPanel.Dock="Top"/>
23+
24+
<TabControl TabStripPlacement="Left" Name="MainTabs">
25+
<TabItem Header="Automation">
26+
<StackPanel>
27+
<TextBlock Name="TextBlockWithName">TextBlockWithName</TextBlock>
28+
<TextBlock Name="NotTheAutomationId">
29+
TextBlockWithNameAndAutomationId
30+
</TextBlock>
31+
<TextBlock Name="TextBlockAsLabel">Label for TextBox</TextBlock>
32+
<TextBox Name="LabeledByTextBox">
33+
Foo
34+
</TextBox>
35+
</StackPanel>
36+
</TabItem>
37+
38+
<TabItem Header="Button">
39+
<StackPanel>
40+
<Button Name="DisabledButton" IsEnabled="False">
41+
Disabled Button
42+
</Button>
43+
<Button Name="BasicButton">
44+
Basic Button
45+
</Button>
46+
<Button Name="ButtonWithTextBlock">
47+
<TextBlock>Button with TextBlock</TextBlock>
48+
</Button>
49+
<Button Name="ButtonWithAcceleratorKey" HotKey="Ctrl+B">Button with Accelerator Key</Button>
50+
</StackPanel>
51+
</TabItem>
52+
53+
<TabItem Header="CheckBox">
54+
<StackPanel>
55+
<CheckBox Name="UncheckedCheckBox">Unchecked</CheckBox>
56+
<CheckBox Name="CheckedCheckBox" IsChecked="True">Checked</CheckBox>
57+
<CheckBox Name="ThreeStateCheckBox" IsThreeState="True" IsChecked="{x:Null}">ThreeState</CheckBox>
58+
</StackPanel>
59+
</TabItem>
60+
61+
<TabItem Header="ComboBox">
62+
<StackPanel>
63+
<ComboBox Name="BasicComboBox">
64+
<ComboBoxItem>Item 0</ComboBoxItem>
65+
<ComboBoxItem>Item 1</ComboBoxItem>
66+
</ComboBox>
67+
<Button Name="ComboBoxSelectionClear">Clear Selection</Button>
68+
<Button Name="ComboBoxSelectFirst">Select First</Button>
69+
</StackPanel>
70+
</TabItem>
71+
72+
<TabItem Header="ListBox">
73+
<DockPanel>
74+
<StackPanel DockPanel.Dock="Bottom">
75+
<Button Name="ListBoxSelectionClear">Clear Selection</Button>
76+
</StackPanel>
77+
<ListBox Name="BasicListBox" Items="{Binding ListBoxItems}" SelectionMode="Multiple"/>
78+
</DockPanel>
79+
</TabItem>
80+
81+
<TabItem Header="Menu">
82+
<DockPanel>
83+
<Menu DockPanel.Dock="Top">
84+
<MenuItem Name="RootMenuItem" Header="_Root">
85+
<MenuItem Name="Child1MenuItem" Header="_Child 1" InputGesture="Ctrl+O" Click="MenuClicked"/>
86+
<MenuItem Name="Child2MenuItem" Header="C_hild 2">
87+
<MenuItem Name="GrandchildMenuItem" Header="_Grandchild" Click="MenuClicked"/>
88+
</MenuItem>
89+
</MenuItem>
90+
</Menu>
91+
<StackPanel>
92+
<TextBlock Name="ClickedMenuItem">None</TextBlock>
93+
<Button Name="MenuClickedMenuItemReset">Reset</Button>
94+
<TextBox Name="MenuFocusTest"/>
95+
</StackPanel>
96+
</DockPanel>
97+
</TabItem>
98+
99+
<TabItem Header="Window">
100+
<StackPanel>
101+
<TextBox Name="ShowWindowSize" Watermark="Window Size"/>
102+
<ComboBox Name="ShowWindowMode" SelectedIndex="0">
103+
<ComboBoxItem>NonOwned</ComboBoxItem>
104+
<ComboBoxItem>Owned</ComboBoxItem>
105+
<ComboBoxItem>Modal</ComboBoxItem>
106+
</ComboBox>
107+
<ComboBox Name="ShowWindowLocation" SelectedIndex="0">
108+
<ComboBoxItem>Manual</ComboBoxItem>
109+
<ComboBoxItem>CenterScreen</ComboBoxItem>
110+
<ComboBoxItem>CenterOwner</ComboBoxItem>
111+
</ComboBox>
112+
<Button Name="ShowWindow">Show Window</Button>
113+
<Button Name="SendToBack">Send to Back</Button>
114+
<Button Name="ExitFullscreen">Exit Fullscreen</Button>
115+
<Button Name="RestoreAll">Restore All</Button>
116+
</StackPanel>
117+
</TabItem>
118+
</TabControl>
119+
</DockPanel>
120+
</Window>

0 commit comments

Comments
 (0)