@@ -1588,6 +1588,43 @@ impl cosmic::Application for AppModel {
15881588 )
15891589 } ;
15901590
1591+ // Volume-key shutter on phones: the compositor swallows the keys
1592+ // for system audio so they never reach iced as keyboard events.
1593+ // The `volume_keys` backend reads `/dev/input/event*` directly,
1594+ // grabs each device exclusively while the window is focused
1595+ // (so the compositor doesn't *also* change the volume) and
1596+ // forwards presses as `Message::Capture` — same as the spacebar.
1597+ let volume_keys_sub = subscription_with_id (
1598+ "volume_keys" ,
1599+ cosmic:: iced:: stream:: channel ( 8 , async move |mut output| {
1600+ let mut rx = crate :: backends:: volume_keys:: start ( ) ;
1601+ while let Some ( _key) = rx. recv ( ) . await {
1602+ if output. send ( Message :: Capture ) . await . is_err ( ) {
1603+ break ;
1604+ }
1605+ }
1606+ } ) ,
1607+ ) ;
1608+
1609+ // Translate Wayland keyboard-focus transitions for the camera
1610+ // window into `WindowFocusChanged` messages; the update handler
1611+ // forwards them into the volume_keys backend so we only grab the
1612+ // hardware shutter buttons while the camera is in focus.
1613+ let window_focus_sub = subscription:: filter_map ( "window_focus" , |event| {
1614+ let subscription:: Event :: Interaction { event, .. } = event else {
1615+ return None ;
1616+ } ;
1617+ match event {
1618+ cosmic:: iced:: Event :: Window ( cosmic:: iced:: window:: Event :: Focused ) => {
1619+ Some ( Message :: WindowFocusChanged ( true ) )
1620+ }
1621+ cosmic:: iced:: Event :: Window ( cosmic:: iced:: window:: Event :: Unfocused ) => {
1622+ Some ( Message :: WindowFocusChanged ( false ) )
1623+ }
1624+ _ => None ,
1625+ }
1626+ } ) ;
1627+
15911628 Subscription :: batch ( [
15921629 config_sub,
15931630 camera_sub,
@@ -1602,6 +1639,8 @@ impl cosmic::Application for AppModel {
16021639 audio_level_sub,
16031640 portal_theme_sub,
16041641 keybind_sub,
1642+ volume_keys_sub,
1643+ window_focus_sub,
16051644 ] )
16061645 }
16071646
0 commit comments