Skip to content

QoL: Adjust output device volume by scrolling mouse wheel over the tray icon - #102

Merged
G-Stas merged 16 commits into
G-Stas:mainfrom
ElektroStudios:feature/tray-wheel-volume
Oct 29, 2026
Merged

G-Stas merged 16 commits into
G-Stas:mainfrom
ElektroStudios:feature/tray-wheel-volume

Conversation

@ElektroStudios

@ElektroStudios ElektroStudios commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR introduces a quality-of-life feature: the ability to adjust the volume of the current default output device by simply scrolling the mouse wheel while hovering over the Volumey system tray icon. There is no need to click or open the mixer window anymore.

Note on OSD behavior: The On-Screen Display (OSD) will always trigger when adjusting the volume this way (provided the mixer window is closed), regardless of the user's general OSD visibility settings. I considered this the most logical default behavior to provide immediate visual feedback during a blind scroll action. See commentary

Note on authoring: As mentioned in my previous PR, I am not a C# or WPF developer by trade. I just wanted this specific functionality to exist, so I used an AI assistant to meticulously guide me through the architecture and the exact codebase modifications required. The logic has been tested locally on WIndows 10.

Visual Demonstration

🎛️ Tray Icon Mouse Wheel Scrolling
feature-demo

@ElektroStudios ElektroStudios changed the title Adjust volume by scrolling mouse wheel over the tray iconallow volume control via mouse wheel on system tray icon Adjust volume by scrolling mouse wheel over the tray icon Oct 26, 2026
Comment thread Volumey/View/MainView.xaml.cs Outdated
//the open mixer window shows the new volume itself; otherwise the tray
//tooltip that is already shown isn't repainted by Explorer, so the OSD shows it.
if(!IsVisible)
notifications.ShowNotification(master);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be replaced to: notifications.NotifyAudioStateChange(master); to respect the OSD's user preferences.

@ElektroStudios ElektroStudios changed the title Adjust volume by scrolling mouse wheel over the tray icon Adjust master volume by scrolling mouse wheel over the tray icon Oct 26, 2026
@ElektroStudios ElektroStudios changed the title Adjust master volume by scrolling mouse wheel over the tray icon QoL: Adjust master volume by scrolling mouse wheel over the tray icon Oct 26, 2026
@ElektroStudios ElektroStudios changed the title QoL: Adjust master volume by scrolling mouse wheel over the tray icon QoL: Adjust output device volume by scrolling mouse wheel over the tray icon Oct 26, 2026
@ElektroStudios

Copy link
Copy Markdown
Contributor Author

Awesome work on the trimming optimizations in #121, those size reductions are massive!

Now that the scrollbar and white-flashing bugs are fully ironed out, I just wanted to gently bump this PR. I know you are deep into the deployment/trimming pipeline right now, so absolutely no rush on a line-by-line code review. I'd just love to get your thoughts on the concept of this QoL improvement.

I built this specific workflow because it is a massive QoL game-changer for my daily usage. It drastically cuts down the time spent adjusting audio and simplifies the whole interaction into a single, frictionless motion. I'd love to know if you are open to merging this concept as designed, so just let me know if it fits your overarching vision for Volumey whenever you have a moment!

@G-Stas

G-Stas commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thanks for this! Actually I've already designed most of how I want it to work but haven't implemented it yet. The main point: I don't want to do it with the global hook. Could you switch to raw input only while the cursor is on the icon?

  1. Handle TaskbarIcon.TrayMouseMove. Explorer sends it while the cursor is over the icon. On the first move, read the icon's rect with Shell_NotifyIconGetRect (your helper, returning false instead of throwing).
  2. Register for raw mouse input: RegisterRawInputDevices with RAWINPUTDEVICE { usUsagePage = 0x01, usUsage = 0x02, dwFlags = RIDEV_INPUTSINK, hwndTarget = MainView's HWND }. RIDEV_INPUTSINK delivers input while the window is in the background.
  3. In WndProc, on WM_INPUT: GetRawInputData(lParam, RID_INPUT, ...) into RAWINPUT, check header.dwType == RIM_TYPEMOUSE and usButtonFlags & RI_MOUSE_WHEEL, read the delta as (short)usButtonData. Then check GetCursorPos against the rect. If it's outside, unregister.
  4. Unregister with RIDEV_REMOVE (and hwndTarget = null) when the cursor leaves the rect, and on exit.
  5. Add up the deltas and change the volume once per WHEEL_DELTA (120), keeping the remainder, so touchpads with small deltas don't jump.

GetCursorPos and Shell_NotifyIconGetRect both give physical screen coordinates in our PerMonitorV2 process, so the check works on every monitor layout. It also doesn't touch InputHookHost at all.

Also:

  • Use the volume step and mute rules from the device hotkeys (MasterSessionModel.OnHotkeyPressed), ideally moved into a shared method, not ±1.
  • Ignore the wheel while a modifier is held, so it doesn't also fire wheel hotkeys like Ctrl+Wheel up.

@G-Stas G-Stas added the enhancement New feature or request label Oct 28, 2026
@G-Stas

G-Stas commented Oct 28, 2026

Copy link
Copy Markdown
Owner

If you'd like, I can do the rework myself on top of your branch

@ElektroStudios

ElektroStudios commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Could you switch to raw input only while the cursor is on the icon?

Thanks for the detailed design. I reworked it following your steps as closely as I could (with the AI doing the typing and me reviewing). Here is what changed:

  • Global hook removed: MainView no longer uses InputHookHost or SharpHook, and InputHookHost itself is untouched.
  • TaskbarIcon.TrayMouseMove: on the first move, MainView reads the icon's rect with the Shell_NotifyIconGetRect helper, now NativeMethods.TryGetTrayIconRect, which returns false instead of throwing.
  • Raw input: the new TrayWheelInput helper registers raw mouse input (usUsagePage = 0x01, usUsage = 0x02, RIDEV_INPUTSINK, MainView's HWND) and unregisters it with RIDEV_REMOVE and a null target when the cursor leaves the rect, and on exit (MainView.OnClosed).
  • WM_INPUT in WndProc: GetRawInputData fills a RAWINPUT, it checks RIM_TYPEMOUSE and RI_MOUSE_WHEEL, and the delta is (short)usButtonData. One small difference from your steps: the cursor is checked against the rect with GetCursorPos first, on every WM_INPUT and not only on wheel events, so the registration is removed as soon as the cursor leaves the icon.
  • Deltas: they are added up and the volume changes once per WHEEL_DELTA (120), keeping the remainder.
  • Modifiers: the wheel is ignored while Shift, Ctrl, Alt or a Windows key is held. The key codes come from CsWin32's VIRTUAL_KEY.
  • Shared step and mute rules: the volume step and mute rules of MasterSessionModel.OnHotkeyPressed moved into ChangeVolumeByStep(bool up, bool notify), used by both the hotkeys and the wheel. The wheel passes notify: false and shows the OSD itself when the mixer is closed, so it doesn't show twice.
  • Device while the mixer is open: the wheel changes the device selected in the mixer's drop-down (even before it's set as default), so it matches the volume slider you see; with the mixer closed it changes the default device. See the attached GIF.
  • Test: added ChangeVolumeByStepMustUseTheHotkeysStep, ChangeVolumeByStepDownMustUseTheHotkeysStep, ChangeVolumeByStepDownMustMuteInsteadOfReachingZero_IfEnabled and ChangeVolumeByStepMustNotNotifyTheMediator_IfNotifyIsFalse.

I could only test it on Windows 10. Feel free to change anything on top of my branch.


GDFGDFG

@G-Stas G-Stas left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, works great on Win 10 and 11! I pushed a few tweaks on top:

  • OSD now respects the OSD switch (as you suggested)
  • touchpad fix: reversing direction doesn't eat the first notch
  • failed raw input registration is logged once and retried after 5s
  • UI tests for it (Windows 10 only, Win 11 ignores programmatic mouse moves over tray icons)

@G-Stas
G-Stas merged commit 423f2c6 into G-Stas:main Oct 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants