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; - } - } }