Skip to content

Commit

Permalink
Ensures backdrop is initializes when window becomes visible
Browse files Browse the repository at this point in the history
Fixes #90
  • Loading branch information
dotMorten committed Dec 8, 2022
1 parent f55f283 commit ceacf87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<Authors>Morten Nielsen - https://xaml.dev</Authors>
<Company>Morten Nielsen - https://xaml.dev</Company>
<PackageIcon>logo.png</PackageIcon>
<Version>2.0.0</Version>
<PackageValidationBaselineVersion>1.8.0</PackageValidationBaselineVersion>
<Version>2.0.1</Version>
<PackageValidationBaselineVersion>2.0.0</PackageValidationBaselineVersion>
</PropertyGroup>

<ItemGroup Condition="'$(PackageId)'!=''">
Expand Down
10 changes: 2 additions & 8 deletions src/WinUIEx/WinUIEx.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--<Sdk Name="Microsoft.DotNet.PackageValidation" Version="1.0.0-preview.7.21379.12" />-->
<Sdk Name="Microsoft.DotNet.PackageValidation" Version="1.0.0-preview.7.21379.12" />

<PropertyGroup>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
Expand All @@ -22,13 +22,7 @@
<PackageId>WinUIEx</PackageId>
<Product>WinUI Extensions</Product>
<PackageReleaseNotes>
- Major version update. Requires Windows App SDK v1.2.
- BREAKING: Removed `MediaPlayerElement` control (now included in Windows App SDK 1.2).
- BREAKING: Remove obsolete APIs (tray icon and WindowEx.TitleBar).
- Add support for trimming.
- Fix issue where MicaAlt wasn't applied. Setting Kind on the Mica backdrop will now change the backdrop settings for properties that hasn't been explicitly overridden (matches Windows App SDK behavior). (Issue #88)
- Adds support for defining a maximum width and height of the window. (Issue #81)
- Remove workarounds for issues now addressed in Windows App SDK v1.2.
- Ensure backdrop is always initialized during startup (Issue #90)
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
8 changes: 8 additions & 0 deletions src/WinUIEx/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,20 @@ private WindowManager(Window window, WindowMessageMonitor monitor)
_monitor.WindowMessageReceived += OnWindowMessage;
_window.Activated += Window_Activated;
_window.Closed += Window_Closed;
_window.VisibilityChanged += Window_VisibilityChanged;
AppWindow.Changed += AppWindow_Changed;

overlappedPresenter = AppWindow.Presenter as OverlappedPresenter ?? Microsoft.UI.Windowing.OverlappedPresenter.Create();
managers[window.GetWindowHandle()] = new WeakReference<WindowManager>(this);
}

private void Window_VisibilityChanged(object sender, WindowVisibilityChangedEventArgs args)
{
// Ensures backdrop gets set up if it was previously attempted initialized while window wasn't visible
if (args.Visible && m_backdrop is not null && currentController is null)
InitBackdrop();
}

private void Window_Activated(object sender, WindowActivatedEventArgs args)
{
if (BackdropConfiguration != null)
Expand Down

0 comments on commit ceacf87

Please sign in to comment.