Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpui: fixed metadata update issue in macos media controls

+25 -12
+19 -8
gpui/src/now_playing.rs
··· 23 23 pub struct NowPlayingManager { 24 24 controls: MediaControls, 25 25 cmd_rx: mpsc::Receiver<MediaCommand>, 26 - /// Last track id pushed to the OS so we only re-send metadata on change. 26 + /// Last track id pushed to the OS — guards against redundant metadata sends. 27 27 last_track_id: String, 28 + /// Last cover URL — re-send metadata when art arrives after the track id. 29 + last_cover_url: Option<String>, 28 30 } 29 31 30 32 impl NowPlayingManager { ··· 59 61 }) 60 62 .ok()?; 61 63 62 - Some(NowPlayingManager { controls, cmd_rx, last_track_id: String::new() }) 64 + Some(NowPlayingManager { 65 + controls, 66 + cmd_rx, 67 + last_track_id: String::new(), 68 + last_cover_url: None, 69 + }) 63 70 } 64 71 65 72 /// Drain all pending OS media-key commands (non-blocking). ··· 82 89 }; 83 90 let _ = self.controls.set_playback(playback); 84 91 85 - // Metadata only on track change 86 92 let track_id = track.map(|t| t.id.as_str()).unwrap_or(""); 87 - if track_id == self.last_track_id { 88 - return; 89 - } 90 - self.last_track_id = track_id.to_string(); 91 - 92 93 // album_art is a bare filename served by rockboxd's cover HTTP server. 93 94 let cover_url = track 94 95 .and_then(|t| t.album_art.as_deref()) 95 96 .filter(|s| !s.is_empty()) 96 97 .map(|name| format!("http://localhost:6062/covers/{}", name)); 98 + 99 + // Re-send metadata when either the track or the cover art changes. 100 + // Cover art can arrive in a later poll tick after the track id was set. 101 + let track_changed = track_id != self.last_track_id; 102 + let cover_changed = cover_url != self.last_cover_url; 103 + if !track_changed && !cover_changed { 104 + return; 105 + } 106 + self.last_track_id = track_id.to_string(); 107 + self.last_cover_url = cover_url.clone(); 97 108 98 109 let meta = track 99 110 .map(|t| MediaMetadata {
+6 -4
gpui/src/ui/components/pages/library.rs
··· 1992 1992 let max_x = viewport.width - menu_w - margin; 1993 1993 let menu_x = if menu.pos.x > max_x { max_x } else { menu.pos.x }; 1994 1994 let menu_x = if menu_x < margin { margin } else { menu_x }; 1995 - let max_y = viewport.height - menu_h - margin; 1996 - let menu_y = if menu.pos.y > max_y { max_y } else { menu.pos.y }; 1995 + // Flip above cursor when the menu would overflow the bottom edge. 1996 + let overflows_bottom = (menu.pos.y + menu_h + margin) > viewport.height; 1997 + let menu_y = if overflows_bottom { menu.pos.y - menu_h } else { menu.pos.y }; 1997 1998 let menu_y = if menu_y < margin { margin } else { menu_y }; 1998 1999 this.child( 1999 2000 div() ··· 2176 2177 let max_x = viewport.width - menu_w - margin; 2177 2178 let menu_x = if menu.pos.x > max_x { max_x } else { menu.pos.x }; 2178 2179 let menu_x = if menu_x < margin { margin } else { menu_x }; 2179 - let max_y = viewport.height - menu_h - margin; 2180 - let menu_y = if menu.pos.y > max_y { max_y } else { menu.pos.y }; 2180 + // Flip above cursor when the menu would overflow the bottom edge. 2181 + let overflows_bottom = (menu.pos.y + menu_h + margin) > viewport.height; 2182 + let menu_y = if overflows_bottom { menu.pos.y - menu_h } else { menu.pos.y }; 2181 2183 let menu_y = if menu_y < margin { margin } else { menu_y }; 2182 2184 this.child( 2183 2185 div()