Skip to content

Commit 863fd9d

Browse files
committed
Update the logic of the profile to be sure to save state when needed
1 parent e5c0ffd commit 863fd9d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

SoundSwitch/Framework/Profile/Profile.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ internal DeviceRoleWrapper(DeviceInfo deviceInfo, ERole role)
3232
public IList<Trigger.Trigger> Triggers { get; set; } = new List<Trigger.Trigger>();
3333

3434
public bool AlsoSwitchDefaultDevice { get; set; } = false;
35-
35+
/// <summary>
36+
/// Should the device be restore when the profile is disabled
37+
/// </summary>
3638
public bool RestoreDevices
3739
{
3840
get => AlsoSwitchDefaultDevice && (_restoreDevices ?? AlsoSwitchDefaultDevice);

SoundSwitch/Framework/Profile/ProfileManager.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,12 @@ private void RegisterEvents()
162162
/// </summary>
163163
private bool SaveCurrentState(User32.NativeMethods.HWND windowHandle, Profile profile, Trigger.Trigger trigger)
164164
{
165-
if (!_triggerFactory.Get(trigger.Type).AlwaysDefaultAndRestoreDevice && (!trigger.ShouldRestoreDevices || !profile.AlsoSwitchDefaultDevice))
165+
var triggerDefinition = _triggerFactory.Get(trigger.Type);
166+
if (!(triggerDefinition.AlwaysDefaultAndRestoreDevice || (profile.RestoreDevices && triggerDefinition.CanRestoreDevices)))
167+
{
166168
return false;
167-
169+
}
170+
168171
if (_activeWindowsTrigger.ContainsKey(windowHandle))
169172
{
170173
return false;

0 commit comments

Comments
 (0)