Skip to content
Merged
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
53 changes: 34 additions & 19 deletions src/TrayIconFlyout.Shared/TrayIconFlyout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
#endif

private readonly XamlIslandHostWindow? _host;
private bool? _wasTaskbarLightLastTimeChecked;

Check warning on line 44 in src/TrayIconFlyout.Shared/TrayIconFlyout.cs

View workflow job for this annotation

GitHub Actions / build-uwp (Debug, x64)

The field 'TrayIconFlyout._wasTaskbarLightLastTimeChecked' is never used

Check warning on line 44 in src/TrayIconFlyout.Shared/TrayIconFlyout.cs

View workflow job for this annotation

GitHub Actions / build-uwp (Debug, ARM64)

The field 'TrayIconFlyout._wasTaskbarLightLastTimeChecked' is never used

Check warning on line 44 in src/TrayIconFlyout.Shared/TrayIconFlyout.cs

View workflow job for this annotation

GitHub Actions / build-uwp (Release, x64)

The field 'TrayIconFlyout._wasTaskbarLightLastTimeChecked' is never used

Check warning on line 44 in src/TrayIconFlyout.Shared/TrayIconFlyout.cs

View workflow job for this annotation

GitHub Actions / build-uwp (Release, ARM64)

The field 'TrayIconFlyout._wasTaskbarLightLastTimeChecked' is never used
private bool? _wasTaskbarColorPrevalenceLastTimeChecked;
private bool _isPopupAnimationPlaying;
private Point? _customPlacementBottomCenterPoint;
private TrayIconFlyoutPopupDirection? _customPopupDirection;
Expand Down Expand Up @@ -185,25 +184,41 @@

var isTaskbarLight = GeneralHelpers.IsTaskbarLight();
var isTaskbarColorPrevalence = GeneralHelpers.IsTaskbarColorPrevalenceEnabled();
bool shouldUpdateBackdrop = _wasTaskbarLightLastTimeChecked != isTaskbarLight || _wasTaskbarColorPrevalenceLastTimeChecked != isTaskbarColorPrevalence;
_wasTaskbarLightLastTimeChecked = isTaskbarLight;
_wasTaskbarColorPrevalenceLastTimeChecked = isTaskbarColorPrevalence;
if (!shouldUpdateBackdrop && !coerce)
return;

ISystemBackdropControllerWithTargets? controller = BackdropKind is BackdropKind.Acrylic
? (isTaskbarColorPrevalence
? BackdropControllerHelpers.GetAccentedAcrylicController()
: isTaskbarLight
? BackdropControllerHelpers.GetLightAcrylicController()
: BackdropControllerHelpers.GetDarkAcrylicController())
: (isTaskbarColorPrevalence
? BackdropControllerHelpers.GetAccentedMicaController()
: isTaskbarLight
? BackdropControllerHelpers.GetLightMicaController()
: BackdropControllerHelpers.GetDarkMicaController());
if (controller is null)
return;
ISystemBackdropControllerWithTargets? controller = null;
if (coerce)
{
controller = BackdropKind is BackdropKind.Acrylic
? (isTaskbarColorPrevalence
? BackdropControllerHelpers.GetAccentedAcrylicController()
: isTaskbarLight
? BackdropControllerHelpers.GetLightAcrylicController()
: BackdropControllerHelpers.GetDarkAcrylicController())
: (isTaskbarColorPrevalence
? BackdropControllerHelpers.GetAccentedMicaController()
: isTaskbarLight
? BackdropControllerHelpers.GetLightMicaController()
: BackdropControllerHelpers.GetDarkMicaController());
}
else if (isTaskbarColorPrevalence) // Force update backdrop when color prevalence is on, as the accent color might change
{
controller = BackdropKind is BackdropKind.Acrylic
? BackdropControllerHelpers.GetAccentedAcrylicController()
: BackdropControllerHelpers.GetAccentedMicaController();
}
else if (_wasTaskbarLightLastTimeChecked != isTaskbarLight)
{
controller = BackdropKind is BackdropKind.Acrylic
? (isTaskbarLight
? BackdropControllerHelpers.GetLightAcrylicController()
: BackdropControllerHelpers.GetDarkAcrylicController())
: (isTaskbarLight
? BackdropControllerHelpers.GetLightMicaController()
: BackdropControllerHelpers.GetDarkMicaController());
_wasTaskbarLightLastTimeChecked = isTaskbarLight;
}
if (controller is null)
return;

BackdropManager?.Dispose();
BackdropManager = null;
Expand Down
Loading