Skip to content

Commit

Permalink
Don't throw exceptions on back-to-back window deactivations (#23519)
Browse files Browse the repository at this point in the history
* Don't throw exceptions on back-to-back window deactivations, as this is valid behavior on platforms such as Windows.

* Switch activation logic check to be in MauiWinUIWindow

* Clarify comment

---------

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
  • Loading branch information
Foda and Mike Corsaro authored Jul 13, 2024
1 parent 4f97f92 commit 79dd879
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Core/src/Platform/Windows/MauiWinUIWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ protected virtual void OnActivated(object sender, UI.Xaml.WindowActivatedEventAr
else
_enableResumeEvent = true;
}
else if (args.WindowActivationState == UI.Xaml.WindowActivationState.Deactivated &&
!_isActivated)
{
// Don't invoke deactivated event if we're not activated. It's possible we can
// recieve this event multiple times if we start a new child process and that
// process creates a new window
return;
}
else
{
_isActivated = false;
Expand Down

0 comments on commit 79dd879

Please sign in to comment.