Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#8415 from AvaloniaUI/backport/8405
Browse files Browse the repository at this point in the history
Backport macOS windowing fixes.
  • Loading branch information
danwalmsley authored Jul 4, 2022
2 parents 277d94c + af05fce commit 06c83fb
Show file tree
Hide file tree
Showing 18 changed files with 563 additions and 47 deletions.
43 changes: 35 additions & 8 deletions Avalonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsInteropTest", "sampl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ControlSamples", "samples\SampleControls\ControlSamples.csproj", "{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTestApp", "samples\IntegrationTestApp\IntegrationTestApp.csproj", "{D3867680-B9C7-43D6-BF2C-697EC9CF1151}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 5
src\Shared\RenderHelpers\RenderHelpers.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Ad-Hoc|iPhone = Ad-Hoc|iPhone
Expand Down Expand Up @@ -2195,6 +2189,30 @@ Global
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}.Release|iPhone.Build.0 = Release|Any CPU
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhone.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhone.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|Any CPU.Build.0 = Release|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhone.ActiveCfg = Release|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhone.Build.0 = Release|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{D3867680-B9C7-43D6-BF2C-697EC9CF1151}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2258,8 +2276,17 @@ Global
{C08E9894-AA92-426E-BF56-033E262CAD3E} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{26A98DA1-D89D-4A95-8152-349F404DA2E2} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
{A0D0A6A4-5C72-4ADA-9B27-621C7D94F270} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{D3867680-B9C7-43D6-BF2C-697EC9CF1151} = {9B9E3891-2366-4253-A952-D08BCEB71098}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 5
src\Shared\RenderHelpers\RenderHelpers.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
if (ret == nullptr)
return E_POINTER;

if(Window != nullptr){
if(Window != nullptr && _shown){
auto frame = [Window frame];
ret->Width = frame.size.width;
ret->Height = frame.size.height;
Expand Down
18 changes: 11 additions & 7 deletions native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,16 @@
{
if(Window != nullptr)
{
if(IsDialog())
if (![Window isMiniaturized])
{
Activate();
}
else
{
[Window orderFront:nullptr];
if(IsDialog())
{
Activate();
}
else
{
[Window orderFront:nullptr];
}
}

[Window invalidateShadow];
Expand Down Expand Up @@ -487,6 +490,8 @@
}

if (_shown) {
_actualWindowState = _lastWindowState;

switch (state) {
case Maximized:
if (currentState == FullScreen) {
Expand Down Expand Up @@ -544,7 +549,6 @@
break;
}

_actualWindowState = _lastWindowState;
WindowEvents->WindowStateChanged(_actualWindowState);
}

Expand Down
7 changes: 7 additions & 0 deletions samples/IntegrationTestApp/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="IntegrationTestApp.App">
<Application.Styles>
<FluentTheme Mode="Light"/>
</Application.Styles>
</Application>
24 changes: 24 additions & 0 deletions samples/IntegrationTestApp/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace IntegrationTestApp
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}

base.OnFrameworkInitializationCompleted();
}
}
}
28 changes: 28 additions & 0 deletions samples/IntegrationTestApp/IntegrationTestApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<CFBundleName>IntegrationTestApp</CFBundleName>
<CFBundleIdentifier>net.avaloniaui.avalonia.integrationtestapp</CFBundleIdentifier>
<NSHighResolutionCapable>true</NSHighResolutionCapable>
<CFBundleShortVersionString>1.0.0</CFBundleShortVersionString>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
</ItemGroup>

<Import Project="..\..\build\BuildTargets.targets" />
<Import Project="..\..\build\SampleApp.props" />
<Import Project="..\..\build\ReferenceCoreLibraries.props" />

</Project>
120 changes: 120 additions & 0 deletions samples/IntegrationTestApp/MainWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IntegrationTestApp.MainWindow"
Name="MainWindow"
Title="IntegrationTestApp">
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="File">
<NativeMenu>
<NativeMenuItem Header="Open..."/>
</NativeMenu>
</NativeMenuItem>
<NativeMenuItem Header="View">
<NativeMenu/>
</NativeMenuItem>
</NativeMenu>
</NativeMenu.Menu>
<DockPanel>
<NativeMenuBar DockPanel.Dock="Top"/>

<TabControl TabStripPlacement="Left" Name="MainTabs">
<TabItem Header="Automation">
<StackPanel>
<TextBlock Name="TextBlockWithName">TextBlockWithName</TextBlock>
<TextBlock Name="NotTheAutomationId">
TextBlockWithNameAndAutomationId
</TextBlock>
<TextBlock Name="TextBlockAsLabel">Label for TextBox</TextBlock>
<TextBox Name="LabeledByTextBox">
Foo
</TextBox>
</StackPanel>
</TabItem>

<TabItem Header="Button">
<StackPanel>
<Button Name="DisabledButton" IsEnabled="False">
Disabled Button
</Button>
<Button Name="BasicButton">
Basic Button
</Button>
<Button Name="ButtonWithTextBlock">
<TextBlock>Button with TextBlock</TextBlock>
</Button>
<Button Name="ButtonWithAcceleratorKey" HotKey="Ctrl+B">Button with Accelerator Key</Button>
</StackPanel>
</TabItem>

<TabItem Header="CheckBox">
<StackPanel>
<CheckBox Name="UncheckedCheckBox">Unchecked</CheckBox>
<CheckBox Name="CheckedCheckBox" IsChecked="True">Checked</CheckBox>
<CheckBox Name="ThreeStateCheckBox" IsThreeState="True" IsChecked="{x:Null}">ThreeState</CheckBox>
</StackPanel>
</TabItem>

<TabItem Header="ComboBox">
<StackPanel>
<ComboBox Name="BasicComboBox">
<ComboBoxItem>Item 0</ComboBoxItem>
<ComboBoxItem>Item 1</ComboBoxItem>
</ComboBox>
<Button Name="ComboBoxSelectionClear">Clear Selection</Button>
<Button Name="ComboBoxSelectFirst">Select First</Button>
</StackPanel>
</TabItem>

<TabItem Header="ListBox">
<DockPanel>
<StackPanel DockPanel.Dock="Bottom">
<Button Name="ListBoxSelectionClear">Clear Selection</Button>
</StackPanel>
<ListBox Name="BasicListBox" Items="{Binding ListBoxItems}" SelectionMode="Multiple"/>
</DockPanel>
</TabItem>

<TabItem Header="Menu">
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Name="RootMenuItem" Header="_Root">
<MenuItem Name="Child1MenuItem" Header="_Child 1" InputGesture="Ctrl+O" Click="MenuClicked"/>
<MenuItem Name="Child2MenuItem" Header="C_hild 2">
<MenuItem Name="GrandchildMenuItem" Header="_Grandchild" Click="MenuClicked"/>
</MenuItem>
</MenuItem>
</Menu>
<StackPanel>
<TextBlock Name="ClickedMenuItem">None</TextBlock>
<Button Name="MenuClickedMenuItemReset">Reset</Button>
<TextBox Name="MenuFocusTest"/>
</StackPanel>
</DockPanel>
</TabItem>

<TabItem Header="Window">
<StackPanel>
<TextBox Name="ShowWindowSize" Watermark="Window Size"/>
<ComboBox Name="ShowWindowMode" SelectedIndex="0">
<ComboBoxItem>NonOwned</ComboBoxItem>
<ComboBoxItem>Owned</ComboBoxItem>
<ComboBoxItem>Modal</ComboBoxItem>
</ComboBox>
<ComboBox Name="ShowWindowLocation" SelectedIndex="0">
<ComboBoxItem>Manual</ComboBoxItem>
<ComboBoxItem>CenterScreen</ComboBoxItem>
<ComboBoxItem>CenterOwner</ComboBoxItem>
</ComboBox>
<Button Name="ShowWindow">Show Window</Button>
<Button Name="SendToBack">Send to Back</Button>
<Button Name="ExitFullscreen">Exit Fullscreen</Button>
<Button Name="RestoreAll">Restore All</Button>
</StackPanel>
</TabItem>
</TabControl>
</DockPanel>
</Window>
Loading

0 comments on commit 06c83fb

Please sign in to comment.