Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
riverar committed Aug 6, 2023
2 parents a7d6e7d + 6677262 commit 3b44acb
Show file tree
Hide file tree
Showing 77 changed files with 2,026 additions and 131 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ jobs:
include:
- channel: AppInstaller
publisher:
"CN=File-New-Project, O=File-New-Project, L=Purcellville,
S=Virginia, C=US"
"CN=File-New-Project, O=File-New-Project, L=Purcellville, S=Virginia, C=US"
- channel: Store
publisher: CN=6099D0EF-9374-47ED-BDFE-A82136831235
- channel: Chocolatey
publisher:
"CN=File-New-Project, O=File-New-Project, L=Purcellville,
S=Virginia, C=US"
"CN=File-New-Project, O=File-New-Project, L=Purcellville, S=Virginia, C=US"
max-parallel: 3
steps:
- name: Checkout
Expand Down Expand Up @@ -193,6 +191,10 @@ jobs:
$manifest.AppInstaller.Uri = "https://install.eartrumpet.app/${{ steps.gitversion.outputs.branchName }}/EarTrumpet.Package.appinstaller"
$manifest.AppInstaller.MainBundle.Uri = "https://install.eartrumpet.app/${{ steps.gitversion.outputs.branchName }}/EarTrumpet.Package_${{ steps.gitversion.outputs.majorMinorPatch }}.${{ steps.gitversion.outputs.commitsSinceVersionSource }}_x86.appxbundle"
$manifest.AppInstaller.MainBundle.Publisher = "${{ matrix.publisher }}"
$fragment = [xml]'<AppInstaller xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"><Dependencies><Package Name="Microsoft.VCLibs.140.00.UWPDesktop" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.30704.0" ProcessorArchitecture="x86" Uri="https://aka.ms/Microsoft.VCLibs.x86.14.00.Desktop.appx" /></Dependencies></AppInstaller>'
$manifest.AppInstaller.InsertAfter($manifest.ImportNode($fragment.AppInstaller.Dependencies, $true), $manifest.AppInstaller.MainBundle)
$manifest.Save($manifestPath)
- name: Upload appinstaller/sideload package artifacts
Expand Down Expand Up @@ -279,14 +281,6 @@ jobs:
Expand-Archive package.zip -DestinationPath acs
Invoke-WebRequest $env:ACS_METADATA_URI -UseBasicParsing -OutFile acs\metadata.json
- name: Install Chocolatey
if: matrix.channel == 'Chocolatey'
shell: powershell
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- name: Sign and repackage Store artifacts
if: matrix.channel == 'Store'
shell: pwsh
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 2.3.0.0
- Added setting to turn on/off ability to change volume with the scroll wheel anywhere (thanks @Tester798!)
- Added setting to turn on/off ability to change volume with the scroll wheel when hovering over the EarTrumpet icon (thanks @Tester798!)
- Added new community settings area
- Added new community setting to turn on/off use of a logarithmic volume scale (thanks @yonatan-mitmit!)
- Added legacy shortcuts to the context menu pointing to [App volume and device preferences] / [Volume mixer]
- Added ability to use the Windows key in shortcuts (thanks @iamevn!)
- Added linguistic display name sorting for audio devices (thanks @Tester798!)
- Added a workaround for Windows Search (CortanaUI) showing a default asset (X) icon
- Fixed an issue where installation of EarTrumpet via AppInstaller would fail if the Visual C++ libs package was not installed
- Fixed an issue where EarTrumpet tooltips were not updating live while scrolling the mouse wheel on Windows 10 (thanks @krlvm!)
- Forced EarTrumpet to render in software-only mode to keep it off power hungry GPUs.
- Improved the flyout animation (thanks @krlvm!)

## 2.2.2.0
- Fixed an issue with the volume changing when scrolling in certain scenarios (e.g. virtual reality)
- Updated Japanese translations
Expand Down Expand Up @@ -231,4 +245,4 @@
- Fixed Ear Trumpet window not having the correct border and drop shadow

## 1.0.0.0
- Initial release
- Initial release
62 changes: 43 additions & 19 deletions EarTrumpet/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EarTrumpet.Extensibility;
using EarTrumpet.Extensibility.Hosting;
using EarTrumpet.Extensions;
using EarTrumpet.Interop;
using EarTrumpet.Interop.Helpers;
using EarTrumpet.UI.Helpers;
using EarTrumpet.UI.ViewModels;
Expand All @@ -14,6 +15,8 @@
using System.Threading;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;

namespace EarTrumpet
{
Expand All @@ -36,18 +39,21 @@ public partial class App
private WindowHolder _mixerWindow;
private WindowHolder _settingsWindow;
private ErrorReporter _errorReporter;
private AppSettings _settings;

public static AppSettings Settings { get; private set; }

private void OnAppStartup(object sender, StartupEventArgs e)
{
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

Exit += (_, __) => IsShuttingDown = true;
HasIdentity = PackageHelper.CheckHasIdentity();
HasDevIdentity = PackageHelper.HasDevIdentity();
PackageVersion = PackageHelper.GetVersion(HasIdentity);
PackageName = PackageHelper.GetFamilyName(HasIdentity);

_settings = new AppSettings();
_errorReporter = new ErrorReporter(_settings);
Settings = new AppSettings();
_errorReporter = new ErrorReporter(Settings);

if (SingleInstanceAppMutex.TakeExclusivity())
{
Expand Down Expand Up @@ -75,13 +81,13 @@ private void ContinueStartup()

var deviceManager = WindowsAudioFactory.Create(AudioDeviceKind.Playback);
deviceManager.Loaded += (_, __) => CompleteStartup();
CollectionViewModel = new DeviceCollectionViewModel(deviceManager, _settings);
CollectionViewModel = new DeviceCollectionViewModel(deviceManager, Settings);

_trayIcon = new ShellNotifyIcon(new TaskbarIconSource(CollectionViewModel, _settings));
_trayIcon = new ShellNotifyIcon(new TaskbarIconSource(CollectionViewModel, Settings));
Exit += (_, __) => _trayIcon.IsVisible = false;
CollectionViewModel.TrayPropertyChanged += () => _trayIcon.SetTooltip(CollectionViewModel.GetTrayToolTip());

_flyoutViewModel = new FlyoutViewModel(CollectionViewModel, () => _trayIcon.SetFocus(), _settings);
_flyoutViewModel = new FlyoutViewModel(CollectionViewModel, () => _trayIcon.SetFocus(), Settings);
FlyoutWindow = new FlyoutWindow(_flyoutViewModel);
// Initialize the FlyoutWindow last because its Show/Hide cycle will pump messages, causing UI frames
// to be executed, breaking the assumption that startup is complete.
Expand All @@ -98,35 +104,47 @@ private void CompleteStartup()
_mixerWindow = new WindowHolder(CreateMixerExperience);
_settingsWindow = new WindowHolder(CreateSettingsExperience);

_settings.FlyoutHotkeyTyped += () => _flyoutViewModel.OpenFlyout(InputType.Keyboard);
_settings.MixerHotkeyTyped += () => _mixerWindow.OpenOrClose();
_settings.SettingsHotkeyTyped += () => _settingsWindow.OpenOrBringToFront();
_settings.AbsoluteVolumeUpHotkeyTyped += AbsoluteVolumeIncrement;
_settings.AbsoluteVolumeDownHotkeyTyped += AbsoluteVolumeDecrement;
_settings.RegisterHotkeys();
Settings.FlyoutHotkeyTyped += () => _flyoutViewModel.OpenFlyout(InputType.Keyboard);
Settings.MixerHotkeyTyped += () => _mixerWindow.OpenOrClose();
Settings.SettingsHotkeyTyped += () => _settingsWindow.OpenOrBringToFront();
Settings.AbsoluteVolumeUpHotkeyTyped += AbsoluteVolumeIncrement;
Settings.AbsoluteVolumeDownHotkeyTyped += AbsoluteVolumeDecrement;
Settings.RegisterHotkeys();

_trayIcon.PrimaryInvoke += (_, type) => _flyoutViewModel.OpenFlyout(type);
_trayIcon.SecondaryInvoke += (_, args) => _trayIcon.ShowContextMenu(GetTrayContextMenuItems(), args.Point);
_trayIcon.TertiaryInvoke += (_, __) => CollectionViewModel.Default?.ToggleMute.Execute(null);
_trayIcon.Scrolled += (_, wheelDelta) => CollectionViewModel.Default?.IncrementVolume(Math.Sign(wheelDelta) * 2);
_trayIcon.Scrolled += trayIconScrolled;
_trayIcon.SetTooltip(CollectionViewModel.GetTrayToolTip());
_trayIcon.IsVisible = true;

DisplayFirstRunExperience();
}

private void trayIconScrolled(object _, int wheelDelta)
{
if (Settings.UseScrollWheelInTray && (!Settings.UseGlobalMouseWheelHook || _flyoutViewModel.State == FlyoutViewState.Hidden))
{
var hWndTray = WindowsTaskbar.GetTrayToolbarWindowHwnd();
var hWndTooltip = User32.SendMessage(hWndTray, User32.TB_GETTOOLTIPS, IntPtr.Zero, IntPtr.Zero);
User32.SendMessage(hWndTooltip, User32.TTM_POPUP, IntPtr.Zero, IntPtr.Zero);

CollectionViewModel.Default?.IncrementVolume(Math.Sign(wheelDelta) * 2);
}
}

private void DisplayFirstRunExperience()
{
if (!_settings.HasShownFirstRun
if (!Settings.HasShownFirstRun
#if DEBUG
|| Keyboard.IsKeyDown(Key.LeftCtrl)
#endif
)
{
Trace.WriteLine($"App DisplayFirstRunExperience Showing welcome dialog");
_settings.HasShownFirstRun = true;
Settings.HasShownFirstRun = true;

var dialog = new DialogWindow { DataContext = new WelcomeViewModel(_settings) };
var dialog = new DialogWindow { DataContext = new WelcomeViewModel(Settings) };
dialog.Show();
dialog.RaiseWindow();
}
Expand Down Expand Up @@ -192,6 +210,10 @@ private IEnumerable<ContextMenuItem> GetTrayContextMenuItems()
new ContextMenuItem { DisplayName = EarTrumpet.Properties.Resources.RecordingDevicesText, Command = new RelayCommand(() => LegacyControlPanelHelper.Open("recording")) },
new ContextMenuItem { DisplayName = EarTrumpet.Properties.Resources.SoundsControlPanelText, Command = new RelayCommand(() => LegacyControlPanelHelper.Open("sounds")) },
new ContextMenuItem { DisplayName = EarTrumpet.Properties.Resources.OpenSoundSettingsText, Command = new RelayCommand(() => SettingsPageHelper.Open("sound")) },
new ContextMenuItem {
DisplayName = Environment.OSVersion.IsAtLeast(OSVersions.Windows11) ?
EarTrumpet.Properties.Resources.OpenAppsVolume_Windows11_Text
: EarTrumpet.Properties.Resources.OpenAppsVolume_Windows10_Text, Command = new RelayCommand(() => SettingsPageHelper.Open("apps-volume")) },
},
},
new ContextMenuSeparator(),
Expand Down Expand Up @@ -222,9 +244,11 @@ private Window CreateSettingsExperience()
null,
new SettingsPageViewModel[]
{
new EarTrumpetShortcutsPageViewModel(_settings),
new EarTrumpetLegacySettingsPageViewModel(_settings),
new EarTrumpetAboutPageViewModel(() => _errorReporter.DisplayDiagnosticData(), _settings)
new EarTrumpetShortcutsPageViewModel(Settings),
new EarTrumpetMouseSettingsPageViewModel(Settings),
new EarTrumpetCommunitySettingsPageViewModel(Settings),
new EarTrumpetLegacySettingsPageViewModel(Settings),
new EarTrumpetAboutPageViewModel(() => _errorReporter.DisplayDiagnosticData(), Settings)
});

var allCategories = new List<SettingsCategoryViewModel>();
Expand Down
31 changes: 31 additions & 0 deletions EarTrumpet/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using static EarTrumpet.Interop.User32;

namespace EarTrumpet
{
Expand Down Expand Up @@ -132,6 +133,18 @@ public bool IsExpanded
set => _settings.Set("IsExpanded", value);
}

public bool UseScrollWheelInTray
{
get => _settings.Get("UseScrollWheelInTray", true);
set => _settings.Set("UseScrollWheelInTray", value);
}

public bool UseGlobalMouseWheelHook
{
get => _settings.Get("UseGlobalMouseWheelHook", false);
set => _settings.Set("UseGlobalMouseWheelHook", value);
}

public bool HasShownFirstRun
{
get => _settings.HasKey("hasShownFirstRun");
Expand All @@ -147,6 +160,24 @@ public bool IsTelemetryEnabled
set => _settings.Set("IsTelemetryEnabled", value);
}

public bool UseLogarithmicVolume
{
get => _settings.Get("UseLogarithmicVolume", false);
set => _settings.Set("UseLogarithmicVolume", value);
}

public WINDOWPLACEMENT? FullMixerWindowPlacement
{
get => _settings.Get("FullMixerWindowPlacement", default(WINDOWPLACEMENT?));
set => _settings.Set("FullMixerWindowPlacement", value);
}

public WINDOWPLACEMENT? SettingsWindowPlacement
{
get => _settings.Get("SettingsWindowPlacement", default(WINDOWPLACEMENT?));
set => _settings.Set("SettingsWindowPlacement", value);
}

private bool IsTelemetryEnabledByDefault()
{
// Discussion on what to include:
Expand Down
12 changes: 11 additions & 1 deletion EarTrumpet/DataModel/Audio/Mocks/AudioDevice.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EarTrumpet.DataModel.WindowsAudio;
using EarTrumpet.DataModel.WindowsAudio.Internal;
using EarTrumpet.Extensions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -41,9 +42,18 @@ public bool IsMuted
private float _volume = 1;
public float Volume
{
get => _volume;
get
{
return App.Settings.UseLogarithmicVolume ? _volume.ToDisplayVolume() : _volume;
}

set
{
if (App.Settings.UseLogarithmicVolume)
{
value = value.ToLogVolume();
}

if (_volume != value)
{
_volume = value;
Expand Down
12 changes: 11 additions & 1 deletion EarTrumpet/DataModel/Audio/Mocks/AudioDeviceSession.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EarTrumpet.DataModel.WindowsAudio;
using EarTrumpet.DataModel.WindowsAudio.Internal;
using EarTrumpet.Extensions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -50,9 +51,18 @@ public bool IsMuted
private float _volume = 1;
public float Volume
{
get => _volume;
get
{
return App.Settings.UseLogarithmicVolume ? _volume.ToDisplayVolume() : _volume;
}

set
{
if (App.Settings.UseLogarithmicVolume)
{
value = value.ToLogVolume();
}

if (_volume != value)
{
_volume = value;
Expand Down
13 changes: 11 additions & 2 deletions EarTrumpet/DataModel/WindowsAudio/Internal/AudioDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,19 @@ void IAudioEndpointVolumeCallback.OnNotify(IntPtr pNotify)

public float Volume
{
get => _volume;
get
{
return App.Settings.UseLogarithmicVolume ? _volume.ToDisplayVolume() : _volume;
}
set
{
value = value.Bound(0, 1f);

if (App.Settings.UseLogarithmicVolume)
{
value = value.ToLogVolume();
}

if (_volume != value)
{
try
Expand All @@ -112,7 +120,8 @@ public float Volume
{
// Expected in some cases.
}
IsMuted = _volume.ToVolumeInt() == 0;

IsMuted = App.Settings.UseLogarithmicVolume ? _volume <= (1 / 100f).ToLogVolume() : _volume.ToVolumeInt() == 0;
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions EarTrumpet/DataModel/WindowsAudio/Internal/AudioDeviceSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@ public IAudioDevice Parent

public float Volume
{
get => _volume;
get
{
return App.Settings.UseLogarithmicVolume ? _volume.ToDisplayVolume() : _volume;
}
set
{
value = value.Bound(0, 1f);

if (value != _volume)
if (App.Settings.UseLogarithmicVolume)
{
value = value.ToLogVolume();
}

if (_volume != value)
{
try
{
Expand All @@ -47,7 +55,8 @@ public float Volume
{
// Expected in some cases.
}
IsMuted = _volume.ToVolumeInt() == 0;

IsMuted = App.Settings.UseLogarithmicVolume ? _volume <= (1 / 100f).ToLogVolume() : _volume.ToVolumeInt() == 0;
}
}
}
Expand Down
Loading

0 comments on commit 3b44acb

Please sign in to comment.