From a9f15d67a23a43f5fe389dc50cec1b7c0e1a9c12 Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Wed, 29 Jul 2026 11:59:32 +0200 Subject: [PATCH] fix: handle wheel events before cursor bounds check in MouseArea Move the on_mouse_wheel handler before the cursor.is_over(bounds) guard. The panel's nested compositor only routes axis events to the applet surface when the pointer is over it, making the bounds check redundant for scroll events. This fixes scroll-to-adjust-volume not working on the audio applet after a fresh login, when the cursor coordinates sent by the panel may not match the applet's surface-local coordinate space. --- cosmic-applet-audio/src/mouse_area.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cosmic-applet-audio/src/mouse_area.rs b/cosmic-applet-audio/src/mouse_area.rs index 38306e45..94efb4f7 100644 --- a/cosmic-applet-audio/src/mouse_area.rs +++ b/cosmic-applet-audio/src/mouse_area.rs @@ -307,6 +307,19 @@ fn update( shell: &mut Shell<'_, Message>, state: &mut State, ) { + // Handle wheel events before the bounds check. The panel's nested + // compositor routes axis events to this surface only when the pointer + // is over the applet, but the cursor coordinates it sends may be in + // panel-local space rather than surface-local space. This makes + // cursor.is_over() unreliable for scroll events. + if let Event::Mouse(mouse::Event::WheelScrolled { delta }) = event { + if let Some(message) = widget.on_mouse_wheel.as_ref() { + shell.publish((message)(*delta)); + shell.capture_event(); + return; + } + } + if !cursor.is_over(layout.bounds()) { if !state.is_out_of_bounds { if widget @@ -416,12 +429,4 @@ fn update( } } } - - if let Some(message) = widget.on_mouse_wheel.as_ref() { - if let Event::Mouse(mouse::Event::WheelScrolled { delta }) = event { - shell.publish((message)(*delta)); - shell.capture_event(); - return; - } - } }