Skip to content

Commit 9dae7aa

Browse files
authored
Merge pull request #1169 from unchihugo/fix/volume-flyout-activation
Update logic for volume flyout activation
2 parents b07bd4a + adb9718 commit 9dae7aa

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

‎FluentFlyoutWPF/MainWindow.xaml.cs‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,7 @@ private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
919919
if (mediaKeysPressed || (!SettingsManager.Current.MediaFlyoutVolumeKeysExcluded && volumeKeysPressed))
920920
result = TryShowMediaFlyoutDebounced();
921921

922-
if (SettingsManager.Current.VolumeControlEnabled)
923-
{
924-
volumeMixerWindow?.ViewModel.SyncMasterFromDevice();
925-
volumeMixerWindow?.ShowFlyout();
926-
}
922+
ShowVolumeFlyout();
927923

928924
if (!result)
929925
{
@@ -974,6 +970,15 @@ private bool TryShowMediaFlyoutDebounced()
974970
return true;
975971
}
976972

973+
private void ShowVolumeFlyout()
974+
{
975+
if (!SettingsManager.Current.VolumeControlEnabled)
976+
return;
977+
978+
volumeMixerWindow?.ViewModel.SyncMasterFromDevice();
979+
volumeMixerWindow?.ShowFlyout();
980+
}
981+
977982
public async void ShowMediaFlyout(bool toggleMode = false, bool forceShow = false)
978983
{
979984
var activeSession = GetActiveMediaSession();
@@ -1709,18 +1714,13 @@ private nint WndProc(nint hwnd, int msg, nint wParam, nint lParam, ref bool hand
17091714
_ => false
17101715
};
17111716

1712-
bool isVolumeCommand = false;
1713-
1714-
if (!isMediaCommand && !SettingsManager.Current.MediaFlyoutVolumeKeysExcluded)
1717+
bool isVolumeCommand = cmd switch
17151718
{
1716-
isVolumeCommand = cmd switch
1717-
{
1718-
APPCOMMAND_VOLUME_MUTE => true,
1719-
APPCOMMAND_VOLUME_DOWN => true,
1720-
APPCOMMAND_VOLUME_UP => true,
1721-
_ => false
1722-
};
1723-
}
1719+
APPCOMMAND_VOLUME_MUTE => true,
1720+
APPCOMMAND_VOLUME_DOWN => true,
1721+
APPCOMMAND_VOLUME_UP => true,
1722+
_ => false
1723+
};
17241724

17251725
if (!isMediaCommand && !isVolumeCommand)
17261726
return 0;
@@ -1730,9 +1730,14 @@ private nint WndProc(nint hwnd, int msg, nint wParam, nint lParam, ref bool hand
17301730
if (!isKeyCommand)
17311731
return 0;
17321732

1733-
bool result = TryShowMediaFlyoutDebounced();
1733+
bool result = false;
1734+
if (isMediaCommand || (!SettingsManager.Current.MediaFlyoutVolumeKeysExcluded && isVolumeCommand))
1735+
result = TryShowMediaFlyoutDebounced();
1736+
1737+
if (isVolumeCommand)
1738+
ShowVolumeFlyout();
17341739

1735-
if (!result)
1740+
if (!result && !isVolumeCommand)
17361741
{
17371742
return 0;
17381743
}

0 commit comments

Comments
 (0)