A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.
feat: add volume expansion and progress tracking to the music panel
CristianOlivera1dbbc742330d7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3e4fd95..364fea7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,30 @@ copia la sección de la versión que se publica a la release de GitHub.## [Unreleased]+### English++- The music/video popup now shows playback progress and elapsed/total time when+ provided by the player. The speaker button on its right expands the volume+ controls on demand. Timeline events and the local progress timer stop when+ the popup is hidden; progress updates retain the existing visual tree.+- Added an opt-in setting under Settings > Windows to show other workspaces. With+ compatible shell-cloaking window managers (such as komorebi's Cloak mode),+ clicking a pinned app can reuse its existing window instead of launching+ another instance. Also includes other Windows virtual desktops; app-cloaked+ and inherited-cloak windows remain excluded. No additional polling.++### Español++- El popup de música/vídeo muestra el progreso y los tiempos transcurrido/total+ cuando el reproductor los proporciona. El icono de audio a la derecha despliega+ el volumen al pulsarlo. Al ocultar el popup se detienen su suscripción al+ progreso y su temporizador local, sin reconstruir la interfaz en cada avance.+- Añadida una opción desactivada por defecto en Ventanas para mostrar ventanas+ de otros espacios de trabajo. Con gestores compatibles (como el modo Cloak+ de komorebi), permite reutilizar la ventana de una app fijada en vez de abrir+ otra instancia. También incluye otros escritorios virtuales de Windows;+ siguen excluidas las ventanas ocultas por la app o por herencia. Sin sondeo nuevo.+## [0.1.21]### Englishdiff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rsindex 0e4681b..98eacdb 100644--- a/apps/dock/src/app.rs+++ b/apps/dock/src/app.rs@@ -4053,6 +4053,7 @@ impl App {}let hiding_changed = config.auto_hide != self.config.auto_hide|| config.smart_hide != self.config.smart_hide;+ let workspaces_changed = config.show_other_workspaces != self.config.show_other_workspaces;let moved = config.dock_position != self.config.dock_position;apply_explorer_pin(&mut self.roster, config.pin_explorer);self.slide.omega = config.dock_auto_hide_speed.omega();@@ -4072,6 +4073,9 @@ impl App {}// Updates may have been turned on or off.self.schedule_update();+ if workspaces_changed {+ self.sync()?;+ }self.sync_thumbnails();self.apply_menu_bar_setting();self.update_menu_bar_app()?;@@ -4848,7 +4852,9 @@ impl App {}fn read_windows(&mut self) -> bool {- self.windows = self.tracker.list();+ self.windows = self+ .tracker+ .list_with_workspaces(self.config.show_other_workspaces);self.preview_order.update(&self.windows);let pruned = self.attention@@ -5014,6 +5020,13 @@ pub fn menu_bar_volume_flush() {});}+pub fn menu_bar_progress_tick() {+ with_app("progreso multimedia", |app| match &mut app.menubar {+ Some(bar) => bar.progress_tick(&app.gfx),+ None => Ok(()),+ });+}+pub fn menu_bar_media_changed() {with_app("reproducción", |app| match &mut app.menubar {Some(bar) => bar.media_changed(&app.gfx),diff --git a/apps/dock/src/guard.rs b/apps/dock/src/guard.rsindex fb001e8..11ba4fe 100644--- a/apps/dock/src/guard.rs+++ b/apps/dock/src/guard.rs@@ -296,7 +296,8 @@ fn restore_desktop() {taskbar::give_back_on_exit();// The dock turns off window transitions while it runs (genie effect); if// it died without restoring them, do it here.- for window in WindowTracker::default().list() {+ // The opt-in workspace mode can also have calmed windows on other desktops.+ for window in WindowTracker::default().list_with_workspaces(true) {set_window_transitions(window.hwnd, true);}}diff --git a/apps/dock/src/media.rs b/apps/dock/src/media.rsindex a031a6c..ecd693b 100644--- a/apps/dock/src/media.rs+++ b/apps/dock/src/media.rs@@ -5,11 +5,11 @@ use muelle_shell::{icons::IconImage, imagery};use std::{sync::{Arc, Mutex, OnceLock,- atomic::{AtomicIsize, AtomicU8, Ordering},+ atomic::{AtomicBool, AtomicIsize, AtomicU8, Ordering},mpsc::{self, Receiver, SyncSender},},thread,- time::Duration,+ time::{Duration, Instant, SystemTime, UNIX_EPOCH},};use windows::{Foundation::TypedEventHandler,@@ -31,8 +31,61 @@ use windows_future::IAsyncOperation;const SESSION: u8 = 1;const TRACK: u8 = 2;const PLAYBACK: u8 = 4;+const TIMELINE: u8 = 8;const TIMEOUT: Duration = Duration::from_secs(3);+/// A local monotonic anchor, advanced without querying the player on each tick.+#[derive(Clone, Copy, Debug, PartialEq)]+pub struct Timeline {+ position: Duration,+ pub duration: Duration,+ recorded: Instant,+ rate: f64,+}++impl Timeline {+ fn new(start: i64, end: i64, position: i64, age: Duration, rate: f64) -> Option<Self> {+ let length = end.checked_sub(start).filter(|length| *length > 0)?;+ let duration = Duration::from_secs_f64(length as f64 / 10_000_000.0);+ let relative = position.clamp(start, end).checked_sub(start)?;+ let rate = if rate.is_finite() { rate } else { 1.0 };+ let seconds = (relative as f64 / 10_000_000.0 + age.as_secs_f64() * rate)+ .clamp(0.0, duration.as_secs_f64());+ Some(Self {+ position: Duration::from_secs_f64(seconds),+ duration,+ recorded: Instant::now(),+ rate,+ })+ }++ pub fn position_at(self, now: Instant) -> Duration {+ Duration::from_secs_f64(+ (self.position.as_secs_f64()+ + now.saturating_duration_since(self.recorded).as_secs_f64() * self.rate)+ .clamp(0.0, self.duration.as_secs_f64()),+ )+ }++ pub fn advancing(self, now: Instant) -> bool {+ let position = self.position_at(now);+ (self.rate > 0.0 && position < self.duration) || (self.rate < 0.0 && !position.is_zero())+ }+}++fn timeline_age(updated: i64, now: SystemTime) -> Duration {+ const UNIX_OFFSET: u128 = 116_444_736_000_000_000;+ if updated <= 0 {+ return Duration::ZERO;+ }+ let ticks = now+ .duration_since(UNIX_EPOCH)+ .map(|elapsed| elapsed.as_nanos() / 100 + UNIX_OFFSET)+ .unwrap_or(0)+ .saturating_sub(updated as u128);+ Duration::from_secs_f64(ticks as f64 / 10_000_000.0)+}+#[derive(Clone, Copy)]pub enum Control {Previous,@@ -50,6 +103,24 @@ pub struct Track {pub toggle: bool,pub next: bool,pub artwork: Option<Arc<IconImage>>,+ pub timeline: Option<Timeline>,+}++impl Track {+ pub fn same_content(&self, other: &Self) -> bool {+ self.generation == other.generation+ && self.title == other.title+ && self.artist == other.artist+ && self.playing == other.playing+ && self.previous == other.previous+ && self.toggle == other.toggle+ && self.next == other.next+ && match (&self.artwork, &other.artwork) {+ (Some(a), Some(b)) => Arc::ptr_eq(a, b),+ (None, None) => true,+ _ => false,+ }+ }}#[cfg(test)]@@ -62,6 +133,7 @@ impl Track {previous: true,toggle: true,next: true,+ timeline: Timeline::new(0, 2_400_000_000, 420_000_000, Duration::ZERO, 1.0),..Default::default()}}@@ -125,12 +197,30 @@ pub struct Watch {state: Arc<Mutex<Option<Track>>>,events: Events,commands: SyncSender<(u64, Control)>,+ progress: Arc<AtomicBool>,}impl Watch {+ #[cfg(test)]+ pub fn test_snapshot(track: Track) -> Self {+ let (wake, _inbox) = mpsc::sync_channel(1);+ let (commands, _requests) = mpsc::sync_channel(4);+ Self {+ window: Arc::new(AtomicIsize::new(0)),+ state: Arc::new(Mutex::new(Some(track))),+ events: Events {+ wake,+ dirty: Arc::new(AtomicU8::new(0)),+ },+ commands,+ progress: Arc::new(AtomicBool::new(false)),+ }+ }+pub fn start(hwnd: HWND, message: u32) -> Option<Self> {let window = Arc::new(AtomicIsize::new(hwnd.0 as isize));let state = Arc::new(Mutex::new(None));+ let progress = Arc::new(AtomicBool::new(false));let (wake, inbox) = mpsc::sync_channel(1);let (commands, requests) = mpsc::sync_channel(4);let events = Events {@@ -139,13 +229,16 @@ impl Watch {};{let (window, state, events) = (window.clone(), state.clone(), events.clone());+ let progress = progress.clone();thread::Builder::new().name("muelle-media".into()).spawn(move || {// SAFETY: This is a new thread. The apartment is kept alive// until all of the worker's WinRT objects have been dropped.if unsafe { RoInitialize(RO_INIT_MULTITHREADED) }.is_ok() {- run(&window, message, &state, &events, &inbox, &requests);+ run(+ &window, message, &state, &events, &inbox, &requests, &progress,+ );unsafe { RoUninitialize() };}})@@ -156,6 +249,7 @@ impl Watch {state,events,commands,+ progress,})}@@ -163,6 +257,14 @@ impl Watch {self.state.lock().ok().and_then(|state| state.clone())}+ /// Subscribe only while the music popup is visible. Closing it also stops+ /// timeline reads, independently of the existing metadata/playback watch.+ pub fn show_progress(&self, visible: bool) {+ if self.progress.swap(visible, Ordering::AcqRel) != visible {+ self.events.mark(TIMELINE);+ }+ }+pub fn send(&self, track: &Track, control: Control) {if self.commands.try_send((track.generation, control)).is_ok() {self.events.mark(0);@@ -210,6 +312,7 @@ struct Current {session: Session,track_event: Option<i64>,playback_event: Option<i64>,+ timeline_event: Option<i64>,title: String,artist: String,artwork: Option<Arc<IconImage>>,@@ -235,6 +338,7 @@ impl Current {session,track_event,playback_event,+ timeline_event: None,title: String::new(),artist: String::new(),artwork: None,@@ -265,7 +369,22 @@ impl Current {}}- fn snapshot(&self, generation: u64) -> Option<Track> {+ fn watch_timeline(&mut self, enabled: bool, events: &Events) {+ if enabled && self.timeline_event.is_none() {+ let events = events.clone();+ self.timeline_event = self+ .session+ .TimelinePropertiesChanged(&TypedEventHandler::new(move |_, _| {+ events.mark(TIMELINE);+ Ok(())+ }))+ .ok();+ } else if !enabled && let Some(token) = self.timeline_event.take() {+ let _ = self.session.RemoveTimelinePropertiesChanged(token);+ }+ }++ fn snapshot(&self, generation: u64, progress: bool) -> Option<Track> {let info = self.session.GetPlaybackInfo().ok()?;let status = info.PlaybackStatus().ok()?;if !matches!(status, Status::Playing | Status::Paused | Status::Changing) {@@ -273,12 +392,36 @@ impl Current {}let playing = matches!(status, Status::Playing | Status::Changing);let controls = info.Controls().ok()?;+ let timeline = progress+ .then(|| {+ let timeline = self.session.GetTimelineProperties().ok()?;+ let rate = if playing {+ info.PlaybackRate()+ .ok()+ .and_then(|rate| rate.Value().ok())+ .unwrap_or(1.0)+ } else {+ 0.0+ };+ Timeline::new(+ timeline.StartTime().ok()?.Duration,+ timeline.EndTime().ok()?.Duration,+ timeline.Position().ok()?.Duration,+ timeline+ .LastUpdatedTime()+ .map(|time| timeline_age(time.UniversalTime, SystemTime::now()))+ .unwrap_or_default(),+ rate,+ )+ })+ .flatten();Some(Track {generation,title: self.title.clone(),artist: self.artist.clone(),artwork: self.artwork.clone(),playing,+ timeline,previous: controls.IsPreviousEnabled().unwrap_or(false),next: controls.IsNextEnabled().unwrap_or(false),toggle: controls.IsPlayPauseToggleEnabled().unwrap_or(false)@@ -330,6 +473,9 @@ impl Drop for Current {if let Some(token) = self.playback_event {let _ = self.session.RemovePlaybackInfoChanged(token);}+ if let Some(token) = self.timeline_event {+ let _ = self.session.RemoveTimelinePropertiesChanged(token);+ }}}@@ -340,6 +486,7 @@ fn run(events: &Events,inbox: &Receiver<()>,requests: &Receiver<(u64, Control)>,+ progress: &AtomicBool,) {let Some(manager) = Manager::RequestAsync().ok().and_then(complete) else {return;@@ -371,6 +518,10 @@ fn run(dirty |= TRACK;}}+ let progress = progress.load(Ordering::Acquire);+ if let Some(active) = &mut current {+ active.watch_timeline(progress, events);+ }if dirty != 0 {if dirty & TRACK != 0&& let Some(current) = &mut current@@ -379,7 +530,7 @@ fn run(}let latest = current.as_ref()- .and_then(|current| current.snapshot(generation));+ .and_then(|current| current.snapshot(generation, progress));if let Ok(mut snapshot) = state.lock()&& *snapshot != latest{@@ -419,6 +570,106 @@ fn run(#[cfg(test)]mod native_probe {use super::*;+ use anyhow::Context;++ #[test]+ fn progress_uses_source_age_and_playback_rate_then_clamps_at_both_ends() -> anyhow::Result<()> {+ let mut timeline = Timeline::new(+ 300_000_000,+ 1_500_000_000,+ 450_000_000,+ Duration::from_secs(5),+ 2.0,+ )+ .context("finite playing timeline")?;+ let anchor = Instant::now();+ timeline.recorded = anchor;+ assert_eq!(timeline.position_at(anchor), Duration::from_secs(25));+ assert_eq!(+ timeline.position_at(anchor + Duration::from_secs(10)),+ Duration::from_secs(45)+ );+ assert!(timeline.advancing(anchor));+ assert_eq!(+ timeline.position_at(anchor + Duration::from_secs(100)),+ Duration::from_secs(120)+ );+ assert!(!timeline.advancing(anchor + Duration::from_secs(100)));+ timeline.rate = -2.0;+ assert_eq!(+ timeline.position_at(anchor + Duration::from_secs(100)),+ Duration::ZERO+ );+ assert!(!timeline.advancing(anchor + Duration::from_secs(100)));+ Ok(())+ }++ #[test]+ fn paused_live_and_invalid_timelines_do_not_invent_progress() -> anyhow::Result<()> {+ let paused = Timeline::new(0, 900_000_000, 150_000_000, Duration::from_secs(300), 0.0)+ .context("finite paused timeline")?;+ assert_eq!(+ paused.position_at(paused.recorded + Duration::from_secs(60)),+ Duration::from_secs(15)+ );+ assert!(!paused.advancing(paused.recorded));+ for (start, end) in [(0, 0), (100, 20), (i64::MIN, i64::MAX)] {+ assert!(Timeline::new(start, end, 0, Duration::ZERO, 1.0).is_none());+ }+ let normalized = Timeline::new(0, 900_000_000, -1, Duration::ZERO, f64::NAN)+ .context("normalized timeline")?;+ assert_eq!(normalized.position_at(normalized.recorded), Duration::ZERO);+ Ok(())+ }++ #[test]+ fn timeline_utc_age_ignores_missing_or_future_timestamps() {+ const UNIX_OFFSET: i64 = 116_444_736_000_000_000;+ let now = UNIX_EPOCH + Duration::from_secs(100);+ assert_eq!(+ timeline_age(UNIX_OFFSET + 970_000_000, now),+ Duration::from_secs(3)+ );+ assert_eq!(+ timeline_age(UNIX_OFFSET + 1_010_000_000, now),+ Duration::ZERO+ );+ assert_eq!(timeline_age(0, now), Duration::ZERO);+ }++ #[test]+ fn progress_visibility_wakes_the_worker_only_when_it_changes() {+ let (wake, inbox) = mpsc::sync_channel(1);+ let (commands, _requests) = mpsc::sync_channel(4);+ let watch = Watch {+ window: Arc::new(AtomicIsize::new(0)),+ state: Arc::new(Mutex::new(None)),+ events: Events {+ wake,+ dirty: Arc::new(AtomicU8::new(0)),+ },+ commands,+ progress: Arc::new(AtomicBool::new(false)),+ };+ watch.show_progress(false);+ assert!(inbox.try_recv().is_err());+ watch.show_progress(true);+ assert!(inbox.try_recv().is_ok());+ watch.show_progress(true);+ assert!(inbox.try_recv().is_err());+ watch.show_progress(false);+ assert!(inbox.try_recv().is_ok());+ }++ #[test]+ fn a_position_update_does_not_invalidate_track_content_but_transport_changes_do() {+ let old = Track::test_fixture();+ let mut new = old.clone();+ new.timeline = Timeline::new(0, 2_400_000_000, 840_000_000, Duration::ZERO, 1.0);+ assert!(old.same_content(&new));+ new.playing = false;+ assert!(!old.same_content(&new));+ }#[test]#[ignore = "Read-only artwork probe of the current Windows media session"]@@ -464,6 +715,21 @@ mod native_probe {};let mut current = Current::new(session, &events);current.update_track();+ current.watch_timeline(true, &events);+ assert!(current.timeline_event.is_some());+ if let Some(track) = current.snapshot(1, true) {+ if let Some(timeline) = track.timeline {+ eprintln!(+ "Native timeline: {} / {} seconds",+ timeline.position_at(Instant::now()).as_secs(),+ timeline.duration.as_secs()+ );+ } else {+ eprintln!("Current session does not publish a finite timeline");+ }+ }+ current.watch_timeline(false, &events);+ assert!(current.timeline_event.is_none());if let Some(image) = ¤t.artwork {assert!(image.width <= 128 && image.height <= 128);eprintln!("Windows media artwork: {}x{}", image.width, image.height);diff --git a/apps/dock/src/menubar.rs b/apps/dock/src/menubar.rsindex b0bcf8c..f74a24b 100644--- a/apps/dock/src/menubar.rs+++ b/apps/dock/src/menubar.rs@@ -93,6 +93,7 @@ const VOLUME_CAPTURE_LOST: u32 = WM_APP + 31;const AUDIO_CHANGED: u32 = WM_APP + 32;const AUDIO_TICK: u32 = WM_APP + 33;const VOLUME_TIMER: usize = 4;+const PROGRESS_TIMER: usize = 5;const ACCESSORIES_CHANGED: u32 = WM_APP + 30;const CLOCK_TIMER: usize = 1;@@ -231,6 +232,7 @@ struct Look {panel: Option<Island>,usage_refreshing: bool,track: Option<Track>,+ volume_expanded: bool,}#[derive(Clone, Copy, Debug, PartialEq, Eq)]@@ -252,7 +254,13 @@ fn accessory_readings(snapshot: &AccessorySnapshot) -> [Option<AccessoryReading>impl Look {fn panel_content_height(&self) -> f32 {match self.panel {- Some(Island::Music) => 164.0,+ Some(Island::Music) => {+ if self.volume_expanded {+ 218.0+ } else {+ 180.0+ }+ }Some(Island::Usage) => {74.0 + Provider::ALL.into_iter()@@ -301,6 +309,7 @@ enum IslandAction {Toggle(Island),Media(MediaControl),Volume(Span),+ ToggleVolume,Mute,Refresh,ScrollUsage(i8),@@ -346,6 +355,64 @@ struct VolumeControls {label_percent: u8,}+/// Only the progress fill and time labels change while the popup is open.+struct ProgressControls {+ fill: CompositionRoundedRectangleGeometry,+ elapsed: SpriteVisual,+ total: SpriteVisual,+ geometry: IslandGeometry,+ width: f32,+ elapsed_seconds: Option<u64>,+ total_seconds: Option<u64>,+}++impl ProgressControls {+ fn paint(&mut self, gfx: &Gfx, timeline: media::Timeline, now: Instant) -> Result<()> {+ let position = timeline.position_at(now);+ let px = |v| self.geometry.px(v);+ let filled = self.width * (position.as_secs_f64() / timeline.duration.as_secs_f64()) as f32;+ self.fill.SetSize(Vector2::new(filled, px(4.0)))?;+ self.fill+ .SetCornerRadius(Vector2::new(px(2.0).min(filled / 2.0), px(2.0)))?;+ for (visual, cached, seconds, right) in [+ (+ &self.elapsed,+ &mut self.elapsed_seconds,+ position.as_secs(),+ false,+ ),+ (+ &self.total,+ &mut self.total_seconds,+ timeline.duration.as_secs(),+ true,+ ),+ ] {+ if *cached == Some(seconds) {+ continue;+ }+ let label = gfx.text_brush_sized(+ &media_time(seconds),+ self.geometry.scale,+ 10.0,+ false,+ self.geometry.ink(),+ )?;+ visual.SetBrush(&label.brush.cast::<CompositionBrush>()?)?;+ visual.SetSize(Vector2::new(label.width, label.height))?;+ if right {+ visual.SetOffset(Vector3::new(+ px(26.0) + self.width - label.width,+ px(148.0),+ 0.0,+ ))?;+ }+ *cached = Some(seconds);+ }+ Ok(())+ }+}+impl VolumeControls {fn move_to(&mut self, percent: u8) -> Result<()> {if self.position_percent == Some(percent) {@@ -426,6 +493,9 @@ pub struct MenuBar {pending_volume: Option<u8>,volume_target: Option<u8>,volume_controls: Option<VolumeControls>,+ volume_expanded: bool,+ progress_controls: Option<ProgressControls>,+ progress_timer: bool,usage_scroll: f32,usage_viewport: Option<UsageViewport>,suppress_volume_release: bool,@@ -478,6 +548,7 @@ unsafe extern "system" fn bar_proc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) -}WM_TIMER if w.0 == POINTER_TIMER => app::menu_bar_check_pointer(),WM_TIMER if w.0 == VOLUME_TIMER => app::menu_bar_volume_flush(),+ WM_TIMER if w.0 == PROGRESS_TIMER => app::menu_bar_progress_tick(),WM_CAPTURECHANGED => {// Avoid reentering the app borrow inside Set/ReleaseCapture.unsafe {@@ -1090,6 +1161,9 @@ impl MenuBar {pending_volume: None,volume_target: None,volume_controls: None,+ volume_expanded: false,+ progress_controls: None,+ progress_timer: false,usage_scroll: 0.0,usage_viewport: None,suppress_volume_release: false,@@ -1457,6 +1531,7 @@ impl MenuBar {/// Positions the window and reserves (or frees) its strip of the screen.fn place(&mut self) -> Result<()> {+ self.sync_progress_watch();let bounds = self.bounds;let bar_height = bounds.bottom - bounds.top;if bar_height <= 0 {@@ -1689,6 +1764,14 @@ impl MenuBar {return Ok(());}IslandAction::Volume(_) => return Ok(()), // Handled on press/drag.+ IslandAction::ToggleVolume => {+ self.release_volume(None)?;+ self.volume_expanded = !self.volume_expanded;+ let Some(look) = self.look.clone() else {+ return self.refresh(gfx);+ };+ return self.apply_look(gfx, look);+ }IslandAction::Mute => {if let Some(audio) = &mut self.audio {audio.toggle_mute()?;@@ -1807,6 +1890,7 @@ impl MenuBar {panel: self.panel,usage_refreshing: self.usage.as_ref().is_some_and(UsageMonitor::is_refreshing),track,+ volume_expanded: self.volume_expanded,};self.apply_look(gfx, look)}@@ -1816,7 +1900,19 @@ impl MenuBar {let Some(mut look) = self.look.clone() else {return self.refresh(gfx);};- look.track = self.media.as_ref().and_then(media::Watch::snapshot);+ let track = self.media.as_ref().and_then(media::Watch::snapshot);+ let timeline_only = look+ .track+ .as_ref()+ .zip(track.as_ref())+ .is_some_and(|(old, new)| {+ old.same_content(new) && old.timeline.is_some() == new.timeline.is_some()+ });+ look.track = track;+ if timeline_only {+ self.look = Some(look);+ return self.progress_tick(gfx);+ }self.panel = available_panel(self.panel, look.track.is_some(), look.usage_enabled);look.panel = self.panel;self.apply_look(gfx, look)@@ -1827,6 +1923,10 @@ impl MenuBar {look.usage_enabled &= look.active_providers.any();self.panel = available_panel(look.panel, look.track.is_some(), look.usage_enabled);look.panel = self.panel;+ if look.panel != Some(Island::Music) || look.status.volume.is_none() {+ self.volume_expanded = false;+ }+ look.volume_expanded = self.volume_expanded;if look.panel != Some(Island::Usage) {self.usage_scroll = 0.0;}@@ -1853,6 +1953,7 @@ impl MenuBar {self.build(gfx, &look)?;}self.look = Some(look);+ self.sync_progress_watch();if let Some((provider, act)) = moment&& let Some(&(_, x)) = self.usage_anchors.iter().find(|(p, _)| *p == provider){@@ -2077,6 +2178,7 @@ impl MenuBar {self.island_hits.clear();self.volume_controls = None;+ self.progress_controls = None;self.usage_viewport = None;self.triggers_span = Span::default();self.panel_span = Span::default();@@ -2316,7 +2418,14 @@ impl MenuBar {match kind {Island::Music => {if let Some(track) = &look.track {- self.draw_player(gfx, &content, geometry, track, cover.as_ref())?;+ self.draw_player(+ gfx,+ &content,+ geometry,+ track,+ cover.as_ref(),+ look.volume_expanded,+ )?;}}Island::Usage => {@@ -2503,6 +2612,7 @@ impl MenuBar {geometry: IslandGeometry,track: &Track,cover: Option<&CompositionSurfaceBrush>,+ volume_expanded: bool,) -> Result<()> {let px = |v| geometry.px(v);let c = &gfx.compositor;@@ -2626,6 +2736,7 @@ impl MenuBar {.push(geometry.hit(x, y, size, size, IslandAction::Media(control)));}}+ self.draw_progress(gfx, layers, geometry, track)?;if let Some(volume) = self.status.volume {let symbol = if volume.muted {glyph::MUTE@@ -2633,18 +2744,62 @@ impl MenuBar {glyph::VOLUME[volume.level.min(3) as usize]};let label = gfx.glyph_brush(&[(symbol, 1.0)], geometry.scale, ink)?;+ let button_x = geometry.width - px(52.0);+ if volume_expanded {+ add_rounded_box(+ c,+ layers,+ button_x,+ px(127.0),+ px(28.0),+ px(28.0),+ px(9.0),+ geometry.control_fill(),+ None,+ )?;+ }+ add_visual(+ c,+ layers,+ &label.brush.cast()?,+ button_x + (px(28.0) - label.width) / 2.0,+ px(141.0) - label.height / 2.0,+ label.width,+ label.height,+ )?;+ self.island_hits.push(geometry.hit(+ button_x,+ px(127.0),+ px(28.0),+ px(28.0),+ IslandAction::ToggleVolume,+ ));+ if !volume_expanded {+ return Ok(());+ }+ add_rounded_box(+ c,+ layers,+ px(26.0),+ px(175.0),+ geometry.width - px(52.0),+ px(1.0),+ 0.0,+ geometry.border(),+ None,+ )?;add_visual(c,layers,&label.brush.cast()?,px(25.0),- px(140.0) - label.height / 2.0,+ px(192.0) - label.height / 2.0,label.width,label.height,)?;self.island_hits.push(geometry.hit(px(18.0),- px(126.0),+ px(178.0),px(32.0),px(28.0),IslandAction::Mute,@@ -2656,7 +2811,7 @@ impl MenuBar {c,layers,left,- px(138.0),+ px(190.0),width,px(4.0),px(2.0),@@ -2667,7 +2822,7 @@ impl MenuBar {c,layers,left,- px(138.0),+ px(190.0),width,px(4.0),px(2.0),@@ -2685,7 +2840,7 @@ impl MenuBar {layers,&label.brush.cast()?,geometry.width - px(51.0),- px(133.0),+ px(185.0),label.width,label.height,)?;@@ -2702,7 +2857,7 @@ impl MenuBar {self.volume_controls = Some(controls);self.island_hits.push(geometry.hit(left - px(6.0),- px(127.0),+ px(179.0),width + px(12.0),px(29.0),IslandAction::Volume(Span {@@ -2710,20 +2865,146 @@ impl MenuBar {right: geometry.left + left + width,}),));- } else {- add_panel_text(- gfx,+ }+ Ok(())+ }++ fn draw_progress(+ &mut self,+ gfx: &Gfx,+ layers: &VisualCollection,+ geometry: IslandGeometry,+ track: &Track,+ ) -> Result<()> {+ let px = |v| geometry.px(v);+ let c = &gfx.compositor;+ let width = (geometry.width+ - px(if self.status.volume.is_some() {+ 92.0+ } else {+ 52.0+ }))+ .max(px(1.0));+ let Some(timeline) = track.timeline else {+ let text = if self.status.volume.is_some() {+ strings::text().media_no_progress+ } else {+ strings::text().media_no_output+ };+ let label =+ gfx.text_brush_fitted(text, geometry.scale, 11.0, false, geometry.ink(), width)?;+ add_visual(+ c,layers,- strings::text().media_no_output,- px(25.0),+ &label.brush.cast()?,+ px(26.0),px(135.0),- geometry.scale,- 11.0,- false,- ink,- 0.5,- )?;+ label.width,+ label.height,+ )?+ .SetOpacity(0.55)?;+ return Ok(());+ };+ add_rounded_box(+ c,+ layers,+ px(26.0),+ px(139.0),+ width,+ px(4.0),+ px(2.0),+ geometry.control_fill(),+ None,+ )?;+ let (_, fill) = retained_rounded_box(+ c,+ layers,+ px(26.0),+ px(139.0),+ width,+ px(4.0),+ px(2.0),+ if geometry.light {+ rgba(40, 48, 58, 220)+ } else {+ rgba(240, 244, 250, 235)+ },+ None,+ )?;+ let label = gfx.text_brush_sized("0:00", geometry.scale, 10.0, false, geometry.ink())?;+ let elapsed = add_visual(+ c,+ layers,+ &label.brush.cast()?,+ px(26.0),+ px(148.0),+ label.width,+ label.height,+ )?;+ let total = add_visual(+ c,+ layers,+ &label.brush.cast()?,+ px(26.0),+ px(148.0),+ label.width,+ label.height,+ )?;+ elapsed.SetOpacity(0.6)?;+ total.SetOpacity(0.6)?;+ let mut controls = ProgressControls {+ fill,+ elapsed,+ total,+ geometry,+ width,+ elapsed_seconds: None,+ total_seconds: None,+ };+ controls.paint(gfx, timeline, Instant::now())?;+ self.progress_controls = Some(controls);+ Ok(())+ }++ fn sync_progress_watch(&mut self) {+ let shown =+ self.panel == Some(Island::Music) && self.visible && (!self.auto_hide || self.revealed);+ if let Some(media) = &self.media {+ media.show_progress(shown);}+ let ticking = shown+ && self.progress_controls.is_some()+ && self+ .look+ .as_ref()+ .and_then(|look| look.track.as_ref())+ .and_then(|track| track.timeline)+ .is_some_and(|timeline| timeline.advancing(Instant::now()));+ if ticking != self.progress_timer {+ // This timer only advances cached position/time labels while the+ // player popup is visible. No API calls, artwork reads or polling.+ unsafe {+ self.progress_timer = if ticking {+ SetTimer(Some(self.hwnd), PROGRESS_TIMER, 1000, None) != 0+ } else {+ let _ = KillTimer(Some(self.hwnd), PROGRESS_TIMER);+ false+ };+ }+ }+ }++ pub fn progress_tick(&mut self, gfx: &Gfx) -> Result<()> {+ if let Some(timeline) = self+ .look+ .as_ref()+ .and_then(|look| look.track.as_ref())+ .and_then(|track| track.timeline)+ && let Some(controls) = &mut self.progress_controls+ {+ controls.paint(gfx, timeline, Instant::now())?;+ }+ self.sync_progress_watch();Ok(())}@@ -2878,6 +3159,19 @@ fn volume_percent(span: Span, x: f32) -> u8 {(((x - span.left) / span.width()).clamp(0.0, 1.0) * 100.0).round() as u8}+fn media_time(seconds: u64) -> String {+ if seconds >= 3600 {+ format!(+ "{}:{:02}:{:02}",+ seconds / 3600,+ seconds / 60 % 60,+ seconds % 60+ )+ } else {+ format!("{}:{:02}", seconds / 60, seconds % 60)+ }+}+fn same_volume_indicator(old: Option<Volume>, new: Option<Volume>) -> bool {old.map(|v| (v.level, v.muted)) == new.map(|v| (v.level, v.muted))}@@ -3810,6 +4104,9 @@ mod island_tests {muted: false,percent: 50,});+ bar.volume_expanded = true;+ look.volume_expanded = true;+ look.status = bar.status;bar.apply_look(&gfx, look.clone())?;bar.apply_volume_reading(&gfx,@@ -3889,6 +4186,19 @@ mod island_tests {assert_eq!(volume_percent(Span::default(), 1.0), 0);}+ #[test]+ fn playback_timestamps_include_hours_without_affecting_short_tracks() {+ for (seconds, expected) in [+ (0, "0:00"),+ (65, "1:05"),+ (3599, "59:59"),+ (3600, "1:00:00"),+ (3661, "1:01:01"),+ ] {+ assert_eq!(media_time(seconds), expected);+ }+ }+#[test]fn percentage_changes_keep_the_same_indicator_but_mute_and_device_changes_do_not() {let volume = Volume {@@ -3953,8 +4263,41 @@ mod island_tests {for (light, glass) in [(true, true), (false, true), (true, false), (false, false)] {look.light = light;look.glass = glass;+ look.volume_expanded = false;+ bar.volume_expanded = false;bar.build(&gfx, &look)?;assert!(bar.cover.is_some());+ assert!(bar.progress_controls.is_some());+ assert!(bar.volume_controls.is_none());+ assert!(!bar.island_hits.iter().any(|hit| matches!(+ hit.action,+ IslandAction::Volume(_) | IslandAction::Mute+ )));+ let audio = *bar+ .island_hits+ .iter()+ .find(|hit| matches!(hit.action, IslandAction::ToggleVolume))+ .context("volume expander")?;+ let (audio_left, audio_top, audio_right, audio_bottom) = audio.bounds;+ let progress = bar.progress_controls.as_ref().context("progress")?;+ assert!(+ progress.geometry.left + progress.geometry.px(26.0) + progress.width+ < audio_left+ );+ assert!(+ audio_right <= bar.panel_span.right+ && audio_bottom+ <= (HEIGHT + PANEL_GAP + look.panel_height()) * scale + 1.0+ );+ bar.panel = look.panel;+ bar.look = Some(look.clone());+ bar.click(+ &gfx,+ (audio_left + audio_right) / 2.0,+ (audio_top + audio_bottom) / 2.0,+ )?;+ look = bar.look.clone().context("expanded look")?;+ assert!(bar.volume_expanded && look.volume_expanded);let brush = bar.cover.as_ref().context("missing cover")?.1.clone();bar.build(&gfx, &look)?;assert_eq!(bar.cover.as_ref().context("cached cover")?.1, brush);@@ -3982,7 +4325,7 @@ mod island_tests {.find(|hit| {hit.at(geometry.left + geometry.px(30.0),- geometry.top + geometry.px(140.0),+ geometry.top + geometry.px(192.0),)}).context("speaker has no hit target")?;@@ -3990,12 +4333,24 @@ mod island_tests {let slider = bar.island_hits.iter()- .find(|hit| hit.at((left + right) / 2.0, geometry.top + geometry.px(140.0)))+ .find(|hit| hit.at((left + right) / 2.0, geometry.top + geometry.px(192.0))).context("slider has no hit target")?;assert!(matches!(slider.action, IslandAction::Volume(_)));}}}+ let audio = *bar+ .island_hits+ .iter()+ .find(|hit| matches!(hit.action, IslandAction::ToggleVolume))+ .context("collapse volume")?;+ let (left, top, right, bottom) = audio.bounds;+ bar.click(&gfx, (left + right) / 2.0, (top + bottom) / 2.0)?;+ assert!(!bar.volume_expanded && bar.volume_controls.is_none());+ assert!(bar.progress_controls.is_some());+ bar.click(&gfx, (left + right) / 2.0, (top + bottom) / 2.0)?;+ assert!(bar.volume_expanded && bar.volume_controls.is_some());+ look = bar.look.clone().context("reopened volume")?;let image = Arc::new(muelle_shell::icons::IconImage {width: 8,height: 8,@@ -4025,6 +4380,25 @@ mod island_tests {let full_redraw = started.elapsed();bar.look = Some(look.clone());let root = bar.surface.Children()?.First()?.Current()?;+ let mut update = look.track.clone().context("track for progress update")?;+ update.timeline = Track::test_fixture().timeline;+ bar.media = Some(media::Watch::test_snapshot(update));+ bar.media_changed(&gfx)?;+ assert_eq!(+ bar.surface.Children()?.First()?.Current()?,+ root,+ "position events retain the visual tree"+ );+ bar.visible = true; // The native window stays hidden throughout the fixture.+ bar.revealed = true;+ bar.sync_progress_watch();+ assert!(bar.progress_timer);+ bar.visible = false;+ bar.sync_progress_watch();+ assert!(+ !bar.progress_timer,+ "hidden popups must have no progress timer"+ );let started = Instant::now();for step in 0..64 {bar.apply_volume_reading(@@ -4095,6 +4469,7 @@ mod island_tests {assert!(bar.release_volume(Some(200.0))?); // Late up after capture loss/timer.assert!(!bar.release_volume(Some(200.0))?);bar.status.volume = None;+ look.status = bar.status;// DWM/theme changes can require a new host backdrop while the visible// theme flags remain identical. A cached Look must not suppress it.bar.look = Some(look.clone());@@ -4112,6 +4487,9 @@ mod island_tests {.iter().any(|hit| matches!(hit.action, IslandAction::Volume(_) | IslandAction::Mute)));+ look.track.as_mut().context("track")?.timeline = None;+ bar.apply_look(&gfx, look)?;+ assert!(bar.progress_controls.is_none() && !bar.progress_timer);Ok(())}diff --git a/apps/dock/src/strings.rs b/apps/dock/src/strings.rsindex 34c2e53..7b7e771 100644--- a/apps/dock/src/strings.rs+++ b/apps/dock/src/strings.rs@@ -41,6 +41,7 @@ pub struct Strings {pub usage_used: &'static str,pub media_title: &'static str,pub media_no_output: &'static str,+ pub media_no_progress: &'static str,pub folder_empty: &'static str,pub folder_unavailable: &'static str,pub change_folder: &'static str,@@ -95,6 +96,7 @@ const ES: Strings = Strings {usage_used: "usado",media_title: "Reproducción",media_no_output: "Sin dispositivo de salida",+ media_no_progress: "Progreso no disponible",folder_empty: "(vacía)",folder_unavailable: "Carpeta no disponible",change_folder: "&Cambiar de carpeta…",@@ -142,6 +144,7 @@ const EN: Strings = Strings {usage_used: "used",media_title: "Now playing",media_no_output: "No output device",+ media_no_progress: "Progress unavailable",folder_empty: "(empty)",folder_unavailable: "Folder unavailable",change_folder: "&Change Folder…",@@ -189,6 +192,7 @@ const FR: Strings = Strings {usage_used: "utilisé",media_title: "En cours de lecture",media_no_output: "Aucun périphérique de sortie",+ media_no_progress: "Progression indisponible",folder_empty: "(vide)",folder_unavailable: "Dossier introuvable",change_folder: "&Changer de dossier…",diff --git a/apps/settings/src/App.tsx b/apps/settings/src/App.tsxindex 5c509b2..f0c8872 100644--- a/apps/settings/src/App.tsx+++ b/apps/settings/src/App.tsx@@ -546,6 +546,15 @@ export function App() {/></Row></Card>+ <Card>+ <Row label={t.showOtherWorkspaces} hint={t.showOtherWorkspacesHint}>+ <Toggle+ label={t.showOtherWorkspaces}+ checked={config.showOtherWorkspaces ?? false}+ onChange={(showOtherWorkspaces) => update({ showOtherWorkspaces })}+ />+ </Row>+ </Card></>) : section === "menubar" ? (<>diff --git a/apps/settings/src/config.ts b/apps/settings/src/config.tsindex 2ad7911..9627727 100644--- a/apps/settings/src/config.ts+++ b/apps/settings/src/config.ts@@ -27,6 +27,7 @@ export interface Config {genie: boolean;genieSpeed: GenieSpeed;showMinimized: boolean;+ showOtherWorkspaces: boolean;showPreviewCloseButton: boolean;jumpLists: boolean;menuBar: boolean;diff --git a/apps/settings/src/i18n/en.json b/apps/settings/src/i18n/en.jsonindex 2319a4c..cc0daad 100644--- a/apps/settings/src/i18n/en.json+++ b/apps/settings/src/i18n/en.json@@ -37,6 +37,8 @@"genieOffAction": "Open Windows settings","showMinimized": "Show minimized windows","showMinimizedHint": "Thumbnails separate from app icons.",+ "showOtherWorkspaces": "Show windows from other workspaces",+ "showOtherWorkspacesHint": "Reuse open windows across Windows virtual desktops and compatible tiling workspaces, such as komorebi's Cloak mode.","showPreviewCloseButton": "Show close button on previews","showPreviewCloseButtonHint": "Displays a close button on window hover previews and allows middle-clicking to close.","menuBar": "Menu bar",diff --git a/apps/settings/src/i18n/es.json b/apps/settings/src/i18n/es.jsonindex 955d804..85513a2 100644--- a/apps/settings/src/i18n/es.json+++ b/apps/settings/src/i18n/es.json@@ -37,6 +37,8 @@"genieOffAction": "Abrir la configuración de Windows","showMinimized": "Mostrar ventanas minimizadas","showMinimizedHint": "Miniaturas separadas de los iconos de las apps.",+ "showOtherWorkspaces": "Mostrar ventanas de otros espacios de trabajo",+ "showOtherWorkspacesHint": "Reutiliza ventanas abiertas en escritorios virtuales de Windows y espacios compatibles, como el modo Cloak de komorebi.","showPreviewCloseButton": "Mostrar botón de cerrar en previsualizaciones","showPreviewCloseButtonHint": "Muestra un botón de cerrar en las previsualizaciones y permite cerrar con clic central.","menuBar": "Barra superior",diff --git a/apps/settings/src/i18n/fr.json b/apps/settings/src/i18n/fr.jsonindex 76e60db..f70a842 100644--- a/apps/settings/src/i18n/fr.json+++ b/apps/settings/src/i18n/fr.json@@ -37,6 +37,8 @@"genieOffAction": "Ouvrir les paramètres de Windows","showMinimized": "Afficher les fenêtres réduites","showMinimizedHint": "Des miniatures séparées des icônes des apps.",+ "showOtherWorkspaces": "Afficher les fenêtres des autres espaces de travail",+ "showOtherWorkspacesHint": "Réutilise les fenêtres ouvertes sur les bureaux virtuels Windows et les espaces compatibles, comme le mode Cloak de komorebi.","showPreviewCloseButton": "Afficher le bouton de fermeture sur les aperçus","showPreviewCloseButtonHint": "Affiche un bouton de fermeture sur les aperçus et permet de fermer avec le clic du milieu.","menuBar": "Barre de menus",diff --git a/apps/settings/tests/app.test.mjs b/apps/settings/tests/app.test.mjsindex c37fb64..ba5dec3 100644--- a/apps/settings/tests/app.test.mjs+++ b/apps/settings/tests/app.test.mjs@@ -31,6 +31,7 @@ const base = {dockDensity: "normal", dockAutoHideSpeed: "normal", showStart: true,showTrash: true, pinExplorer: true,showDownloads: true,+ showOtherWorkspaces: false,menuBarIslandStyle: "notch", menuBarSearch: null, menuBarTaskView: null,menuBarWidgets: null, menuBarBatteryPercent: null, checkUpdates: false,pinned: [], recent: [], shortcutsFolder: null,@@ -128,6 +129,26 @@ test("each section renders only its own controls, in every language and visibili}});+test("other workspaces are opt-in and save without changing other window preferences", async () => {+ const view = fixture("windows", { showOtherWorkspaces: undefined });+ const checked = () => [...elements(view.body())].find((node) =>+ node.props.label === texts.en.showOtherWorkspaces && "checked" in node.props).props.checked;+ const unmount = await view.mount();+ try {+ assert.equal(checked(), false);+ view.change(texts.en.showOtherWorkspaces, true);+ view.fire(60);+ await settle();+ assert.equal(checked(), true);+ assert.deepEqual(view.calls, [{ showOtherWorkspaces: true }]);+ view.change(texts.en.showOtherWorkspaces, false);+ view.fire(60);+ await settle();+ assert.equal(checked(), false);+ assert.deepEqual(view.calls.at(-1), { showOtherWorkspaces: false });+ } finally { unmount(); }+});+test("failed writes remain retryable and prevent closing until saved", async () => {let fail = true;const view = fixture("menubar", {}, async () => { if (fail) throw new Error("disk busy"); });diff --git a/crates/muelle-config/src/lib.rs b/crates/muelle-config/src/lib.rsindex 88203ea..3d4225f 100644--- a/crates/muelle-config/src/lib.rs+++ b/crates/muelle-config/src/lib.rs@@ -76,6 +76,9 @@ pub struct Config {/// Minimized windows get a live thumbnail in the right section of the/// dock. Off by default: they go into their app's icon instead.pub show_minimized: bool,+ /// Include shell-cloaked windows from Windows/tiling-WM workspaces.+ /// Off by default to preserve the current-desktop taskbar behavior.+ pub show_other_workspaces: bool,/// An app's right-click menu starts with its jump list (pinned and recent/// items, tasks), as on the Windows taskbar. Off, the menu has only the/// dock's own items and no jump list is read.@@ -306,6 +309,7 @@ impl Default for Config {genie: true,genie_speed: GenieSpeed::Normal,show_minimized: false,+ show_other_workspaces: false,jump_lists: true,menu_bar: true,menu_bar_auto_hide: false,@@ -463,6 +467,16 @@ fn write_config(path: &Path, config: &Config) -> Result<(), ConfigError> {mod tests {use super::*;+ #[test]+ fn other_workspaces_are_opt_in_and_preserved_when_saving() -> Result<(), serde_json::Error> {+ let legacy: Config = serde_json::from_str("{}")?;+ assert!(!legacy.show_other_workspaces);+ let enabled: Config = serde_json::from_str(r#"{"showOtherWorkspaces":true}"#)?;+ let restored: Config = serde_json::from_str(&serde_json::to_string(&enabled)?)?;+ assert!(restored.show_other_workspaces);+ Ok(())+ }+#[test]fn intelligent_hiding_defaults_off_and_retired_banner_preferences_are_ignored()-> Result<(), serde_json::Error> {diff --git a/crates/muelle-shell/src/launcher.rs b/crates/muelle-shell/src/launcher.rsindex 494c9a2..cb02d63 100644--- a/crates/muelle-shell/src/launcher.rs+++ b/crates/muelle-shell/src/launcher.rs@@ -386,7 +386,10 @@ fn activate_with(windows: &[isize], request_focus: impl FnOnce(HWND) -> bool) {unsafe {let valid = |hwnd: HWND| IsWindow(Some(hwnd)).as_bool() && IsWindowVisible(hwnd).as_bool();let Some(front) = handles()- .find(|&hwnd| valid(hwnd) && !IsIconic(hwnd).as_bool())+ .find(|&hwnd| {+ valid(hwnd) && !IsIconic(hwnd).as_bool() && !crate::tracker::is_cloaked(hwnd)+ })+ .or_else(|| handles().find(|&hwnd| valid(hwnd) && !IsIconic(hwnd).as_bool())).or_else(|| handles().find(|&hwnd| valid(hwnd)))else {return;@@ -445,6 +448,7 @@ fn stack_group_behind(front: HWND, windows: &[isize], foreground: impl Fn() -> H|| !IsWindow(Some(hwnd)).as_bool()|| !IsWindowVisible(hwnd).as_bool()|| IsIconic(hwnd).as_bool()+ || crate::tracker::is_cloaked(hwnd)|| GetWindowLongW(hwnd, GWL_EXSTYLE) as u32 & WS_EX_TOPMOST.0 != 0{continue;@@ -473,7 +477,10 @@ pub fn minimize(windows: &[isize]) {let hwnd = HWND(raw as *mut _);// SAFETY: Calls on another window; they fail without effect if it is gone.unsafe {- if IsWindowVisible(hwnd).as_bool() && !IsIconic(hwnd).as_bool() {+ if IsWindowVisible(hwnd).as_bool()+ && !IsIconic(hwnd).as_bool()+ && !crate::tracker::is_cloaked(hwnd)+ {let _ = ShowWindowAsync(hwnd, SW_MINIMIZE);}}@@ -554,6 +561,53 @@ mod tests {}}+ #[test]+ #[ignore = "requires a Windows desktop; cloaks only a test-owned window without taking focus"]+ fn native_workspace_activation_prefers_visible_peers_and_preserves_background_cloaks()+ -> windows::core::Result<()> {+ use std::cell::Cell;+ use windows::Win32::Graphics::Dwm::{DWMWA_CLOAK, DwmSetWindowAttribute};++ let desktop = Desktop::new()?;+ let [cloaked, visible, _] = desktop.windows[..] else {+ unreachable!("three test windows");+ };+ let cloak = windows::core::BOOL::from(true);+ // SAFETY: Only the fixture's own window is cloaked, never user apps.+ unsafe {+ DwmSetWindowAttribute(+ cloaked,+ DWMWA_CLOAK,+ (&raw const cloak).cast(),+ size_of::<windows::core::BOOL>() as u32,+ )?;+ }+ assert!(crate::tracker::is_cloaked(cloaked));+ let group = [cloaked.0 as isize, visible.0 as isize];+ let selected = Cell::new(HWND::default());+ activate_with(&group, |target| {+ selected.set(target);+ false // Record the request without changing the user's foreground.+ });+ assert_eq!(selected.get(), visible);+ activate_with(&group[..1], |target| {+ selected.set(target);+ false+ });+ assert_eq!(+ selected.get(),+ cloaked,+ "a remote-only window remains activatable"+ );+ let before = desktop.order()?;+ stack_group_behind(visible, &group, || visible);+ assert_eq!(desktop.order()?, before, "do not reposition a cloaked peer");+ minimize(&group[..1]);+ assert!(!unsafe { IsIconic(cloaked) }.as_bool());+ assert!(crate::tracker::is_cloaked(cloaked));+ Ok(())+ }+#[test]#[ignore = "Requires a Windows desktop; briefly restores only a test-owned window"]fn native_minimized_window_restores_even_when_the_focus_request_is_refused()diff --git a/crates/muelle-shell/src/tracker.rs b/crates/muelle-shell/src/tracker.rsindex 5be5f24..a6e2752 100644--- a/crates/muelle-shell/src/tracker.rs+++ b/crates/muelle-shell/src/tracker.rs@@ -10,7 +10,7 @@ use windows::{Win32::{Foundation::{CloseHandle, HWND, LPARAM, POINT, RECT, WPARAM},Graphics::{- Dwm::{DWMWA_CLOAKED, DwmGetWindowAttribute},+ Dwm::{DWM_CLOAKED_SHELL, DWMWA_CLOAKED, DwmGetWindowAttribute},Gdi::ClientToScreen,},Storage::{@@ -69,6 +69,12 @@ pub struct WindowTracker {impl WindowTracker {pub fn list(&mut self) -> Vec<TrackedWindow> {+ self.list_with_workspaces(false)+ }++ /// Optionally includes shell-cloaked windows on other Windows/tiling-WM+ /// workspaces. App-cloaked and inherited-cloak windows remain excluded.+ pub fn list_with_workspaces(&mut self, show_other_workspaces: bool) -> Vec<TrackedWindow> {unsafe extern "system" fn collect(hwnd: HWND, list: LPARAM) -> BOOL {// SAFETY: `list` points to the Vec passed by `list` and remains// alive for the entire synchronous enumeration.@@ -84,7 +90,7 @@ impl WindowTracker {let windows: Vec<TrackedWindow> = all.into_iter()- .filter(|&hwnd| is_app_window(hwnd))+ .filter(|&hwnd| is_app_window(hwnd, show_other_workspaces)).filter_map(|hwnd| {let key = hwnd.0 as isize;let app_id = match self.app_ids.get(&key) {@@ -257,6 +263,7 @@ fn recover_browser_z_order_with(for window in windows {let browser = window.hwnd;if window.app_id == active.app_id+ || is_cloaked(HWND(browser as *mut _))|| !matches!(window.app_id.rsplit('\\').next(),Some("msedge.exe" | "brave.exe")@@ -500,7 +507,11 @@ pub fn task_switcher_state() -> Option<bool> {/// Hidden by the system although "visible": on another virtual desktop, or/// a suspended Store app.-fn is_cloaked(hwnd: HWND) -> bool {+pub(crate) fn is_cloaked(hwnd: HWND) -> bool {+ cloak_state(hwnd) != 0+}++fn cloak_state(hwnd: HWND) -> u32 {let mut cloaked = 0u32;// SAFETY: `cloaked` is a valid 4-byte output.unsafe {@@ -511,7 +522,13 @@ fn is_cloaked(hwnd: HWND) -> bool {size_of::<u32>() as u32,);}- cloaked != 0+ cloaked+}++fn workspace_cloak_allowed(cloaked: u32, show_other_workspaces: bool) -> bool {+ // Do not expose suspended Store apps or owner-cloaked helper windows,+ // including mixed flags. Windows desktops and tiling WMs share SHELL.+ cloaked == 0 || (show_other_workspaces && cloaked == DWM_CLOAKED_SHELL)}/// The desktop and the (hidden) taskbar: shell windows, not apps.@@ -529,7 +546,7 @@ fn covers(window: RECT, screen: RECT) -> bool {&& window.bottom >= screen.bottom}-fn is_app_window(hwnd: HWND) -> bool {+fn is_app_window(hwnd: HWND, show_other_workspaces: bool) -> bool {// SAFETY: Read-only queries; calls on a destroyed `hwnd` have no effect.unsafe {if !IsWindowVisible(hwnd).as_bool() || GetWindowTextLengthW(hwnd) == 0 {@@ -545,8 +562,7 @@ fn is_app_window(hwnd: HWND) -> bool {if (owned || has(WS_EX_NOACTIVATE)) && !has(WS_EX_APPWINDOW) {return false;}- // Windows hidden by the system, such as on other virtual desktops or suspended apps.- if is_cloaked(hwnd) {+ if !workspace_cloak_allowed(cloak_state(hwnd), show_other_workspaces) {return false;}let mut pid = 0u32;@@ -670,6 +686,26 @@ pub fn request_close_window(hwnd: isize) -> bool {mod tests {use super::*;+ #[test]+ fn workspace_cloaking_is_opt_in_without_exposing_app_or_inherited_cloaks() {+ use windows::Win32::Graphics::Dwm::{DWM_CLOAKED_APP, DWM_CLOAKED_INHERITED};++ assert!(workspace_cloak_allowed(0, false));+ assert!(workspace_cloak_allowed(0, true));+ assert!(!workspace_cloak_allowed(DWM_CLOAKED_SHELL, false));+ assert!(workspace_cloak_allowed(DWM_CLOAKED_SHELL, true));+ for flags in [+ DWM_CLOAKED_APP,+ DWM_CLOAKED_INHERITED,+ DWM_CLOAKED_SHELL | DWM_CLOAKED_APP,+ DWM_CLOAKED_SHELL | DWM_CLOAKED_INHERITED,+ 8,+ ] {+ assert!(!workspace_cloak_allowed(flags, false), "flags={flags}");+ assert!(!workspace_cloak_allowed(flags, true), "flags={flags}");+ }+ }+#[test]fn fullscreen_geometry_should_follow_content_instead_of_maximized_style()-> windows::core::Result<()> {