Skip to content

A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.

chore(release): prepare v0.1.21

CristianOlivera1050a0c857195
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09a05a2..3e4fd95 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,36 @@ copia la sección de la versión que se publica a la release de GitHub.
## [Unreleased]
+## [0.1.21]
+
+### English
+
+- Removed Muelle's custom notification cards, notification CLI/IPC and banner
+ settings. Windows notifications remain managed by Windows; native dock
+ attention indicators and bounce are retained.
+- Added optional intelligent Dock hiding, disabled by default. When enabled,
+ maximized windows use the full work area and the Dock hides when the active
+ app overlaps it. Enable it independently of always-auto-hide in Settings.
+- Claude Desktop background processes no longer imply active use. Native Claude
+ Code is distinguished from Desktop, and missing credentials name the required
+ Claude Code sign-in instead of promising Desktop authentication works.
+- Recreate dock/menu-bar backdrop materials on Windows theme/colorization changes,
+ even when cached light/glass flags are unchanged.
+
+### Español
+
+- Retirados los banners personalizados, su CLI/IPC y sus ajustes. Windows
+ conserva sus notificaciones; permanecen el indicador de atención y el rebote
+ del Dock.
+- Añadida ocultación inteligente del Dock, desactivada por defecto. Al activarla,
+ las ventanas maximizadas aprovechan el área útil completa y el Dock se oculta
+ si la app activa ocupa su espacio, independientemente del auto-hide.
+- Claude Desktop cerrado en segundo plano ya no cuenta como uso activo. Se
+ distingue el cliente nativo de Claude Code de Desktop y, sin credenciales,
+ se indica cómo iniciar sesión en Claude Code.
+- Los cambios de tema/color del compositor reconstruyen el cristal del Dock y
+ la barra, aunque las opciones de claro/oscuro y transparencia no hayan cambiado.
+
## [0.1.20]
### English
diff --git a/Cargo.lock b/Cargo.lock
index fd19a84..9e01888 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2253,7 +2253,7 @@ dependencies = [
[[package]]
name = "muelle"
-version = "0.1.20"
+version = "0.1.21"
dependencies = [
"anyhow",
"chrono",
@@ -2274,7 +2274,7 @@ dependencies = [
[[package]]
name = "muelle-config"
-version = "0.1.20"
+version = "0.1.21"
dependencies = [
"serde",
"serde_json",
@@ -2283,11 +2283,11 @@ dependencies = [
[[package]]
name = "muelle-core"
-version = "0.1.20"
+version = "0.1.21"
[[package]]
name = "muelle-settings"
-version = "0.1.20"
+version = "0.1.21"
dependencies = [
"base64 0.23.1",
"muelle-config",
@@ -2303,7 +2303,7 @@ dependencies = [
[[package]]
name = "muelle-shell"
-version = "0.1.20"
+version = "0.1.21"
dependencies = [
"serde",
"thiserror 2.0.21",
diff --git a/Cargo.toml b/Cargo.toml
index fbc16c1..b91b2a1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/*", "apps/dock", "apps/settings/src-tauri", "spikes"]
[workspace.package]
-version = "0.1.20"
+version = "0.1.21"
edition = "2024"
license = "MIT"
diff --git a/README.md b/README.md
index 809e7b7..73a4655 100644
--- a/README.md
+++ b/README.md
@@ -160,6 +160,5 @@ project. It makes two kinds of network requests, both optional:
the key from OpenCode's local `auth.json` or `ZAI_API_KEY` /
`ZHIPU_API_KEY`, then sends it to Z.ai's quota service. Turn usage queries
off in Settings → Menu bar → *Show AI provider usage*.
-- **Notifications:** notification content and banners are processed strictly in memory on your local machine and are never written to disk, saved in log files, or transmitted over the network.
Details: [muelle.crafter.run/privacy](https://muelle.crafter.run/privacy).
diff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rs
index 7874f85..0e4681b 100644
--- a/apps/dock/src/app.rs
+++ b/apps/dock/src/app.rs
@@ -82,12 +82,12 @@ use windows::{
RegisterShellHookWindow, RegisterWindowMessageW, SM_CXDRAG, SM_SWAPBUTTON,
SWP_HIDEWINDOW, SWP_NOACTIVATE, SWP_SHOWWINDOW, SetTimer, SetWindowPos,
WINDOW_EX_STYLE, WINEVENT_OUTOFCONTEXT, WINEVENT_SKIPOWNPROCESS, WM_APP,
- WM_CAPTURECHANGED, WM_CLOSE, WM_COPYDATA, WM_DESTROY, WM_DISPLAYCHANGE,
- WM_DPICHANGED, WM_INITMENUPOPUP, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN,
- WM_MBUTTONUP, WM_MOUSEACTIVATE, WM_MOUSEMOVE, WM_QUIT, WM_RBUTTONUP,
- WM_SETTINGCHANGE, WM_TIMER, WNDCLASSW, WS_EX_LAYERED, WS_EX_NOACTIVATE,
- WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW, WS_EX_TOPMOST, WS_EX_TRANSPARENT,
- WS_POPUP,
+ WM_CAPTURECHANGED, WM_CLOSE, WM_DESTROY, WM_DISPLAYCHANGE, WM_DPICHANGED,
+ WM_DWMCOLORIZATIONCOLORCHANGED, WM_INITMENUPOPUP, WM_LBUTTONDOWN, WM_LBUTTONUP,
+ WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEACTIVATE, WM_MOUSEMOVE, WM_QUIT,
+ WM_RBUTTONUP, WM_SETTINGCHANGE, WM_THEMECHANGED, WM_TIMER, WNDCLASSW,
+ WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW,
+ WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_POPUP,
},
},
},
@@ -106,7 +106,6 @@ use crate::{
menu::{self, MenuItem},
menubar::{MenuBar, MenuBarWidgets},
multi_window_view::{self, MultiWindowAction, MultiWindowView},
- notification_banner,
scene::{Drag, Frame, Scene, SceneInput, SlotContent, Theme},
shell_work::{self, Action as ShellAction},
strings::{self, text},
@@ -576,6 +575,7 @@ struct StageKey {
glass: bool,
bin_full: bool,
auto_hide: bool,
+ smart_hide: bool,
icon_size: u32,
density: DockDensity,
max_scale: f32,
@@ -659,6 +659,17 @@ struct SwitcherFollow {
tab_down: bool,
}
+fn rects_overlap(a: RECT, b: RECT) -> bool {
+ a.left < a.right
+ && a.top < a.bottom
+ && b.left < b.right
+ && b.top < b.bottom
+ && a.left < b.right
+ && b.left < a.right
+ && a.top < b.bottom
+ && b.top < a.bottom
+}
+
struct Stage {
key: StageKey,
window_zone: RECT,
@@ -770,6 +781,7 @@ pub(crate) struct App {
taskbar_retry: bool,
taskbar_attempts: u8,
fullscreen: bool,
+ smart_hidden: bool,
roster: Roster,
tracker: WindowTracker,
windows: Vec<TrackedWindow>,
@@ -825,7 +837,6 @@ pub(crate) struct App {
pointed: bool,
pending_drop: Option<Outside>,
bounces: HashMap<String, Bounce>,
- notifications: muelle_core::notifications::NotificationQueue,
/// Minimized windows, in the order they were minimized.
minimized: Vec<isize>,
thumbnails: Thumbnails,
@@ -1336,6 +1347,7 @@ impl App {
glass: transparency_enabled(),
bin_full: self.bin_full,
auto_hide: self.config.auto_hide,
+ smart_hide: self.config.smart_hide,
icon_size: self.config.icon_size,
density: self.config.dock_density,
max_scale: self.config.max_scale(),
@@ -1432,7 +1444,7 @@ impl App {
};
let frame = DockFrame::new(edge, (dock_x, dock_y), dock.height);
// A hidden dock leaves the whole screen to maximized windows.
- let strip = if self.config.auto_hide {
+ let strip = if self.config.hides_automatically() {
0
} else {
(dock.height + 2.0 * margin) as i32
@@ -1629,16 +1641,18 @@ impl App {
layout: dock,
};
self.stage = Some(stage);
+ self.update_smart_hiding()?;
self.sync_badge_visuals()?;
self.place_windows()?;
self.schedule_trim();
self.render()?;
// Last: reserving space is a synchronous call to Explorer (40-60 ms
// measured), and the dock is already on screen meanwhile.
+ let automatic = self.config.hides_automatically();
if let Some(appbar) = &mut self.appbar {
// Auto-hide reserves zero height. Moving the dock must never
// change the destination monitor's work area.
- let reservation = if self.config.auto_hide {
+ let reservation = if automatic {
primary_monitor().map_or(screen, |primary| primary.screen)
} else {
screen
@@ -1663,7 +1677,7 @@ impl App {
// dock (for example, after launching an app with a dock click).
let input_zone = if self.hovering || self.drag.is_some() {
&stage.hover_zone
- } else if self.config.auto_hide && self.slide.target == 1.0 {
+ } else if self.config.hides_automatically() && self.slide.target == 1.0 {
&stage.edge_zone
} else {
&stage.rest_zone
@@ -2128,7 +2142,7 @@ impl App {
unsafe {
let _ = KillTimer(Some(self.input), PREVIEW_TIMER);
}
- if self.preview.take().is_some() && self.config.auto_hide && !self.hovering {
+ if self.preview.take().is_some() && self.config.hides_automatically() && !self.hovering {
unsafe { SetTimer(Some(self.input), HIDE_TIMER, HIDE_DELAY_MS, None) };
}
}
@@ -2235,7 +2249,7 @@ impl App {
}
self.amount.target = 0.0;
self.last_frame = Instant::now();
- if self.config.auto_hide {
+ if self.config.hides_automatically() {
// SAFETY: Timer on our own window.
unsafe { SetTimer(Some(self.input), HIDE_TIMER, HIDE_DELAY_MS, None) };
}
@@ -2272,7 +2286,7 @@ impl App {
SetTimer(Some(self.input), SWITCHER_TIMER, SWITCHER_POLL_MS, None);
let _ = KillTimer(Some(self.input), HIDE_TIMER);
}
- if self.config.auto_hide && !self.fullscreen {
+ if self.config.hides_automatically() && !self.fullscreen {
self.slide.target = 0.0;
self.last_frame = Instant::now();
self.place_windows()?;
@@ -2551,7 +2565,7 @@ impl App {
return;
}
}
- if matches!(place, mascot::Place::Along { .. }) && self.config.auto_hide {
+ if matches!(place, mascot::Place::Along { .. }) && self.config.hides_automatically() {
// Reveal only after the mascot and its cleanup timer exist.
unsafe {
let _ = KillTimer(Some(self.input), HIDE_TIMER);
@@ -2578,7 +2592,7 @@ impl App {
// mascot timer, and resume the usual dock hiding delay after an act.
unsafe {
let _ = KillTimer(Some(self.input), MASCOT_TIMER);
- if active && self.config.auto_hide {
+ if active && self.config.hides_automatically() {
SetTimer(Some(self.input), HIDE_TIMER, HIDE_DELAY_MS, None);
}
}
@@ -2673,7 +2687,7 @@ impl App {
}
fn hide_if_unused(&mut self) -> Result<()> {
- if !self.config.auto_hide
+ if !(self.config.auto_hide || self.smart_hidden)
|| self.mascot.is_some()
|| self.menu_open
|| self.drag_over
@@ -3286,7 +3300,7 @@ impl App {
if !drag.from_group || self.hovering {
return Ok(());
}
- if self.config.auto_hide {
+ if self.config.hides_automatically() {
// SAFETY: Timer on our own window.
unsafe { SetTimer(Some(self.input), HIDE_TIMER, HIDE_DELAY_MS, None) };
}
@@ -3509,7 +3523,7 @@ impl App {
fn close_group_view(&mut self) {
if self.group_view.take().is_some()
- && self.config.auto_hide
+ && self.config.hides_automatically()
&& !self.hovering
&& self.drag.is_none()
{
@@ -4037,18 +4051,21 @@ impl App {
self.restore_transitions();
self.snapshots.clear();
}
- if config.notification_dnd || !config.notifications {
- self.notifications.clear_banners();
- notification_banner::NotificationBannerView::hide();
- }
- if config.auto_hide != self.config.auto_hide {
- self.slide.target = if config.auto_hide { 1.0 } else { 0.0 };
- self.last_frame = Instant::now();
- }
+ let hiding_changed = config.auto_hide != self.config.auto_hide
+ || config.smart_hide != self.config.smart_hide;
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();
self.config = config;
+ self.smart_hidden &= self.config.smart_hide;
+ if hiding_changed {
+ if self.config.auto_hide || self.smart_hidden {
+ self.hide_if_unused()?;
+ } else {
+ self.slide.target = 0.0;
+ self.last_frame = Instant::now();
+ }
+ }
if moved {
// A hidden dock comes out of its new edge on every display.
self.apply_edge_settings();
@@ -4142,7 +4159,11 @@ impl App {
fn toggle_hiding(&mut self) -> Result<()> {
self.config.auto_hide = save_dock_config(&self.roster, &self.config, true)?.auto_hide;
- self.slide.target = if self.config.auto_hide { 1.0 } else { 0.0 };
+ self.slide.target = if self.config.auto_hide || self.smart_hidden {
+ 1.0
+ } else {
+ 0.0
+ };
self.last_frame = Instant::now();
self.apply_edge_settings();
self.refresh()?;
@@ -4206,162 +4227,29 @@ impl App {
self.sync_badge_visuals()?;
self.render()?;
}
- if (self.config.notification_badges || self.config.notifications)
- && !self.config.muted_apps.contains(&app_id)
- {
- let title = tracker::title(hwnd);
- let app_name = muelle_shell::names::display_name(&app_id);
- let app_name = if app_name.is_empty() {
- title.clone()
- } else {
- app_name
- };
- let pushed = self.notifications.push(
- app_id.clone(),
- app_name,
- title,
- String::new(),
- None,
- Some(hwnd),
- self.config.notification_duration as u64 * 1000,
- self.config.notification_dnd || !self.config.notifications,
- false,
- );
- if self.config.notification_badges {
- let _ = self.render();
- }
- if pushed.is_some() {
- self.show_active_banners();
- }
- }
+ // HSHELL_FLASH is only an attention request: it carries neither a
+ // notification body nor an unread count. Repeated flashes must not
+ // manufacture banners or increment message counters.
}
Ok(())
}
- fn show_active_banners(&self) {
- if self.fullscreen || self.config.notification_dnd || !self.config.notifications {
- return;
- }
- let pos = match self.config.notification_position {
- muelle_config::NotificationPosition::TopRight => {
- muelle_core::notifications::BannerPosition::TopRight
- }
- muelle_config::NotificationPosition::BottomRight => {
- muelle_core::notifications::BannerPosition::BottomRight
- }
- };
- let work_area = primary_monitor().map_or(
- Rect {
- x: 0.0,
- y: 0.0,
- width: 1920.0,
- height: 1080.0,
- },
- |m| Rect {
- x: m.screen.left as f32,
- y: m.screen.top as f32,
- width: (m.screen.right - m.screen.left) as f32,
- height: (m.screen.bottom - m.screen.top) as f32,
- },
- );
- let scale = self.dock_monitor().map_or(1.0, |m| m.scale);
- let theme = Theme::for_system(uses_light_theme(), transparency_enabled());
- let _ = notification_banner::NotificationBannerView::ensure_or_create(
- &self.gfx, pos, work_area, scale, theme,
- );
- let _ =
- notification_banner::NotificationBannerView::sync_queue(&self.gfx, &self.notifications);
- }
-
- pub fn on_notification(&mut self, payload: muelle_shell::dock_link::NotificationPayload) {
- if !self.config.notifications {
- return;
- }
- let muted = self.config.muted_apps.contains(&payload.app_id);
- if muted {
- return;
- }
-
- let duration_ms = (payload.duration_secs.max(1) as u64) * 1000;
- let dnd = self.config.notification_dnd;
-
- let pushed = self.notifications.push(
- payload.app_id.clone(),
- payload.app_name.clone(),
- payload.title.clone(),
- payload.body.clone(),
- payload.icon_path.clone(),
- None,
- duration_ms,
- dnd,
- false,
- );
-
- if self.config.notification_bounce && animations_enabled() {
- self.start_bounce(
- payload.app_id.clone(),
- Some(ATTENTION_HOPS * bounce::HOP_SECONDS),
- );
- }
-
- if self.config.notification_badges {
- let _ = self.sync_badge_visuals().and_then(|()| self.render());
- }
-
- if pushed.is_some() {
- self.show_active_banners();
- }
- }
-
- pub fn dismiss_notification(&mut self, id: u64) {
- self.notifications.dismiss(id);
- let _ =
- notification_banner::NotificationBannerView::sync_queue(&self.gfx, &self.notifications);
- }
-
- pub fn tick_notifications(&mut self, delta_ms: u64) {
- let expired = self.notifications.tick(delta_ms);
- if !expired.is_empty() {
- let _ = notification_banner::NotificationBannerView::sync_queue(
- &self.gfx,
- &self.notifications,
- );
- }
- }
-
- pub fn clear_notification_badge(&mut self, app_id: &str) {
- if self.notifications.badge_count(app_id) > 0 {
- self.notifications.clear_badge(app_id);
- let _ = self.sync_badge_visuals().and_then(|()| self.render());
- }
- }
-
fn sync_badge_visuals(&mut self) -> Result<()> {
if let Some(stage) = &mut self.stage {
- stage.scene.set_notification_counts(
- &self.gfx,
- self.entries.iter().map(|entry| {
- if self.config.notification_badges {
- entry
- .id
- .as_deref()
- .map_or(0, |id| self.notifications.badge_count(id))
- } else {
- 0
- }
- }),
- )?;
stage.scene.set_attention(
&self.gfx,
self.entries.iter().map(|entry| {
self.attention_enabled
+ && self.config.notification_badges
&& entry_has_attention(&self.attention, &self.windows, entry)
}),
)?;
}
if let Some(view) = &mut self.group_view {
view.set_attention(&self.gfx, |id| {
- self.attention_enabled && app_has_attention(&self.attention, &self.windows, id)
+ self.attention_enabled
+ && self.config.notification_badges
+ && app_has_attention(&self.attention, &self.windows, id)
})?;
}
Ok(())
@@ -4649,16 +4537,16 @@ impl App {
fn dock_monitor(&self) -> Option<Monitor> {
self.dock_display
- .filter(|_| self.config.auto_hide)
+ .filter(|_| self.config.hides_automatically())
.and_then(monitor_at)
.or_else(primary_monitor)
}
fn apply_edge_settings(&mut self) {
- if !self.config.auto_hide {
+ if !self.config.hides_automatically() {
self.dock_display = None;
}
- let mut screens = if self.config.auto_hide {
+ let mut screens = if self.config.hides_automatically() {
monitor_rects()
} else {
Vec::new()
@@ -4687,7 +4575,7 @@ impl App {
fn edge_changed(&mut self) -> Result<()> {
// Explorer can recreate a secondary taskbar while the dock is running.
// Check on monitor entry so it is transparent before the edge dwell.
- if self.config.auto_hide
+ if self.config.hides_automatically()
&& self.taskbar_worker.is_none()
&& taskbar::needs_visibility_repair()
{
@@ -4697,7 +4585,11 @@ impl App {
let on_dock_edge = matches!(target, Some(EdgeTarget::Dock(screen))
if self.stage.as_ref().is_some_and(|stage| stage.key.screen == screen));
self.arm_edge_timer(wait);
- if !on_dock_edge && self.config.auto_hide && !self.hovering && self.slide.target == 0.0 {
+ if !on_dock_edge
+ && self.config.hides_automatically()
+ && !self.hovering
+ && self.slide.target == 0.0
+ {
// SAFETY: Existing hide timer on the dock input window.
unsafe {
SetTimer(Some(self.input), HIDE_TIMER, HIDE_DELAY_MS, None);
@@ -4742,7 +4634,7 @@ impl App {
let mouse_down = [VK_LBUTTON, VK_RBUTTON, VK_MBUTTON]
.into_iter()
.any(|key| unsafe { GetAsyncKeyState(i32::from(key.0)) < 0 });
- if !self.config.auto_hide
+ if !self.config.hides_automatically()
|| self.hovering
|| self.menu_open
|| self.press.is_some()
@@ -4830,6 +4722,37 @@ impl App {
}
}
+ fn update_smart_hiding(&mut self) -> Result<()> {
+ let front = tracker::foreground_window();
+ let covered = self.config.smart_hide
+ && self.windows.iter().any(|window| window.hwnd == front)
+ && self.stage.as_ref().is_some_and(|stage| {
+ tracker::screen_rect(front).is_some_and(|(rect, _)| {
+ rects_overlap(
+ stage.screen_rect(Rect {
+ x: 0.0,
+ y: 0.0,
+ width: stage.layout.width,
+ height: stage.layout.height,
+ }),
+ rect,
+ )
+ })
+ });
+ if covered != self.smart_hidden {
+ self.smart_hidden = covered;
+ if self.config.auto_hide || covered {
+ self.hide_if_unused()?;
+ } else {
+ self.slide.target = 0.0;
+ self.last_frame = Instant::now();
+ self.place_windows()?;
+ }
+ self.render()?;
+ }
+ Ok(())
+ }
+
fn update_fullscreen(&mut self) -> Result<()> {
// The window in front is where the user works: note where it is now.
let front = tracker::foreground_window();
@@ -4897,6 +4820,7 @@ impl App {
let _ = KillTimer(Some(self.input), FULLSCREEN_TIMER);
}
}
+ self.update_smart_hiding()?;
// Updating an app name can fail transiently; it must never prevent
// the dock or bar from returning after full-screen mode.
if let Err(error) = self.update_menu_bar_app() {
@@ -4908,10 +4832,6 @@ impl App {
fn on_foreground_changed(&mut self) -> Result<()> {
self.close_preview();
let foreground = tracker::foreground_window();
- if let Some(window) = self.windows.iter().find(|w| w.hwnd == foreground) {
- let app_id = window.app_id.clone();
- self.clear_notification_badge(&app_id);
- }
self.flights.retain(|flight| flight.is_current(foreground));
// The app roster can stay identical while its windows change z-order.
// Refresh their order so the next dock activation selects the actual
@@ -5580,6 +5500,19 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) ->
unsafe { SetTimer(Some(hwnd), BIN_TIMER, BIN_DELAY_MS, None) };
}
WM_SETTINGCHANGE if w.0 == SPI_SETWORKAREA => {}
+ WM_DWMCOLORIZATIONCOLORCHANGED | WM_THEMECHANGED => {
+ with_app("material del sistema", |app| {
+ app.stage = None;
+ if let Some(bar) = &mut app.menubar {
+ bar.invalidate_material();
+ }
+ Ok(())
+ });
+ // Reuse the deferred refresh so DWM can finish changing its backdrop.
+ unsafe {
+ SetTimer(Some(hwnd), REFRESH_TIMER, REFRESH_DELAY_MS, None);
+ }
+ }
WM_SETTINGCHANGE | WM_DISPLAYCHANGE | WM_DPICHANGED => {
if matches!(msg, WM_DISPLAYCHANGE | WM_DPICHANGED) {
with_app("pantalla de la mascota", |app| {
@@ -5717,28 +5650,7 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) ->
}
// A folder's submenu in the shortcuts folder's menu is about to open.
WM_INITMENUPOPUP if folder_menu::init_popup(HMENU(w.0 as *mut _)) => {}
- WM_COPYDATA => {
- let cds =
- unsafe { &*(l.0 as *const windows::Win32::System::DataExchange::COPYDATASTRUCT) };
- if cds.dwData == muelle_shell::dock_link::NOTIFY_DATA_TAG && cds.cbData > 0 {
- let bytes = unsafe {
- std::slice::from_raw_parts(cds.lpData as *const u8, cds.cbData as usize)
- };
- if let Some(payload) = std::str::from_utf8(bytes)
- .ok()
- .and_then(muelle_shell::dock_link::NotificationPayload::decode)
- {
- with_app("notificación", |app| {
- app.on_notification(payload);
- Ok(())
- });
- return LRESULT(1);
- }
- }
- }
WM_DESTROY => {
- notification_banner::NotificationBannerView::hide();
- muelle_shell::system::set_windows_toasts_enabled(true);
unsafe { PostQuitMessage(0) };
}
_ if SHELL_HOOK.get() == Some(&msg) => match w.0 {
@@ -5898,6 +5810,7 @@ pub fn run() -> Result<()> {
taskbar_retry: false,
taskbar_attempts: 0,
fullscreen: false,
+ smart_hidden: false,
roster,
tracker: WindowTracker::default(),
windows: Vec::new(),
@@ -5935,7 +5848,6 @@ pub fn run() -> Result<()> {
pointed: false,
pending_drop: None,
bounces: HashMap::new(),
- notifications: muelle_core::notifications::NotificationQueue::new(),
minimized: Vec::new(),
thumbnails: Thumbnails::new(visual),
flights: Vec::new(),
@@ -6050,9 +5962,6 @@ pub fn run() -> Result<()> {
DROP_WINDOW.store(input.0 as isize, Ordering::Relaxed);
app.schedule_update();
- if app.config.notifications {
- muelle_shell::system::set_windows_toasts_enabled(false);
- }
APP.set(Some(app));
}
@@ -6086,7 +5995,6 @@ pub fn run() -> Result<()> {
app.taskbar_worker.take()
})
});
- muelle_shell::system::set_windows_toasts_enabled(true);
APP.set(None);
// SAFETY: Balances `OleInitialize` above, on the same thread.
unsafe { OleUninitialize() };
@@ -6101,6 +6009,65 @@ pub fn run() -> Result<()> {
mod dock_preferences_tests {
use super::*;
+ #[test]
+ fn intelligent_hiding_requires_real_overlap_on_every_dock_edge() {
+ let screen = RECT {
+ left: -1600,
+ top: -200,
+ right: 0,
+ bottom: 800,
+ };
+ for dock in [
+ RECT {
+ left: -1200,
+ top: 710,
+ right: -400,
+ bottom: 790,
+ },
+ RECT {
+ left: -1590,
+ top: 0,
+ right: -1510,
+ bottom: 600,
+ },
+ RECT {
+ left: -90,
+ top: 0,
+ right: -10,
+ bottom: 600,
+ },
+ ] {
+ assert!(rects_overlap(dock, screen));
+ assert!(!rects_overlap(
+ dock,
+ RECT {
+ left: 10,
+ top: 0,
+ right: 810,
+ bottom: 700
+ }
+ ));
+ assert!(!rects_overlap(
+ dock,
+ RECT {
+ left: dock.right,
+ top: dock.top,
+ right: dock.right + 10,
+ bottom: dock.bottom
+ }
+ ));
+ assert!(!rects_overlap(
+ dock,
+ RECT {
+ left: dock.left + 1,
+ right: dock.left + 1,
+ top: dock.top,
+ bottom: dock.bottom
+ }
+ ));
+ }
+ }
+
#[test]
fn removing_fixed_shortcuts_preserves_folders_pins_and_other_preferences() -> Result<()> {
struct Fixture(std::path::PathBuf);
@@ -6117,7 +6084,7 @@ mod dock_preferences_tests {
let initial = Config {
pinned: vec!["editor".into()],
shortcuts_folder: Some("C:\\Projects".into()),
- notification_dnd: true,
+ notification_badges: false,
..Config::default()
};
muelle_config::save(&file.0, &initial)?;
@@ -6129,7 +6096,7 @@ mod dock_preferences_tests {
assert!(!saved.show_downloads && !saved.show_trash && !saved.show_start);
assert_eq!(saved.pinned, initial.pinned);
assert_eq!(saved.shortcuts_folder, initial.shortcuts_folder);
- assert!(saved.notification_dnd);
+ assert!(!saved.notification_badges);
let before = std::fs::read(&file.0)?;
assert!(hide_fixed_item(&file.0, Role::App).is_err());
assert_eq!(std::fs::read(&file.0)?, before);
diff --git a/apps/dock/src/gfx.rs b/apps/dock/src/gfx.rs
index ee09743..daae980 100644
--- a/apps/dock/src/gfx.rs
+++ b/apps/dock/src/gfx.rs
@@ -39,12 +39,11 @@ use windows::{
},
DirectWrite::{
DWRITE_FACTORY_TYPE_SHARED, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL,
- DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_FONT_WEIGHT_NORMAL,
- DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_MEASURING_MODE_NATURAL,
- DWRITE_PARAGRAPH_ALIGNMENT_CENTER, DWRITE_TEXT_ALIGNMENT_CENTER,
- DWRITE_TEXT_METRICS, DWRITE_TRIMMING, DWRITE_TRIMMING_GRANULARITY_CHARACTER,
- DWRITE_WORD_WRAPPING_NO_WRAP, DWriteCreateFactory, IDWriteFactory,
- IDWriteTextLayout,
+ DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_WEIGHT_SEMI_BOLD,
+ DWRITE_MEASURING_MODE_NATURAL, DWRITE_PARAGRAPH_ALIGNMENT_CENTER,
+ DWRITE_TEXT_ALIGNMENT_CENTER, DWRITE_TEXT_METRICS, DWRITE_TRIMMING,
+ DWRITE_TRIMMING_GRANULARITY_CHARACTER, DWRITE_WORD_WRAPPING_NO_WRAP,
+ DWriteCreateFactory, IDWriteFactory, IDWriteTextLayout,
},
Dxgi::{Common::DXGI_FORMAT_B8G8R8A8_UNORM, IDXGIDevice},
},
@@ -828,191 +827,6 @@ impl Gfx {
})
}
- /// Red notification count badge (macOS style), e.g. "1", "4", "99+".
- pub fn notification_badge_brush(&self, count: usize, scale: f32) -> Result<LabelBrush> {
- let text = if count > 99 {
- "99+".to_string()
- } else {
- count.to_string()
- };
- let font_size = 11.0 * scale;
- let pad_h = 6.0 * scale;
- let pad_v = 2.0 * scale;
-
- let utf16: Vec<u16> = text.encode_utf16().collect();
- let (layout, metrics) = unsafe {
- let format = self.dwrite.CreateTextFormat(
- text_font(),
- None,
- DWRITE_FONT_WEIGHT_BOLD,
- DWRITE_FONT_STYLE_NORMAL,
- DWRITE_FONT_STRETCH_NORMAL,
- font_size,
- w!(""),
- )?;
- let layout = self
- .dwrite
- .CreateTextLayout(&utf16, &format, 256.0, 128.0)?;
- let mut metrics = DWRITE_TEXT_METRICS::default();
- layout.GetMetrics(&mut metrics)?;
- (layout, metrics)
- };
-
- let diameter = (metrics.height + 2.0 * pad_v).max(18.0 * scale).ceil();
- let width = (metrics.width + 2.0 * pad_h).max(diameter).ceil();
- let height = diameter;
-
- let brush = self.draw(width as u32, height as u32, |dc| {
- let radius = height / 2.0;
- let body = D2D1_ROUNDED_RECT {
- rect: D2D_RECT_F {
- left: 0.0,
- top: 0.0,
- right: width,
- bottom: height,
- },
- radiusX: radius,
- radiusY: radius,
- };
- unsafe {
- // macOS traffic-light red badge with slight border for separation
- let bg_color = rgb(1.0, 0.23, 0.19, 1.0);
- let bg_brush = dc.CreateSolidColorBrush(&bg_color, None)?;
- dc.FillRoundedRectangle(&body, &bg_brush);
-
- let text_color = rgb(1.0, 1.0, 1.0, 1.0);
- let text_brush = dc.CreateSolidColorBrush(&text_color, None)?;
- let text_origin = Vector2 {
- X: ((width - metrics.width) / 2.0).floor(),
- Y: ((height - metrics.height) / 2.0).floor(),
- };
- dc.DrawTextLayout(
- text_origin,
- &layout,
- &text_brush,
- D2D1_DRAW_TEXT_OPTIONS_NONE,
- );
- }
- Ok(())
- })?;
-
- Ok(LabelBrush {
- brush,
- width,
- height,
- })
- }
-
- /// A glass notification card with title, body, and rounded corners.
- pub fn notification_banner_brush(
- &self,
- title: &str,
- body: &str,
- width: f32,
- height: f32,
- scale: f32,
- light: bool,
- ) -> Result<CompositionSurfaceBrush> {
- let title_utf16: Vec<u16> = title.encode_utf16().collect();
- let body_utf16: Vec<u16> = body.encode_utf16().collect();
- let avail_w = (width - 52.0 * scale).max(50.0);
-
- let (title_layout, body_layout) = unsafe {
- let t_format = self.dwrite.CreateTextFormat(
- text_font(),
- None,
- DWRITE_FONT_WEIGHT_BOLD,
- DWRITE_FONT_STYLE_NORMAL,
- DWRITE_FONT_STRETCH_NORMAL,
- 13.0 * scale,
- w!(""),
- )?;
- let t_layout =
- self.dwrite
- .CreateTextLayout(&title_utf16, &t_format, avail_w, 24.0 * scale)?;
-
- let b_format = self.dwrite.CreateTextFormat(
- text_font(),
- None,
- DWRITE_FONT_WEIGHT_NORMAL,
- DWRITE_FONT_STYLE_NORMAL,
- DWRITE_FONT_STRETCH_NORMAL,
- 11.5 * scale,
- w!(""),
- )?;
- let b_layout =
- self.dwrite
- .CreateTextLayout(&body_utf16, &b_format, avail_w, 32.0 * scale)?;
-
- (t_layout, b_layout)
- };
-
- self.draw(width as u32, height as u32, |dc| {
- let rounded = D2D1_ROUNDED_RECT {
- rect: D2D_RECT_F {
- left: 0.0,
- top: 0.0,
- right: width,
- bottom: height,
- },
- radiusX: 14.0 * scale,
- radiusY: 14.0 * scale,
- };
- unsafe {
- let fill_color = if light {
- rgb(0.97, 0.97, 0.98, 0.94)
- } else {
- rgb(0.12, 0.12, 0.14, 0.92)
- };
- let brush = dc.CreateSolidColorBrush(&fill_color, None)?;
- dc.FillRoundedRectangle(&rounded, &brush);
-
- let border_color = if light {
- rgb(0.0, 0.0, 0.0, 0.08)
- } else {
- rgb(1.0, 1.0, 1.0, 0.12)
- };
- let border_brush = dc.CreateSolidColorBrush(&border_color, None)?;
- dc.DrawRoundedRectangle(&rounded, &border_brush, 1.0, None);
-
- let title_color = if light {
- rgb(0.08, 0.08, 0.09, 0.95)
- } else {
- rgb(0.95, 0.95, 0.97, 0.98)
- };
- let title_brush = dc.CreateSolidColorBrush(&title_color, None)?;
- dc.DrawTextLayout(
- Vector2 {
- X: 16.0 * scale,
- Y: 12.0 * scale,
- },
- &title_layout,
- &title_brush,
- D2D1_DRAW_TEXT_OPTIONS_NONE,
- );
-
- let body_color = if light {
- rgb(0.35, 0.35, 0.38, 0.90)
- } else {
- rgb(0.72, 0.72, 0.75, 0.90)
- };
- let body_brush = dc.CreateSolidColorBrush(&body_color, None)?;
- dc.DrawTextLayout(
- Vector2 {
- X: 16.0 * scale,
- Y: 34.0 * scale,
- },
- &body_layout,
- &body_brush,
- D2D1_DRAW_TEXT_OPTIONS_NONE,
- );
- }
- Ok(())
- })
- }
-
- /// Start tile: a 3x3 grid of rounded squares on a blue gradient, in the
- /// style of the other dock icons (no Windows logo: it is a trademark).
pub fn start_brush(&self, side: u32) -> Result<CompositionSurfaceBrush> {
let size = side as f32;
self.draw(side, side, |dc| {
diff --git a/apps/dock/src/main.rs b/apps/dock/src/main.rs
index be31143..a3049ef 100644
--- a/apps/dock/src/main.rs
+++ b/apps/dock/src/main.rs
@@ -26,7 +26,6 @@ mod media;
mod menu;
mod menubar;
mod multi_window_view;
-mod notification_banner;
mod recovery;
mod scene;
mod shell_work;
@@ -89,65 +88,7 @@ fn main() -> Result<()> {
[accessories::FLAG, visibility] => accessories::worker_main(Some(visibility)),
[accessories::USB_FLAG] => accessories::usb_worker_main(),
[shell_work::FLAG] => shell_work::worker_main(),
- ["notify", rest @ ..] | ["--notify", rest @ ..] => handle_notify_cli(rest),
- _ => bail!("uso: muelle [--quit | --restore | --autostart on|off | notify]"),
- }
-}
-
-fn handle_notify_cli(args: &[&str]) -> Result<()> {
- let mut title = String::new();
- let mut body = String::new();
- let mut app = "Terminal".to_string();
- let mut icon: Option<String> = None;
- let mut duration_secs = 5u32;
-
- let mut i = 0;
- while i < args.len() {
- match args[i] {
- "--title" if i + 1 < args.len() => {
- title = args[i + 1].to_string();
- i += 2;
- }
- "--body" if i + 1 < args.len() => {
- body = args[i + 1].to_string();
- i += 2;
- }
- "--app" if i + 1 < args.len() => {
- app = args[i + 1].to_string();
- i += 2;
- }
- "--icon" if i + 1 < args.len() => {
- icon = Some(args[i + 1].to_string());
- i += 2;
- }
- "--duration" if i + 1 < args.len() => {
- duration_secs = args[i + 1].parse().unwrap_or(5);
- i += 2;
- }
- _ => i += 1,
- }
- }
-
- if title.is_empty() && body.is_empty() {
- bail!(
- "uso: muelle notify --title <título> --body <cuerpo> [--app <app>] [--icon <ruta>] [--duration <segundos>]"
- );
- }
-
- let payload = muelle_shell::dock_link::NotificationPayload {
- app_id: app.clone(),
- app_name: app,
- title,
- body,
- icon_path: icon,
- duration_secs,
- };
-
- if muelle_shell::dock_link::post_notification(&payload) {
- println!("Notificación enviada a Muelle.");
- Ok(())
- } else {
- bail!("No se pudo entregar la notificación: Muelle no está en ejecución.");
+ _ => bail!("uso: muelle [--quit | --restore | --autostart on|off]"),
}
}
diff --git a/apps/dock/src/menubar.rs b/apps/dock/src/menubar.rs
index 1043372..b0bcf8c 100644
--- a/apps/dock/src/menubar.rs
+++ b/apps/dock/src/menubar.rs
@@ -972,6 +972,7 @@ fn draw_usage_row(
} else {
let message = match usage.state {
State::Loading => text.usage_loading,
+ State::SignIn if provider == Provider::Claude => text.usage_claude_sign_in,
State::SignIn => text.usage_sign_in,
State::Ready | State::Unavailable => text.usage_unavailable,
};
@@ -1754,6 +1755,12 @@ impl MenuBar {
})
}
+ /// Discards cached material after a Windows theme/compositor change.
+ pub fn invalidate_material(&mut self) {
+ // The host backdrop can change while light/glass booleans stay equal.
+ self.look = None;
+ }
+
/// Redraws the bar if anything it shows has changed.
pub fn refresh(&mut self, gfx: &Gfx) -> Result<()> {
let Some(monitor) = system::primary_monitor() else {
@@ -4088,6 +4095,17 @@ 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;
+ // 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());
+ let previous_material = bar.surface.Children()?.First()?.Current()?;
+ bar.invalidate_material();
+ assert!(bar.look.is_none());
+ bar.apply_look(&gfx, look.clone())?;
+ assert_ne!(
+ bar.surface.Children()?.First()?.Current()?,
+ previous_material
+ );
bar.build(&gfx, &look)?;
assert!(
!bar.island_hits
diff --git a/apps/dock/src/notification_banner.rs b/apps/dock/src/notification_banner.rs
deleted file mode 100644
index 4626e74..0000000
--- a/apps/dock/src/notification_banner.rs
+++ /dev/null
@@ -1,485 +0,0 @@
-use std::cell::RefCell;
-
-use muelle_core::{
- layout::Rect,
- notifications::{
- BANNER_HEIGHT, BANNER_WIDTH, BannerPosition, NotificationQueue, banner_bounds,
- banner_close_button_bounds,
- },
-};
-use windows::{
- UI::Composition::{
- CompositionSurfaceBrush, ContainerVisual, Desktop::DesktopWindowTarget, SpriteVisual,
- },
- Win32::{
- Foundation::{HWND, LPARAM, LRESULT, POINT, RECT, WPARAM},
- System::{LibraryLoader::GetModuleHandleW, WinRT::Composition::ICompositorDesktopInterop},
- UI::{
- Input::KeyboardAndMouse::{TME_LEAVE, TRACKMOUSEEVENT, TrackMouseEvent},
- WindowsAndMessaging::{
- CreateWindowExW, DefWindowProcW, DestroyWindow, GetCursorPos, GetWindowRect,
- HWND_TOPMOST, IDC_ARROW, KillTimer, LoadCursorW, MA_NOACTIVATE, RegisterClassW,
- SWP_NOACTIVATE, SWP_SHOWWINDOW, SetTimer, SetWindowPos, WM_DESTROY, WM_LBUTTONUP,
- WM_MBUTTONUP, WM_MOUSEACTIVATE, WM_MOUSEMOVE, WM_TIMER, WNDCLASSW,
- WS_EX_NOACTIVATE, WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOOLWINDOW, WS_EX_TOPMOST,
- WS_POPUP,
- },
- },
- },
- core::{Interface, Result, w},
-};
-use windows_numerics::{Vector2, Vector3};
-
-use crate::{gfx::Gfx, scene::Theme};
-
-const WM_MOUSELEAVE: u32 = 0x02A3;
-const TICK_TIMER: usize = 1;
-const TICK_INTERVAL_MS: u32 = 100;
-
-thread_local! {
- static BANNER_VIEW: RefCell<Option<NotificationBannerView>> = const { RefCell::new(None) };
-}
-
-pub enum BannerAction {
- Activate(Option<isize>, String),
- Dismiss(u64),
-}
-
-struct BannerCardVisual {
- id: u64,
- target_hwnd: Option<isize>,
- app_id: String,
- root: ContainerVisual,
- close_btn: SpriteVisual,
- close_normal: CompositionSurfaceBrush,
- close_hover: CompositionSurfaceBrush,
-}
-
-pub struct NotificationBannerView {
- hwnd: HWND,
- _target: DesktopWindowTarget,
- root: ContainerVisual,
- cards: Vec<BannerCardVisual>,
- position: BannerPosition,
- work_area: Rect,
- scale: f32,
- theme: Theme,
- hovered_card: Option<usize>,
- hovered_close: Option<usize>,
-}
-
-impl NotificationBannerView {
- pub fn ensure_or_create(
- gfx: &Gfx,
- position: BannerPosition,
- work_area: Rect,
- scale: f32,
- theme: Theme,
- ) -> Result<()> {
- BANNER_VIEW.with(|cell| {
- let mut borrow = cell.borrow_mut();
- if borrow.is_none() {
- let view = Self::new(gfx, position, work_area, scale, theme)?;
- *borrow = Some(view);
- } else if let Some(view) = borrow.as_mut() {
- view.position = position;
- view.work_area = work_area;
- view.scale = scale;
- view.theme = theme;
- }
- Ok(())
- })
- }
-
- fn new(
- gfx: &Gfx,
- position: BannerPosition,
- work_area: Rect,
- scale: f32,
- theme: Theme,
- ) -> Result<Self> {
- let hwnd = unsafe {
- let instance = GetModuleHandleW(None)?;
- let class = w!("MuelleNotificationBanner");
- RegisterClassW(&WNDCLASSW {
- lpfnWndProc: Some(banner_window_proc),
- hInstance: instance.into(),
- hCursor: LoadCursorW(None, IDC_ARROW)?,
- lpszClassName: class,
- ..Default::default()
- });
-
- CreateWindowExW(
- WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP,
- class,
- w!("Muelle Notification Banner"),
- WS_POPUP,
- 0,
- 0,
- 0,
- 0,
- None,
- None,
- Some(instance.into()),
- None,
- )?
- };
-
- let target = unsafe {
- gfx.compositor
- .cast::<ICompositorDesktopInterop>()?
- .CreateDesktopWindowTarget(hwnd, true)?
- };
- let root = gfx.compositor.CreateContainerVisual()?;
- target.SetRoot(&root)?;
-
- unsafe {
- SetTimer(Some(hwnd), TICK_TIMER, TICK_INTERVAL_MS, None);
- }
-
- Ok(Self {
- hwnd,
- _target: target,
- root,
- cards: Vec::new(),
- position,
- work_area,
- scale,
- theme,
- hovered_card: None,
- hovered_close: None,
- })
- }
-
- pub fn sync_queue(gfx: &Gfx, queue: &NotificationQueue) -> Result<()> {
- BANNER_VIEW.with(|cell| {
- let mut borrow = cell.borrow_mut();
- if let Some(view) = borrow.as_mut() {
- view.rebuild(gfx, queue)?;
- }
- Ok(())
- })
- }
-
- pub fn hide() {
- BANNER_VIEW.with(|cell| {
- let mut borrow = cell.borrow_mut();
- if let Some(view) = borrow.take() {
- unsafe {
- KillTimer(Some(view.hwnd), TICK_TIMER).ok();
- DestroyWindow(view.hwnd).ok();
- }
- }
- });
- }
-
- fn rebuild(&mut self, gfx: &Gfx, queue: &NotificationQueue) -> Result<()> {
- let items = queue.visible_items();
- if items.is_empty() {
- self.root.Children()?.RemoveAll()?;
- self.cards.clear();
- unsafe {
- SetWindowPos(self.hwnd, Some(HWND_TOPMOST), 0, 0, 0, 0, SWP_NOACTIVATE).ok();
- }
- return Ok(());
- }
-
- let first_rect = banner_bounds(0, self.position, self.work_area, self.scale);
- let last_rect = banner_bounds(items.len() - 1, self.position, self.work_area, self.scale);
-
- let min_x = first_rect.x.min(last_rect.x) as i32;
- let min_y = first_rect.y.min(last_rect.y) as i32;
- let max_x = (first_rect.x + first_rect.width).max(last_rect.x + last_rect.width) as i32;
- let max_y = (first_rect.y + first_rect.height).max(last_rect.y + last_rect.height) as i32;
-
- unsafe {
- SetWindowPos(
- self.hwnd,
- Some(HWND_TOPMOST),
- min_x,
- min_y,
- max_x - min_x,
- max_y - min_y,
- SWP_NOACTIVATE | SWP_SHOWWINDOW,
- )?;
- }
-
- self.root.Children()?.RemoveAll()?;
- self.cards.clear();
-
- let c = &gfx.compositor;
-
- for (index, item) in items.iter().enumerate() {
- let rect = banner_bounds(index, self.position, self.work_area, self.scale);
- let local_x = rect.x - (min_x as f32);
- let local_y = rect.y - (min_y as f32);
-
- let card = c.CreateContainerVisual()?;
- card.SetOffset(Vector3 {
- X: local_x,
- Y: local_y,
- Z: 0.0,
- })?;
- card.SetSize(Vector2 {
- X: rect.width,
- Y: rect.height,
- })?;
-
- // Render glass card brush with title and body
- let banner_brush = gfx
- .notification_banner_brush(
- &item.title,
- &item.body,
- rect.width,
- rect.height,
- self.scale,
- self.theme.light,
- )
- .map_err(|e| {
- windows::core::Error::new(windows::core::HRESULT(-1), e.to_string())
- })?;
-
- let bg_visual = c.CreateSpriteVisual()?;
- bg_visual.SetSize(Vector2 {
- X: rect.width,
- Y: rect.height,
- })?;
- bg_visual.SetBrush(&banner_brush)?;
- card.Children()?.InsertAtBottom(&bg_visual)?;
-
- // Close button ("✕") in top-right corner
- let btn_bounds = banner_close_button_bounds(rect, self.scale);
- let btn_side = btn_bounds.width as u32;
- let close_normal = gfx
- .close_button_brush(btn_side, false, self.theme.light)
- .map_err(|e| {
- windows::core::Error::new(windows::core::HRESULT(-1), e.to_string())
- })?;
- let close_hover = gfx
- .close_button_brush(btn_side, true, self.theme.light)
- .map_err(|e| {
- windows::core::Error::new(windows::core::HRESULT(-1), e.to_string())
- })?;
-
- let close_btn = c.CreateSpriteVisual()?;
- close_btn.SetBrush(&close_normal)?;
- close_btn.SetSize(Vector2 {
- X: btn_bounds.width,
- Y: btn_bounds.height,
- })?;
- close_btn.SetOffset(Vector3 {
- X: btn_bounds.x,
- Y: btn_bounds.y,
- Z: 0.0,
- })?;
- card.Children()?.InsertAtTop(&close_btn)?;
-
- self.root.Children()?.InsertAtTop(&card)?;
-
- self.cards.push(BannerCardVisual {
- id: item.id,
- target_hwnd: item.target_hwnd,
- app_id: item.app_id.clone(),
- root: card,
- close_btn,
- close_normal,
- close_hover,
- });
- }
-
- Ok(())
- }
-
- fn hit_test(&self, point: POINT) -> (Option<usize>, Option<usize>) {
- let width = BANNER_WIDTH * self.scale;
- let height = BANNER_HEIGHT * self.scale;
-
- for (index, card) in self.cards.iter().enumerate() {
- let offset = card.root.Offset().unwrap_or(Vector3::default());
- let card_rect = Rect {
- x: offset.X,
- y: offset.Y,
- width,
- height,
- };
-
- let pt_x = point.x as f32;
- let pt_y = point.y as f32;
-
- if pt_x >= card_rect.x
- && pt_x <= card_rect.x + card_rect.width
- && pt_y >= card_rect.y
- && pt_y <= card_rect.y + card_rect.height
- {
- let btn_rect = banner_close_button_bounds(card_rect, self.scale);
- let btn_local_x = pt_x - card_rect.x;
- let btn_local_y = pt_y - card_rect.y;
-
- if btn_local_x >= btn_rect.x
- && btn_local_x <= btn_rect.x + btn_rect.width
- && btn_local_y >= btn_rect.y
- && btn_local_y <= btn_rect.y + btn_rect.height
- {
- return (Some(index), Some(index));
- }
- return (Some(index), None);
- }
- }
- (None, None)
- }
-
- fn on_mouse_move(&mut self, point: POINT) -> Option<u64> {
- let (card_idx, close_idx) = self.hit_test(point);
-
- if self.hovered_close != close_idx {
- if let Some(card) = self.hovered_close.and_then(|prev| self.cards.get(prev)) {
- let _ = card.close_btn.SetBrush(&card.close_normal);
- }
- if let Some(card) = close_idx.and_then(|curr| self.cards.get(curr)) {
- let _ = card.close_btn.SetBrush(&card.close_hover);
- }
- self.hovered_close = close_idx;
- }
-
- self.hovered_card = card_idx;
- card_idx.and_then(|idx| self.cards.get(idx).map(|c| c.id))
- }
-
- fn on_click(&mut self, point: POINT) -> Option<BannerAction> {
- let (card_idx, close_idx) = self.hit_test(point);
- if let Some(card) = close_idx.and_then(|close| self.cards.get(close)) {
- Some(BannerAction::Dismiss(card.id))
- } else {
- card_idx
- .and_then(|card| self.cards.get(card))
- .map(|card_visual| {
- BannerAction::Activate(card_visual.target_hwnd, card_visual.app_id.clone())
- })
- }
- }
-}
-
-pub fn handle_mouse_move(point: POINT) -> Option<u64> {
- BANNER_VIEW.with(|cell| {
- let mut borrow = cell.borrow_mut();
- borrow.as_mut().and_then(|v| v.on_mouse_move(point))
- })
-}
-
-pub fn handle_click(point: POINT) -> Option<BannerAction> {
- BANNER_VIEW.with(|cell| {
- let mut borrow = cell.borrow_mut();
- borrow.as_mut().and_then(|v| v.on_click(point))
- })
-}
-
-unsafe extern "system" fn banner_window_proc(
- hwnd: HWND,
- msg: u32,
- w: WPARAM,
- l: LPARAM,
-) -> LRESULT {
- match msg {
- WM_MOUSEACTIVATE => LRESULT(MA_NOACTIVATE as isize),
- WM_MOUSEMOVE => {
- unsafe {
- let _ = TrackMouseEvent(&mut TRACKMOUSEEVENT {
- cbSize: size_of::<TRACKMOUSEEVENT>() as u32,
- dwFlags: TME_LEAVE,
- hwndTrack: hwnd,
- dwHoverTime: 0,
- });
- }
- let mut pt = POINT::default();
- unsafe {
- let _ = GetCursorPos(&mut pt);
- };
- let mut rect = RECT::default();
- unsafe {
- let _ = GetWindowRect(hwnd, &mut rect);
- };
- let local_pt = POINT {
- x: pt.x - rect.left,
- y: pt.y - rect.top,
- };
- handle_mouse_move(local_pt);
- LRESULT(0)
- }
- WM_MOUSELEAVE => {
- handle_mouse_move(POINT { x: -999, y: -999 });
- LRESULT(0)
- }
- WM_LBUTTONUP => {
- let mut pt = POINT::default();
- unsafe {
- let _ = GetCursorPos(&mut pt);
- };
- let mut rect = RECT::default();
- unsafe {
- let _ = GetWindowRect(hwnd, &mut rect);
- };
- let local_pt = POINT {
- x: pt.x - rect.left,
- y: pt.y - rect.top,
- };
- if let Some(action) = handle_click(local_pt) {
- match action {
- BannerAction::Dismiss(id) => {
- crate::app::with_app("dismiss banner", |app| {
- app.dismiss_notification(id);
- Ok(())
- });
- }
- BannerAction::Activate(target_hwnd, app_id) => {
- crate::app::with_app_then("activate notification", |app| {
- let outside = if let Some(h) = target_hwnd {
- app.activating(vec![h])
- } else {
- None
- };
- app.clear_notification_badge(&app_id);
- Ok(outside)
- });
- }
- }
- }
- LRESULT(0)
- }
- WM_MBUTTONUP => {
- let mut pt = POINT::default();
- unsafe {
- let _ = GetCursorPos(&mut pt);
- };
- let mut rect = RECT::default();
- unsafe {
- let _ = GetWindowRect(hwnd, &mut rect);
- };
- let local_pt = POINT {
- x: pt.x - rect.left,
- y: pt.y - rect.top,
- };
- if let Some(action) = handle_click(local_pt) {
- let id = match action {
- BannerAction::Dismiss(id) => id,
- BannerAction::Activate(_, _) => 0,
- };
- if id != 0 {
- crate::app::with_app("middle click dismiss banner", |app| {
- app.dismiss_notification(id);
- Ok(())
- });
- }
- }
- LRESULT(0)
- }
- WM_TIMER if w.0 == TICK_TIMER => {
- crate::app::with_app("tick notifications", |app| {
- app.tick_notifications(TICK_INTERVAL_MS as u64);
- Ok(())
- });
- LRESULT(0)
- }
- WM_DESTROY => LRESULT(0),
- _ => unsafe { DefWindowProcW(hwnd, msg, w, l) },
- }
-}
diff --git a/apps/dock/src/scene.rs b/apps/dock/src/scene.rs
index 73080d2..382ccee 100644
--- a/apps/dock/src/scene.rs
+++ b/apps/dock/src/scene.rs
@@ -321,115 +321,6 @@ mod attention_tests {
}
}
- #[test]
- #[ignore = "Requires Windows desktop composition; creates no visible window"]
- fn notification_count_replaces_attention_and_updates_without_rebuilding() -> Result<()> {
- use anyhow::Context;
- use windows::Win32::System::WinRT::{
- CreateDispatcherQueueController, DQTAT_COM_STA, DQTYPE_THREAD_CURRENT,
- DispatcherQueueOptions,
- };
- let _queue = unsafe {
- CreateDispatcherQueueController(DispatcherQueueOptions {
- dwSize: size_of::<DispatcherQueueOptions>() as u32,
- threadType: DQTYPE_THREAD_CURRENT,
- apartmentType: DQTAT_COM_STA,
- })?
- };
- let gfx = Gfx::new()?;
- for scale in [1.0, 1.25, 1.5, 2.0] {
- for light in [false, true] {
- let layout = layout(
- &[ItemKind::Icon, ItemKind::Icon],
- &Metrics::DEFAULT.scaled(scale),
- );
- let mut scene = Scene::build(
- &gfx,
- &SceneInput {
- layout: &layout,
- contents: &[SlotContent::default(); 2],
- theme: Theme::for_system(light, true),
- scale,
- frame: DockFrame::new(DockEdge::Bottom, (0.0, 0.0), layout.height),
- remove_label: None,
- },
- )?;
- let root = scene.root.clone();
- scene.set_attention(&gfx, [true, true].into_iter())?;
- let attention = scene.attention[0]
- .as_ref()
- .context("attention")?
- .visual
- .clone();
- scene.set_notification_counts(&gfx, [1, 0].into_iter())?;
- scene.set_attention(&gfx, [true, true].into_iter())?;
- let state = magnify(
- &layout,
- 0.0,
- 0.0,
- &Magnifier {
- range: 144.0 * scale,
- max_scale: 1.6,
- },
- );
- scene.apply(&Frame {
- state: &state,
- hovered: None,
- lifts: &[0.0, 0.0],
- drag: None,
- target: None,
- slide: 0.0,
- snap: true,
- })?;
- assert!(!attention.IsVisible()?);
- assert!(
- scene.attention[1]
- .as_ref()
- .context("other app attention")?
- .visual
- .IsVisible()?
- );
- let first = scene.notify_badges[0]
- .as_ref()
- .context("unread count")?
- .visual
- .clone();
- assert!(first.IsVisible()?);
- scene.set_notification_counts(&gfx, [1, 0].into_iter())?;
- assert_eq!(
- scene.notify_badges[0]
- .as_ref()
- .context("unchanged count")?
- .visual,
- first
- );
- scene.set_notification_counts(&gfx, [2, 0].into_iter())?;
- assert_ne!(
- scene.notify_badges[0]
- .as_ref()
- .context("updated count")?
- .visual,
- first
- );
- scene.set_notification_counts(&gfx, [0, 0].into_iter())?;
- scene.set_attention(&gfx, [true, true].into_iter())?;
- assert!(scene.notify_badges[0].is_none());
- assert!(attention.IsVisible()?);
- scene.set_attention(&gfx, [false, true].into_iter())?;
- assert!(!attention.IsVisible()?);
- assert!(
- scene.attention[1]
- .as_ref()
- .context("unrelated attention")?
- .visual
- .IsVisible()?
- );
- assert_eq!(scene.root, root);
- }
- }
- Ok(())
- }
-
#[test]
#[ignore = "Requires Windows desktop composition; creates no visible window"]
fn native_attention_badges_reuse_visuals_follow_drag_and_hide_without_rebuilding() -> Result<()>
@@ -582,8 +473,6 @@ pub struct Scene {
raised: Cell<Option<usize>>,
slots: Vec<SpriteVisual>,
badges: Vec<Option<SpriteVisual>>,
- notify_badges: Vec<Option<Label>>,
- notify_counts: Vec<usize>,
attention: Vec<Option<AttentionBadge>>,
attention_theme: Theme,
scale: f32,
@@ -736,8 +625,6 @@ impl Scene {
raised: Cell::new(None),
slots,
badges,
- notify_badges: (0..layout.slots.len()).map(|_| None).collect(),
- notify_counts: vec![0; layout.slots.len()],
attention: (0..layout.slots.len()).map(|_| None).collect(),
attention_theme: theme,
scale,
@@ -747,55 +634,10 @@ impl Scene {
})
}
- /// Updates only changed counts. Notifications never rebuild the dock or
- /// close its window picker; unchanged counts allocate no graphics objects.
- pub fn set_notification_counts(
- &mut self,
- gfx: &Gfx,
- counts: impl Iterator<Item = usize>,
- ) -> Result<()> {
- for ((label, previous), count) in self
- .notify_badges
- .iter_mut()
- .zip(&mut self.notify_counts)
- .zip(counts)
- {
- let count = count.min(100); // The displayed label is capped at 99+.
- if *previous == count {
- continue;
- }
- let next = if count == 0 {
- None
- } else {
- Some(Label::new(
- &gfx.compositor,
- &gfx.notification_badge_brush(count, self.scale)?,
- )?)
- };
- let children = self.content.Children()?;
- if let Some(old) = label.as_ref() {
- children.Remove(&old.visual)?;
- }
- if let Some(next) = &next {
- children.InsertAtTop(&next.visual)?;
- }
- *label = next;
- *previous = count;
- }
- Ok(())
- }
-
/// Changes only badge visuals: notifications never rebuild the layout or
/// close an open window picker. Repeated events reuse the same visual.
pub fn set_attention(&mut self, gfx: &Gfx, pending: impl Iterator<Item = bool>) -> Result<()> {
- for ((notice, count), on) in self
- .attention
- .iter_mut()
- .zip(&self.notify_badges)
- .zip(pending)
- {
- // A real unread count takes precedence over the generic shell alert.
- let on = on && count.is_none();
+ for (notice, on) in self.attention.iter_mut().zip(pending) {
if on && notice.is_none() {
let badge = AttentionBadge::new(gfx, self.attention_theme)?;
self.content.Children()?.InsertAtTop(&badge.visual)?;
@@ -898,13 +740,6 @@ impl Scene {
fit(y + height - side * BADGE_INSIDE),
))?;
}
- if let Some(Some(nb)) = self.notify_badges.get(index) {
- nb.visual.SetIsVisible(dragged.is_none())?;
- nb.visual.SetOffset(v3(
- fit(x + width - nb.width * 0.7),
- fit(y - nb.height * 0.25),
- ))?;
- }
if let Some(Some(notice)) = self.attention.get(index) {
notice.place(
Rect {
diff --git a/apps/dock/src/strings.rs b/apps/dock/src/strings.rs
index 75884f2..34c2e53 100644
--- a/apps/dock/src/strings.rs
+++ b/apps/dock/src/strings.rs
@@ -32,6 +32,7 @@ pub struct Strings {
pub usage_refresh: &'static str,
pub usage_refreshing: &'static str,
pub usage_sign_in: &'static str,
+ pub usage_claude_sign_in: &'static str,
pub usage_unavailable: &'static str,
pub usage_loading: &'static str,
pub usage_stale: &'static str,
@@ -85,6 +86,7 @@ const ES: Strings = Strings {
usage_refresh: "Actualizar",
usage_refreshing: "Actualizando…",
usage_sign_in: "Inicia sesión en el cliente",
+ usage_claude_sign_in: "Inicia sesión en Claude Code (claude auth login)",
usage_unavailable: "No disponible",
usage_loading: "Cargando…",
usage_stale: "Sin actualizar",
@@ -131,6 +133,7 @@ const EN: Strings = Strings {
usage_refresh: "Refresh",
usage_refreshing: "Refreshing…",
usage_sign_in: "Sign in to the client",
+ usage_claude_sign_in: "Sign in to Claude Code (claude auth login)",
usage_unavailable: "Unavailable",
usage_loading: "Loading…",
usage_stale: "Not updated",
@@ -177,6 +180,7 @@ const FR: Strings = Strings {
usage_refresh: "Actualiser",
usage_refreshing: "Actualisation…",
usage_sign_in: "Se connecter dans le client",
+ usage_claude_sign_in: "Connectez Claude Code (claude auth login)",
usage_unavailable: "Indisponible",
usage_loading: "Chargement…",
usage_stale: "Non actualisé",
diff --git a/apps/dock/src/usage.rs b/apps/dock/src/usage.rs
index 3c5492a..8b4188f 100644
--- a/apps/dock/src/usage.rs
+++ b/apps/dock/src/usage.rs
@@ -192,7 +192,12 @@ pub fn active_providers() -> ActiveProviders {
.unwrap_or(entry.szExeFile.len());
let name = String::from_utf16_lossy(&entry.szExeFile[..name_len]);
match name.to_ascii_lowercase().as_str() {
- "claude.exe" => active.0[Provider::Claude as usize] = true,
+ "claude.exe" => {
+ if !active.has(Provider::Claude) {
+ active.0[Provider::Claude as usize] =
+ claude_process_in_use(entry.th32ProcessID);
+ }
+ }
"codex.exe" => active.0[Provider::Codex as usize] = true,
"opencode.exe" => {
active.0[Provider::OpenCode as usize] = true;
@@ -220,6 +225,114 @@ pub fn active_providers() -> ActiveProviders {
active
}
+fn claude_process_in_use(pid: u32) -> bool {
+ use windows::Win32::{
+ System::Threading::{
+ OpenProcess, PROCESS_NAME_WIN32, PROCESS_QUERY_LIMITED_INFORMATION,
+ QueryFullProcessImageNameW,
+ },
+ UI::WindowsAndMessaging::{
+ EnumWindows, GWL_EXSTYLE, GetWindowLongPtrW, GetWindowTextLengthW,
+ GetWindowThreadProcessId, IsWindowVisible, WS_EX_TOOLWINDOW,
+ },
+ };
+ use windows::core::{BOOL, PWSTR};
+ static IMAGES: std::sync::OnceLock<Mutex<std::collections::HashMap<PathBuf, bool>>> =
+ std::sync::OnceLock::new();
+ let path = unsafe {
+ OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid)
+ .ok()
+ .and_then(|handle| {
+ let mut buffer = [0u16; 1024];
+ let mut length = buffer.len() as u32;
+ let result = QueryFullProcessImageNameW(
+ handle,
+ PROCESS_NAME_WIN32,
+ PWSTR(buffer.as_mut_ptr()),
+ &mut length,
+ );
+ let _ = CloseHandle(handle);
+ result
+ .ok()
+ .map(|()| PathBuf::from(String::from_utf16_lossy(&buffer[..length as usize])))
+ })
+ };
+ if let Some(path) = path {
+ let cache = IMAGES.get_or_init(Default::default);
+ let cached = cache
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .get(&path)
+ .copied();
+ let console = cached.unwrap_or_else(|| {
+ // The CLI and Desktop share a filename. Their PE subsystem reliably
+ // distinguishes a console client from Electron, independent of install path.
+ let Some(console) = console_image(&path) else {
+ return false;
+ };
+ let mut cache = cache
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ if cache.len() >= 32 {
+ cache.clear();
+ }
+ cache.insert(path, console);
+ console
+ });
+ if console {
+ return true;
+ }
+ }
+ // Desktop is in use only while it owns an application window (minimized
+ // windows count). Background updaters/renderers do not qualify.
+ struct Visible {
+ pid: u32,
+ found: bool,
+ }
+ unsafe extern "system" fn find(hwnd: HWND, data: LPARAM) -> BOOL {
+ let state = unsafe { &mut *(data.0 as *mut Visible) };
+ let mut owner = 0;
+ unsafe {
+ GetWindowThreadProcessId(hwnd, Some(&mut owner));
+ }
+ if owner == state.pid
+ && unsafe { IsWindowVisible(hwnd) }.as_bool()
+ && unsafe { GetWindowLongPtrW(hwnd, GWL_EXSTYLE) } & WS_EX_TOOLWINDOW.0 as isize == 0
+ && unsafe { GetWindowTextLengthW(hwnd) } > 0
+ {
+ state.found = true;
+ return BOOL(0);
+ }
+ BOOL(1)
+ }
+ let mut state = Visible { pid, found: false };
+ // SAFETY: EnumWindows invokes this callback synchronously while `state` lives.
+ unsafe {
+ let _ = EnumWindows(Some(find), LPARAM((&raw mut state) as isize));
+ }
+ state.found
+}
+
+fn console_image(path: &Path) -> Option<bool> {
+ let mut file = fs::File::open(path).ok()?;
+ let mut dos = [0u8; 64];
+ file.read_exact(&mut dos).ok()?;
+ if &dos[..2] != b"MZ" {
+ return None;
+ }
+ let offset = u32::from_le_bytes(dos[60..64].try_into().ok()?);
+ if !(64..=1024 * 1024).contains(&offset) {
+ return None;
+ }
+ file.seek(SeekFrom::Start(u64::from(offset))).ok()?;
+ let mut pe = [0u8; 94];
+ file.read_exact(&mut pe).ok()?;
+ if &pe[..4] != b"PE\0\0" {
+ return None;
+ }
+ Some(u16::from_le_bytes([pe[92], pe[93]]) == 3)
+}
+
pub fn logo(provider: Provider) -> Option<&'static IconImage> {
static CLAUDE: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
static CODEX: std::sync::OnceLock<Option<IconImage>> = std::sync::OnceLock::new();
@@ -483,7 +596,12 @@ fn fetch_claude(client: &Client) -> ProviderUsage {
let Ok(value) = serde_json::from_str::<Value>(&body) else {
return unavailable();
};
- ready(parse_claude(&value))
+ let windows = parse_claude(&value);
+ if windows.is_empty() {
+ unavailable()
+ } else {
+ ready(windows)
+ }
}
fn fetch_codex(client: &Client) -> ProviderUsage {
@@ -1282,6 +1400,42 @@ mod tests {
use super::*;
use serde_json::json;
+ #[test]
+ fn claude_native_console_and_desktop_images_are_distinguished_without_path_guesses()
+ -> anyhow::Result<()> {
+ let path = env::temp_dir().join(format!("muelle-claude-pe-{}.exe", std::process::id()));
+ struct Fixture(PathBuf);
+ impl Drop for Fixture {
+ fn drop(&mut self) {
+ let _ = fs::remove_file(&self.0);
+ }
+ }
+ let file = Fixture(path);
+ let mut image = vec![0u8; 64 + 94];
+ image[..2].copy_from_slice(b"MZ");
+ image[60..64].copy_from_slice(&64u32.to_le_bytes());
+ image[64..68].copy_from_slice(b"PE\0\0");
+ for (subsystem, console) in [(2u16, false), (3, true)] {
+ image[156..158].copy_from_slice(&subsystem.to_le_bytes());
+ fs::write(&file.0, &image)?;
+ assert_eq!(console_image(&file.0), Some(console));
+ }
+ fs::write(&file.0, b"MZ")?;
+ assert_eq!(console_image(&file.0), None);
+ Ok(())
+ }
+
+ #[test]
+ fn claude_real_quota_preserves_zero_and_reset_times() {
+ let windows = parse_claude(&json!({
+ "five_hour": {"utilization":0.0,"resets_at":"2026-11-23T03:00:00Z"},
+ "seven_day": {"utilization":32.0,"resets_at":"2026-11-29T03:00:00Z"}
+ }));
+ assert_eq!(windows.len(), 2);
+ assert_eq!(windows[0].used_percent, 0);
+ assert!(windows[0].resets_at.is_some());
+ }
+
#[test]
fn opencode_go_reads_official_absolute_resets_and_rejects_overflowing_legacy_dates() {
let windows = parse_opencode(&json!({"usage": {
diff --git a/apps/settings/src/App.tsx b/apps/settings/src/App.tsx
index 651a8ec..5c509b2 100644
--- a/apps/settings/src/App.tsx
+++ b/apps/settings/src/App.tsx
@@ -431,7 +431,10 @@ export function App() {
onChange={(autoHide) => update({ autoHide })}
/>
</Row>
- <SubRow label={t.dockAutoHideSpeed} open={config.autoHide}>
+ <Row label={t.smartHide} hint={t.smartHideHint}>
+ <Toggle label={t.smartHide} checked={config.smartHide ?? false} onChange={(smartHide) => update({ smartHide })} />
+ </Row>
+ <SubRow label={t.dockAutoHideSpeed} open={config.autoHide || (config.smartHide ?? false)}>
<Segmented<DockAutoHideSpeed>
label={t.dockAutoHideSpeed}
value={config.dockAutoHideSpeed ?? "normal"}
@@ -443,6 +446,12 @@ export function App() {
onChange={(dockAutoHideSpeed) => update({ dockAutoHideSpeed })}
/>
</SubRow>
+ <Row label={t.notificationBadges} hint={t.notificationBadgesHint}>
+ <Toggle label={t.notificationBadges} checked={config.notificationBadges} onChange={(notificationBadges) => update({ notificationBadges })} />
+ </Row>
+ <Row label={t.notificationBounce} hint={t.notificationBounceHint}>
+ <Toggle label={t.notificationBounce} checked={config.notificationBounce} onChange={(notificationBounce) => update({ notificationBounce })} />
+ </Row>
<Row icon={<SettingIcon name="bounce" />} label={t.bounceOnOpen}>
<Toggle
label={t.bounceOnOpen}
@@ -633,62 +642,6 @@ export function App() {
</Card>
)}
</>
- ) : section === "notifications" ? (
- <>
- <Card>
- <Row label={t.notificationsEnabled} hint={t.notificationsHint}>
- <Toggle
- label={t.notificationsEnabled}
- checked={config.notifications}
- onChange={(notifications) => update({ notifications })}
- />
- </Row>
- <SubRow label={t.notificationPosition} open={config.notifications}>
- <Segmented
- label={t.notificationPosition}
- value={config.notificationPosition}
- options={[
- { value: "top-right", label: t.notificationPositionTopRight },
- { value: "bottom-right", label: t.notificationPositionBottomRight },
- ]}
- onChange={(notificationPosition) => update({ notificationPosition })}
- />
- </SubRow>
- <SubRow label={t.notificationDuration} open={config.notifications}>
- <Slider
- label={t.notificationDuration}
- min={2}
- max={15}
- value={config.notificationDuration}
- unit="s"
- onChange={(notificationDuration) => update({ notificationDuration })}
- />
- </SubRow>
- </Card>
- <Card>
- <Row label={t.notificationBadges} hint={t.notificationBadgesHint}>
- <Toggle
- label={t.notificationBadges}
- checked={config.notificationBadges}
- onChange={(notificationBadges) => update({ notificationBadges })}
- />
- </Row>
- <Row label={t.notificationBounce} hint={t.notificationBounceHint}>
- <Toggle
- label={t.notificationBounce}
- checked={config.notificationBounce}
- onChange={(notificationBounce) => update({ notificationBounce })}
- />
- </Row>
- <Row label={t.notificationDnd} hint={t.notificationDndHint}>
- <Toggle
- label={t.notificationDnd}
- checked={config.notificationDnd}
- onChange={(notificationDnd) => update({ notificationDnd })}
- />
- </Row>
- </Card>
- </>
) : (
<>
<Card>
@@ -784,7 +737,7 @@ function updateHint(t: Texts, state: UpdateState, version: string): string {
}
}
-const SECTIONS: readonly SectionId[] = ["dock", "windows", "menubar", "notifications", "system"];
+const SECTIONS: readonly SectionId[] = ["dock", "windows", "menubar", "system"];
function sectionTitle(t: Texts, section: SectionId): string {
switch (section) {
@@ -794,8 +747,6 @@ function sectionTitle(t: Texts, section: SectionId): string {
return t.windows;
case "menubar":
return t.menuBar;
- case "notifications":
- return t.notifications;
case "system":
return t.system;
}
diff --git a/apps/settings/src/config.ts b/apps/settings/src/config.ts
index 95556f8..2ad7911 100644
--- a/apps/settings/src/config.ts
+++ b/apps/settings/src/config.ts
@@ -1,7 +1,6 @@
import { invoke } from "@tauri-apps/api/core";
export type Language = "auto" | "es" | "en" | "fr";
-export type NotificationPosition = "top-right" | "bottom-right";
export type IslandStyle = "notch" | "bubble";
export type GenieSpeed = "normal" | "fast" | "faster";
export type DockPosition = "left" | "bottom" | "right";
@@ -14,6 +13,7 @@ export interface Config {
pinned: string[];
recent: string[];
autoHide: boolean;
+ smartHide: boolean;
iconSize: number;
magnification: boolean;
magnifiedSize: number;
@@ -43,13 +43,8 @@ export interface Config {
showIndicators: boolean;
showRecents: boolean;
bounceOnOpen: boolean;
- notifications: boolean;
- notificationPosition: NotificationPosition;
- notificationDuration: number;
notificationBadges: boolean;
notificationBounce: boolean;
- notificationDnd: boolean;
- mutedApps: string[];
mascot: boolean;
checkUpdates: boolean;
autoUpdate: boolean;
diff --git a/apps/settings/src/i18n/en.json b/apps/settings/src/i18n/en.json
index fb72ed5..2319a4c 100644
--- a/apps/settings/src/i18n/en.json
+++ b/apps/settings/src/i18n/en.json
@@ -116,21 +116,14 @@
"shortcutsFolderHint": "Open a folder's contents from the Dock.",
"shortcutsFolderChoose": "Choose…",
"shortcutsFolderRemove": "Remove",
- "notifications": "Notifications",
- "notificationsEnabled": "Show notifications",
- "notificationsHint": "Displays macOS-style glass notification banners for apps and alerts.",
- "notificationPosition": "Position",
- "notificationPositionTopRight": "Top right",
- "notificationPositionBottomRight": "Bottom right",
- "notificationDuration": "Banner duration",
- "notificationBadges": "Badge app icons",
- "notificationBadgesHint": "Show unread notification count badge on the Dock icon.",
+ "notificationBadges": "App attention indicator",
+ "notificationBadgesHint": "Show an indicator when Windows reports that an app needs attention.",
"notificationBounce": "Bounce icon on alert",
"notificationBounceHint": "Bounces the Dock icon when an app requests attention.",
- "notificationDnd": "Do Not Disturb",
- "notificationDndHint": "Silences notification banners while keeping Dock badges.",
"groupAppearance": "Appearance",
"githubTitle": "Muelle on GitHub",
"githubStar": "Support with a star",
- "githubError": "Could not open GitHub. Try again."
+ "githubError": "Could not open GitHub. Try again.",
+ "smartHide": "Intelligent hiding",
+ "smartHideHint": "Keep the Dock visible on the desktop; hide it when the active window overlaps it."
}
diff --git a/apps/settings/src/i18n/es.json b/apps/settings/src/i18n/es.json
index 29031bd..955d804 100644
--- a/apps/settings/src/i18n/es.json
+++ b/apps/settings/src/i18n/es.json
@@ -116,21 +116,14 @@
"shortcutsFolderHint": "Abre el contenido de una carpeta desde el Dock.",
"shortcutsFolderChoose": "Elegir…",
"shortcutsFolderRemove": "Quitar",
- "notifications": "Notificaciones",
- "notificationsEnabled": "Mostrar notificaciones",
- "notificationsHint": "Muestra alertas en banners de cristal estilo macOS para aplicaciones.",
- "notificationPosition": "Posición",
- "notificationPositionTopRight": "Superior derecha",
- "notificationPositionBottomRight": "Inferior derecha",
- "notificationDuration": "Duración del banner",
- "notificationBadges": "Insignias en los iconos",
- "notificationBadgesHint": "Muestra el contador de notificaciones pendientes en el icono del Dock.",
+ "notificationBadges": "Indicador de atención",
+ "notificationBadgesHint": "Muestra un indicador cuando Windows avisa de que una app necesita atención.",
"notificationBounce": "Animar icono al recibir alerta",
"notificationBounceHint": "Hace rebotar el icono en el Dock cuando la app solicita atención.",
- "notificationDnd": "No molestar",
- "notificationDndHint": "Silencia los banners de notificación manteniendo las insignias en el Dock.",
"groupAppearance": "Aspecto",
"githubTitle": "Muelle en GitHub",
"githubStar": "Apoya con una estrella",
- "githubError": "No se pudo abrir GitHub. Inténtalo otra vez."
+ "githubError": "No se pudo abrir GitHub. Inténtalo otra vez.",
+ "smartHide": "Ocultación inteligente",
+ "smartHideHint": "Mantiene el Dock visible en el escritorio y lo oculta si la ventana activa ocupa su espacio."
}
diff --git a/apps/settings/src/i18n/fr.json b/apps/settings/src/i18n/fr.json
index 2324161..76e60db 100644
--- a/apps/settings/src/i18n/fr.json
+++ b/apps/settings/src/i18n/fr.json
@@ -116,21 +116,14 @@
"shortcutsFolderHint": "Ouvrez le contenu d'un dossier depuis le Dock.",
"shortcutsFolderChoose": "Choisir…",
"shortcutsFolderRemove": "Retirer",
- "notifications": "Notifications",
- "notificationsEnabled": "Afficher les notifications",
- "notificationsHint": "Affiche des bannières de notification de style macOS pour les applications.",
- "notificationPosition": "Position",
- "notificationPositionTopRight": "En haut à droite",
- "notificationPositionBottomRight": "En bas à droite",
- "notificationDuration": "Durée de la bannière",
- "notificationBadges": "Badges sur les icônes",
- "notificationBadgesHint": "Affiche un badge de notifications non lues sur l'icône du Dock.",
+ "notificationBadges": "Indicateur d’attention",
+ "notificationBadgesHint": "Affiche un indicateur lorsque Windows signale une demande d’attention.",
"notificationBounce": "Animer l'icône lors d'une alerte",
"notificationBounceHint": "Fait rebondir l'icône dans le Dock lorsqu'une application demande de l'attention.",
- "notificationDnd": "Ne pas déranger",
- "notificationDndHint": "Désactive les bannières de notification tout en conservant les badges du Dock.",
"groupAppearance": "Apparence",
"githubTitle": "Muelle sur GitHub",
"githubStar": "Soutenir avec une étoile",
- "githubError": "Impossible d'ouvrir GitHub. Réessayez."
+ "githubError": "Impossible d'ouvrir GitHub. Réessayez.",
+ "smartHide": "Masquage intelligent",
+ "smartHideHint": "Garde le Dock visible sur le bureau et le masque si la fenêtre active le recouvre."
}
diff --git a/apps/settings/src/icons.tsx b/apps/settings/src/icons.tsx
index ec1a9d9..8b10062 100644
--- a/apps/settings/src/icons.tsx
+++ b/apps/settings/src/icons.tsx
@@ -6,13 +6,12 @@
import type { ReactNode } from "react";
-export type SectionId = "dock" | "windows" | "menubar" | "notifications" | "system";
+export type SectionId = "dock" | "windows" | "menubar" | "system";
const TILES: Record<SectionId, [string, string]> = {
dock: ["#4aa3ff", "#0a6cf0"],
windows: ["#b57bff", "#7d3ff0"],
menubar: ["#ff9f45", "#f0640a"],
- notifications: ["#ff453a", "#d70015"],
system: ["#a1a1a6", "#6e6e73"],
};
@@ -42,14 +41,6 @@ const GLYPHS: Record<SectionId, ReactNode> = {
<circle cx="16.8" cy="6.8" r="0.9" fill="#f0640a" />
</>
),
- // A notification banner card.
- notifications: (
- <>
- <rect x="4" y="6" width="16" height="12" rx="2" fill="#fff" opacity="0.55" />
- <rect x="4" y="6" width="16" height="4" rx="1.6" fill="#fff" />
- <circle cx="17" cy="8" r="1.5" fill="#d70015" />
- </>
- ),
// A gear.
system: (
<path
diff --git a/apps/settings/tests/app.test.mjs b/apps/settings/tests/app.test.mjs
index a7cc04e..c37fb64 100644
--- a/apps/settings/tests/app.test.mjs
+++ b/apps/settings/tests/app.test.mjs
@@ -25,15 +25,15 @@ const texts = Object.fromEntries(["en", "es", "fr"].map((language) => [
language, JSON.parse(readFileSync(path.join(source, "i18n", `${language}.json`), "utf8")),
]));
const base = {
- language: "en", menuBar: true, notifications: true, notificationDuration: 5,
- notificationPosition: "top-right", iconSize: 48, magnifiedSize: 77,
+ language: "en", menuBar: true, smartHide: false, notificationBadges: true, notificationBounce: true,
+ iconSize: 48, magnifiedSize: 77,
magnification: true, dockPosition: "bottom", genie: true, genieSpeed: "normal",
dockDensity: "normal", dockAutoHideSpeed: "normal", showStart: true,
showTrash: true, pinExplorer: true,
showDownloads: true,
menuBarIslandStyle: "notch", menuBarSearch: null, menuBarTaskView: null,
menuBarWidgets: null, menuBarBatteryPercent: null, checkUpdates: false,
- pinned: [], recent: [], mutedApps: [], shortcutsFolder: null,
+ pinned: [], recent: [], shortcutsFolder: null,
};
const settle = async () => { for (let i = 0; i < 12; i++) await Promise.resolve(); };
function* elements(node) {
@@ -65,7 +65,7 @@ function fixture(section = "menubar", config = {}, save = async () => {}) {
};
const nativeWindow = { onCloseRequested(callback) { close = callback; return Promise.resolve(() => {}); } };
const mocks = {
- "@tauri-apps/api/app": { getVersion: async () => "0.1.20" },
+ "@tauri-apps/api/app": { getVersion: async () => "0.1.21" },
"@tauri-apps/api/event": { listen: async () => () => {} },
"@tauri-apps/api/window": { getCurrentWindow: () => nativeWindow },
"@tauri-apps/api/core": { invoke: async (command, args) => {
@@ -112,10 +112,10 @@ function fixture(section = "menubar", config = {}, save = async () => {}) {
}
test("each section renders only its own controls, in every language and visibility state", () => {
- const markers = { dock: "size", windows: "genie", menubar: "menuBarShow", notifications: "notificationsEnabled", system: "autostart" };
- for (const language of Object.keys(texts)) for (const menuBar of [true, false]) for (const notifications of [true, false]) {
+ const markers = { dock: "size", windows: "genie", menubar: "menuBarShow", system: "autostart" };
+ for (const language of Object.keys(texts)) for (const menuBar of [true, false]) {
for (const section of Object.keys(markers)) {
- const view = fixture(section, { language, menuBar, notifications });
+ const view = fixture(section, { language, menuBar });
const body = view.body();
const html = renderToStaticMarkup(body);
assert.doesNotMatch(html, /section\s*===|\)\s*:\s*section/);
diff --git a/crates/muelle-config/src/lib.rs b/crates/muelle-config/src/lib.rs
index c68a879..88203ea 100644
--- a/crates/muelle-config/src/lib.rs
+++ b/crates/muelle-config/src/lib.rs
@@ -51,6 +51,8 @@ pub struct Config {
pub taskbar_pins: Option<Vec<String>>,
#[serde(alias = "auto_hide")]
pub auto_hide: bool,
+ /// Hide only when the foreground app overlaps the dock; leave desktop visible.
+ pub smart_hide: bool,
/// Icon side at rest, in logical pixels.
pub icon_size: u32,
pub magnification: bool,
@@ -123,28 +125,10 @@ pub struct Config {
pub shortcuts_folder: Option<String>,
/// Show a close button ("X") on hover in window preview cards.
pub show_preview_close_button: bool,
- /// Desktop notifications system.
- pub notifications: bool,
- /// Position of notification banners on screen.
- pub notification_position: NotificationPosition,
- /// Auto-dismiss banner duration in seconds.
- pub notification_duration: u32,
- /// Red count badge on app icon when notifications / attention are unread.
+ /// Indicator on app icons when Windows requests attention.
pub notification_badges: bool,
/// Icon bounce in dock when app requests attention.
pub notification_bounce: bool,
- /// Do Not Disturb / Focus mode: silences banners, keeps dock badges.
- pub notification_dnd: bool,
- /// List of app identifiers whose notifications are muted.
- pub muted_apps: Vec<String>,
-}
-
-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
-#[serde(rename_all = "kebab-case")]
-pub enum NotificationPosition {
- #[default]
- TopRight,
- BottomRight,
}
/// Pinned apps the user gathered in one dock icon by dropping one on
@@ -269,6 +253,11 @@ pub const ICON_SIZE_RANGE: (u32, u32) = (32, 96);
pub const MAX_MAGNIFIED_SIZE: u32 = 160;
impl Config {
+ /// Either policy needs a reveal strip and leaves maximized windows the full work area.
+ pub fn hides_automatically(&self) -> bool {
+ self.auto_hide || self.smart_hide
+ }
+
/// Brings out-of-range values (a hand-edited file) back into range.
#[must_use]
pub fn sanitized(mut self) -> Self {
@@ -280,7 +269,6 @@ impl Config {
.shortcuts_folder
.map(|folder| folder.trim().to_owned())
.filter(|folder| !folder.is_empty());
- self.notification_duration = self.notification_duration.clamp(1, 30);
self
}
@@ -304,6 +292,7 @@ impl Default for Config {
recent: Vec::new(),
taskbar_pins: None,
auto_hide: false,
+ smart_hide: false,
icon_size: 48,
magnification: true,
dock_position: DockPosition::Bottom,
@@ -338,13 +327,8 @@ impl Default for Config {
language: Language::Auto,
shortcuts_folder: None,
show_preview_close_button: true,
- notifications: true,
- notification_position: NotificationPosition::TopRight,
- notification_duration: 5,
notification_badges: true,
notification_bounce: true,
- notification_dnd: false,
- muted_apps: Vec::new(),
}
}
}
@@ -479,6 +463,31 @@ fn write_config(path: &Path, config: &Config) -> Result<(), ConfigError> {
mod tests {
use super::*;
+ #[test]
+ fn intelligent_hiding_defaults_off_and_retired_banner_preferences_are_ignored()
+ -> Result<(), serde_json::Error> {
+ let old: Config = serde_json::from_value(serde_json::json!({
+ "notifications": true, "notificationPosition": "top-right",
+ "notificationDuration": 5, "notificationDnd": true,
+ "notificationBadges": false, "autoHide": false
+ }))?;
+ assert!(!old.smart_hide && !old.hides_automatically());
+ assert!(!old.notification_badges);
+ let saved = serde_json::to_value(&old)?;
+ assert!(saved.get("notifications").is_none());
+ assert_eq!(saved.get("smartHide"), Some(&serde_json::json!(false)));
+ Ok(())
+ }
+
+ #[test]
+ fn explicitly_enabled_intelligent_hiding_survives_round_trip() -> Result<(), serde_json::Error>
+ {
+ let enabled: Config = serde_json::from_str(r#"{"smartHide":true,"autoHide":false}"#)?;
+ let restored: Config = serde_json::from_str(&serde_json::to_string(&enabled)?)?;
+ assert!(restored.smart_hide && restored.hides_automatically());
+ Ok(())
+ }
+
#[test]
fn older_configs_keep_the_original_dock_defaults() -> Result<(), serde_json::Error> {
let config: Config = serde_json::from_str(r#"{"iconSize":64}"#)?;
diff --git a/crates/muelle-core/src/lib.rs b/crates/muelle-core/src/lib.rs
index e025329..e263851 100644
--- a/crates/muelle-core/src/lib.rs
+++ b/crates/muelle-core/src/lib.rs
@@ -6,7 +6,6 @@ pub mod frame;
pub mod genie;
pub mod layout;
pub mod magnify;
-pub mod notifications;
pub mod preview;
pub mod roster;
pub mod spring;
diff --git a/crates/muelle-core/src/notifications.rs b/crates/muelle-core/src/notifications.rs
deleted file mode 100644
index 2af9881..0000000
--- a/crates/muelle-core/src/notifications.rs
+++ /dev/null
@@ -1,528 +0,0 @@
-use std::collections::HashMap;
-
-use crate::layout::Rect;
-
-/// Position of notification banners on the screen.
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
-pub enum BannerPosition {
- #[default]
- TopRight,
- BottomRight,
-}
-
-/// A single notification message. Content remains strictly in-memory.
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct NotificationItem {
- pub id: u64,
- pub app_id: String,
- pub app_name: String,
- pub title: String,
- pub body: String,
- pub icon_path: Option<String>,
- pub target_hwnd: Option<isize>,
- pub duration_ms: u64,
- pub elapsed_ms: u64,
- pub paused: bool,
-}
-
-impl NotificationItem {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- id: u64,
- app_id: String,
- app_name: String,
- title: String,
- body: String,
- icon_path: Option<String>,
- target_hwnd: Option<isize>,
- duration_ms: u64,
- ) -> Self {
- Self {
- id,
- app_id,
- app_name,
- title,
- body,
- icon_path,
- target_hwnd,
- duration_ms: duration_ms.max(1000),
- elapsed_ms: 0,
- paused: false,
- }
- }
-}
-
-/// Maximum number of banners shown simultaneously.
-pub const MAX_VISIBLE_BANNERS: usize = 3;
-
-/// Manages active notifications, stacking, auto-dismiss timers, and dock badges.
-#[derive(Debug, Default)]
-pub struct NotificationQueue {
- next_id: u64,
- items: Vec<NotificationItem>,
- hovered_id: Option<u64>,
- badges: HashMap<String, usize>,
-}
-
-impl NotificationQueue {
- pub fn new() -> Self {
- Self::default()
- }
-
- /// Allocates an ID and enqueues a notification.
- /// If `dnd` is active or the app is `muted`, banners are suppressed,
- /// but the app badge count is still incremented (unless muted).
- #[allow(clippy::too_many_arguments)]
- pub fn push(
- &mut self,
- app_id: String,
- app_name: String,
- title: String,
- body: String,
- icon_path: Option<String>,
- target_hwnd: Option<isize>,
- duration_ms: u64,
- dnd: bool,
- muted: bool,
- ) -> Option<u64> {
- if muted {
- return None;
- }
-
- // Increment dock badge count for the source app
- *self.badges.entry(app_id.clone()).or_insert(0) += 1;
-
- if dnd {
- return None;
- }
-
- self.next_id = self.next_id.wrapping_add(1);
- let id = self.next_id;
- let item = NotificationItem::new(
- id,
- app_id,
- app_name,
- title,
- body,
- icon_path,
- target_hwnd,
- duration_ms,
- );
- self.items.push(item);
- Some(id)
- }
-
- /// Advances timers for active notifications and returns IDs of expired ones.
- pub fn tick(&mut self, delta_ms: u64) -> Vec<u64> {
- let mut expired = Vec::new();
- for item in &mut self.items {
- if !item.paused {
- item.elapsed_ms = item.elapsed_ms.saturating_add(delta_ms);
- if item.elapsed_ms >= item.duration_ms {
- expired.push(item.id);
- }
- }
- }
- for id in &expired {
- self.dismiss(*id);
- }
- expired
- }
-
- /// Pauses timer while cursor is hovered over a banner.
- pub fn set_hovered(&mut self, id: Option<u64>) {
- self.hovered_id = id;
- for item in &mut self.items {
- item.paused = Some(item.id) == id;
- }
- }
-
- /// Dismisses a notification by ID.
- pub fn dismiss(&mut self, id: u64) -> Option<NotificationItem> {
- if let Some(pos) = self.items.iter().position(|it| it.id == id) {
- let item = self.items.remove(pos);
- if self.hovered_id == Some(id) {
- self.hovered_id = None;
- }
- Some(item)
- } else {
- None
- }
- }
-
- /// Dismisses all notifications originating from a specific app.
- pub fn dismiss_for_app(&mut self, app_id: &str) -> Vec<NotificationItem> {
- let mut removed = Vec::new();
- self.items.retain(|it| {
- if it.app_id == app_id {
- removed.push(it.clone());
- false
- } else {
- true
- }
- });
- if self
- .hovered_id
- .is_some_and(|h| removed.iter().any(|it| it.id == h))
- {
- self.hovered_id = None;
- }
- removed
- }
-
- /// Clears badge count when an app is focused or dismissed.
- pub fn clear_badge(&mut self, app_id: &str) {
- self.badges.remove(app_id);
- }
-
- /// Returns the badge count for an app.
- pub fn badge_count(&self, app_id: &str) -> usize {
- self.badges.get(app_id).copied().unwrap_or(0)
- }
-
- /// Returns all badge counts.
- pub fn all_badges(&self) -> &HashMap<String, usize> {
- &self.badges
- }
-
- /// Up to `MAX_VISIBLE_BANNERS` currently visible notifications.
- pub fn visible_items(&self) -> &[NotificationItem] {
- let count = self.items.len().min(MAX_VISIBLE_BANNERS);
- &self.items[..count]
- }
-
- /// Total number of active queued notifications.
- pub fn total_count(&self) -> usize {
- self.items.len()
- }
-
- /// Removes banners when Do Not Disturb is enabled, preserving unread badges.
- pub fn clear_banners(&mut self) {
- self.items.clear();
- self.hovered_id = None;
- }
-
- /// Clears all notifications and badges.
- pub fn clear_all(&mut self) {
- self.clear_banners();
- self.badges.clear();
- }
-}
-
-/// Standard layout parameters for notification cards.
-pub const BANNER_WIDTH: f32 = 340.0;
-pub const BANNER_HEIGHT: f32 = 72.0;
-pub const BANNER_GAP: f32 = 10.0;
-pub const BANNER_MARGIN: f32 = 16.0;
-
-/// Calculates the screen bounds for a visible banner at `index` (0-based, top-to-bottom or bottom-to-top).
-pub fn banner_bounds(index: usize, position: BannerPosition, work_area: Rect, scale: f32) -> Rect {
- let width = (BANNER_WIDTH * scale).round();
- let height = (BANNER_HEIGHT * scale).round();
- let gap = (BANNER_GAP * scale).round();
- let margin = (BANNER_MARGIN * scale).round();
-
- let x = work_area.x + work_area.width - width - margin;
- let y = match position {
- BannerPosition::TopRight => work_area.y + margin + (index as f32) * (height + gap),
- BannerPosition::BottomRight => {
- work_area.y + work_area.height - margin - height - (index as f32) * (height + gap)
- }
- };
-
- Rect {
- x,
- y,
- width,
- height,
- }
-}
-
-/// Close button ("✕") hit area on a notification banner (top-right corner of the banner).
-pub fn banner_close_button_bounds(banner_rect: Rect, scale: f32) -> Rect {
- let size = (20.0 * scale).round().max(20.0);
- let padding = (8.0 * scale).round();
- Rect {
- x: banner_rect.width - size - padding,
- y: padding,
- width: size,
- height: size,
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn enabling_dnd_drops_old_banners_but_preserves_unread_badges() {
- let mut queue = NotificationQueue::default();
- queue.push(
- "app".into(),
- "App".into(),
- "Title".into(),
- "Body".into(),
- None,
- None,
- 5000,
- false,
- false,
- );
- queue.clear_banners();
- assert!(queue.visible_items().is_empty());
- assert_eq!(queue.badge_count("app"), 1);
- queue.push(
- "app".into(),
- "App".into(),
- "Silent".into(),
- "Body".into(),
- None,
- None,
- 5000,
- true,
- false,
- );
- assert!(queue.tick(6000).is_empty());
- assert!(queue.visible_items().is_empty());
- assert_eq!(queue.badge_count("app"), 2);
- }
-
- #[test]
- fn test_push_and_expiration() {
- let mut queue = NotificationQueue::new();
- let Some(id1) = queue.push(
- "slack".into(),
- "Slack".into(),
- "New message".into(),
- "Hello!".into(),
- None,
- None,
- 5000,
- false,
- false,
- ) else {
- panic!("should push notification");
- };
-
- assert_eq!(queue.visible_items().len(), 1);
- assert_eq!(queue.badge_count("slack"), 1);
-
- // Advance 3000ms -> not expired
- let expired = queue.tick(3000);
- assert!(expired.is_empty());
- assert_eq!(queue.visible_items().len(), 1);
-
- // Advance another 2000ms -> expired
- let expired = queue.tick(2000);
- assert_eq!(expired, vec![id1]);
- assert_eq!(queue.visible_items().len(), 0);
- // Badge stays until focused/cleared
- assert_eq!(queue.badge_count("slack"), 1);
- }
-
- #[test]
- fn test_hover_pauses_timer() {
- let mut queue = NotificationQueue::new();
- let Some(id) = queue.push(
- "teams".into(),
- "Teams".into(),
- "Meeting".into(),
- "Starting now".into(),
- None,
- None,
- 5000,
- false,
- false,
- ) else {
- panic!("should push notification");
- };
-
- // Hover pauses
- queue.set_hovered(Some(id));
- let expired = queue.tick(6000);
- assert!(expired.is_empty());
- assert_eq!(queue.visible_items().len(), 1);
-
- // Hover end resumes
- queue.set_hovered(None);
- let expired = queue.tick(5000);
- assert_eq!(expired, vec![id]);
- assert_eq!(queue.visible_items().len(), 0);
- }
-
- #[test]
- fn test_dnd_and_mute() {
- let mut queue = NotificationQueue::new();
-
- // Muted app: completely ignored, no badge, no banner
- let id_muted = queue.push(
- "noisy".into(),
- "Noisy".into(),
- "Spam".into(),
- "Buy now".into(),
- None,
- None,
- 5000,
- false,
- true,
- );
- assert!(id_muted.is_none());
- assert_eq!(queue.badge_count("noisy"), 0);
-
- // DND mode: banner suppressed, badge still increments
- let id_dnd = queue.push(
- "mail".into(),
- "Mail".into(),
- "Urgent".into(),
- "Invoice".into(),
- None,
- None,
- 5000,
- true, // dnd
- false,
- );
- assert!(id_dnd.is_none());
- assert_eq!(queue.badge_count("mail"), 1);
- assert_eq!(queue.visible_items().len(), 0);
- }
-
- #[test]
- fn test_banner_bounds_layout() {
- let work_area = Rect {
- x: 0.0,
- y: 32.0, // under menu bar
- width: 1920.0,
- height: 1048.0,
- };
-
- // Top right
- let b0 = banner_bounds(0, BannerPosition::TopRight, work_area, 1.0);
- let b1 = banner_bounds(1, BannerPosition::TopRight, work_area, 1.0);
- assert_eq!(b0.x, 1920.0 - BANNER_WIDTH - BANNER_MARGIN);
- assert_eq!(b0.y, 32.0 + BANNER_MARGIN);
- assert_eq!(b1.y, b0.y + BANNER_HEIGHT + BANNER_GAP);
-
- // Bottom right
- let br0 = banner_bounds(0, BannerPosition::BottomRight, work_area, 1.0);
- let br1 = banner_bounds(1, BannerPosition::BottomRight, work_area, 1.0);
- assert_eq!(br0.x, 1920.0 - BANNER_WIDTH - BANNER_MARGIN);
- assert_eq!(br0.y, 32.0 + 1048.0 - BANNER_MARGIN - BANNER_HEIGHT);
- assert_eq!(br1.y, br0.y - BANNER_HEIGHT - BANNER_GAP);
- }
-
- #[test]
- fn test_burst_of_notifications() {
- let mut queue = NotificationQueue::new();
- let count = 25;
- let mut ids = Vec::new();
-
- for i in 0..count {
- let app = if i % 2 == 0 { "app_a" } else { "app_b" };
- let Some(id) = queue.push(
- app.into(),
- format!("App {app}"),
- format!("Title {i}"),
- format!("Body {i}"),
- None,
- None,
- 5000,
- false,
- false,
- ) else {
- panic!("should push notification");
- };
- ids.push(id);
- }
-
- // Only MAX_VISIBLE_BANNERS (3) are visible at a time
- assert_eq!(queue.visible_items().len(), MAX_VISIBLE_BANNERS);
- assert_eq!(queue.visible_items()[0].id, ids[0]);
- assert_eq!(queue.visible_items()[1].id, ids[1]);
- assert_eq!(queue.visible_items()[2].id, ids[2]);
-
- // Badge counts accumulate correctly across all 25 notifications
- assert_eq!(queue.badge_count("app_a"), 13);
- assert_eq!(queue.badge_count("app_b"), 12);
-
- // Dismissing the first 3 reveals the next 3
- for id in &ids[..3] {
- queue.dismiss(*id);
- }
- assert_eq!(queue.visible_items().len(), MAX_VISIBLE_BANNERS);
- assert_eq!(queue.visible_items()[0].id, ids[3]);
- assert_eq!(queue.visible_items()[1].id, ids[4]);
- assert_eq!(queue.visible_items()[2].id, ids[5]);
- }
-
- #[test]
- fn test_app_exit_notification_dismissal() {
- let mut queue = NotificationQueue::new();
- queue.push(
- "app_x".into(),
- "App X".into(),
- "T1".into(),
- "B1".into(),
- None,
- None,
- 5000,
- false,
- false,
- );
- queue.push(
- "app_y".into(),
- "App Y".into(),
- "T2".into(),
- "B2".into(),
- None,
- None,
- 5000,
- false,
- false,
- );
- queue.push(
- "app_x".into(),
- "App X".into(),
- "T3".into(),
- "B3".into(),
- None,
- None,
- 5000,
- false,
- false,
- );
-
- assert_eq!(queue.badge_count("app_x"), 2);
- assert_eq!(queue.badge_count("app_y"), 1);
-
- // App X exits: remove all notifications for app_x and clear its badge
- let removed = queue.dismiss_for_app("app_x");
- assert_eq!(removed.len(), 2);
- queue.clear_badge("app_x");
-
- assert_eq!(queue.badge_count("app_x"), 0);
- assert_eq!(queue.badge_count("app_y"), 1);
- assert_eq!(queue.visible_items().len(), 1);
- assert_eq!(queue.visible_items()[0].app_id, "app_y");
- }
-
- #[test]
- fn test_banner_close_button_geometry() {
- let banner = Rect {
- x: 100.0,
- y: 50.0,
- width: BANNER_WIDTH,
- height: BANNER_HEIGHT,
- };
- let close_1x = banner_close_button_bounds(banner, 1.0);
- assert_eq!(close_1x.width, 20.0);
- assert_eq!(close_1x.height, 20.0);
- assert_eq!(close_1x.x, BANNER_WIDTH - 20.0 - 8.0);
- assert_eq!(close_1x.y, 8.0);
-
- let close_2x = banner_close_button_bounds(banner, 2.0);
- assert_eq!(close_2x.width, 40.0);
- assert_eq!(close_2x.height, 40.0);
- assert_eq!(close_2x.x, BANNER_WIDTH - 40.0 - 16.0);
- assert_eq!(close_2x.y, 16.0);
- }
-}
diff --git a/crates/muelle-shell/src/dock_link.rs b/crates/muelle-shell/src/dock_link.rs
index e68c622..3e3206a 100644
--- a/crates/muelle-shell/src/dock_link.rs
+++ b/crates/muelle-shell/src/dock_link.rs
@@ -3,11 +3,7 @@
use windows::{
Win32::{
Foundation::{LPARAM, WPARAM},
- System::DataExchange::COPYDATASTRUCT,
- UI::WindowsAndMessaging::{
- FindWindowW, PostMessageW, RegisterWindowMessageW, SMTO_ABORTIFHUNG,
- SendMessageTimeoutW, WM_COPYDATA,
- },
+ UI::WindowsAndMessaging::{FindWindowW, PostMessageW, RegisterWindowMessageW},
},
core::{PCWSTR, w},
};
@@ -15,52 +11,6 @@ use windows::{
pub const DOCK_WINDOW_CLASS: PCWSTR = w!("MuelleWindow");
/// Name of the registered window message meaning "the configuration file changed".
pub const CONFIG_CHANGED: PCWSTR = w!("Muelle.ConfigChanged");
-/// Tag for notification payloads sent via WM_COPYDATA.
-pub const NOTIFY_DATA_TAG: usize = 0x4D55_4E46; // "MUNF"
-
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct NotificationPayload {
- pub app_id: String,
- pub app_name: String,
- pub title: String,
- pub body: String,
- pub icon_path: Option<String>,
- pub duration_secs: u32,
-}
-
-impl NotificationPayload {
- pub fn encode(&self) -> String {
- format!(
- "{}\t{}\t{}\t{}\t{}\t{}",
- self.app_id.replace('\t', " "),
- self.app_name.replace('\t', " "),
- self.title.replace('\t', " "),
- self.body.replace('\t', " "),
- self.icon_path.as_deref().unwrap_or("").replace('\t', " "),
- self.duration_secs
- )
- }
-
- pub fn decode(s: &str) -> Option<Self> {
- let parts: Vec<&str> = s.split('\t').collect();
- if parts.len() < 6 {
- return None;
- }
- Some(Self {
- app_id: parts[0].to_string(),
- app_name: parts[1].to_string(),
- title: parts[2].to_string(),
- body: parts[3].to_string(),
- icon_path: if parts[4].is_empty() {
- None
- } else {
- Some(parts[4].to_string())
- },
- duration_secs: parts[5].parse().unwrap_or(5),
- })
- }
-}
-
/// `true` if a dock is running in this session.
#[must_use]
pub fn is_running() -> bool {
@@ -79,68 +29,3 @@ pub fn notify_config_changed() {
}
}
}
-
-/// Sends a notification payload to the running dock process via WM_COPYDATA.
-/// Returns `true` if delivered successfully.
-pub fn post_notification(payload: &NotificationPayload) -> bool {
- let raw = payload.encode();
- let bytes = raw.as_bytes();
-
- unsafe {
- let dock = match FindWindowW(DOCK_WINDOW_CLASS, None) {
- Ok(hwnd) => hwnd,
- Err(_) => return false,
- };
-
- let cds = COPYDATASTRUCT {
- dwData: NOTIFY_DATA_TAG,
- cbData: bytes.len() as u32,
- lpData: bytes.as_ptr() as *mut _,
- };
-
- let mut result = 0;
- let ok = SendMessageTimeoutW(
- dock,
- WM_COPYDATA,
- WPARAM(0),
- LPARAM(&cds as *const _ as isize),
- SMTO_ABORTIFHUNG,
- 2000,
- Some(&mut result),
- );
- ok.0 != 0
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn test_notification_payload_roundtrip() {
- let payload = NotificationPayload {
- app_id: "com.example.app".into(),
- app_name: "Example App".into(),
- title: "Hello World".into(),
- body: "Notification body content with special chars: 🚀 <&>".into(),
- icon_path: Some("C:\\path\\to\\icon.png".into()),
- duration_secs: 10,
- };
- let encoded = payload.encode();
- let Some(decoded) = NotificationPayload::decode(&encoded) else {
- panic!("should decode valid payload");
- };
- assert_eq!(decoded.app_id, payload.app_id);
- assert_eq!(decoded.app_name, payload.app_name);
- assert_eq!(decoded.title, payload.title);
- assert_eq!(decoded.body, payload.body);
- assert_eq!(decoded.icon_path, payload.icon_path);
- assert_eq!(decoded.duration_secs, payload.duration_secs);
- }
-
- #[test]
- fn test_notification_payload_invalid_json() {
- assert!(NotificationPayload::decode("not valid json").is_none());
- assert!(NotificationPayload::decode("").is_none());
- }
-}
diff --git a/crates/muelle-shell/src/system.rs b/crates/muelle-shell/src/system.rs
index 6f8758d..7a2cbb7 100644
--- a/crates/muelle-shell/src/system.rs
+++ b/crates/muelle-shell/src/system.rs
@@ -9,9 +9,7 @@ use windows::{
},
System::Com::CoTaskMemFree,
System::Registry::{
- HKEY, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, KEY_SET_VALUE, REG_DWORD,
- REG_OPTION_NON_VOLATILE, RRF_RT_REG_DWORD, RRF_RT_REG_SZ, RegCloseKey, RegCreateKeyExW,
- RegGetValueW, RegSetValueExW,
+ HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, RRF_RT_REG_DWORD, RRF_RT_REG_SZ, RegGetValueW,
},
UI::{
HiDpi::{GetDpiForMonitor, MDT_EFFECTIVE_DPI},
@@ -47,34 +45,6 @@ pub fn transparency_enabled() -> bool {
!energy_saver_on() && personalize(w!("EnableTransparency")) != Some(0)
}
-/// Suppresses or restores native Windows toast notification banners.
-///
-/// Setting `ToastEnabled` to 0 prevents Windows from showing its native toast
-/// popups so Muelle's macOS-style glass notification banners can take precedence.
-pub fn set_windows_toasts_enabled(enabled: bool) {
- let value = u32::from(enabled).to_le_bytes();
- // SAFETY: Updates the user's push notification toast setting safely.
- unsafe {
- let mut key = HKEY::default();
- if RegCreateKeyExW(
- HKEY_CURRENT_USER,
- w!(r"Software\Microsoft\Windows\CurrentVersion\PushNotifications"),
- None,
- None,
- REG_OPTION_NON_VOLATILE,
- KEY_SET_VALUE,
- None,
- &mut key,
- None,
- )
- .is_ok()
- {
- let _ = RegSetValueExW(key, w!("ToastEnabled"), None, REG_DWORD, Some(&value));
- let _ = RegCloseKey(key);
- }
- }
-}
-
/// `true` while energy saver (battery saver on Windows 10) is on.
#[must_use]
pub fn energy_saver_on() -> bool {
diff --git a/muelle/src/data/site.ts b/muelle/src/data/site.ts
index b086b85..b77e4e2 100644
--- a/muelle/src/data/site.ts
+++ b/muelle/src/data/site.ts
@@ -13,7 +13,7 @@ export const site = {
releases: "https://github.com/crafter-station/Muelle/releases",
download: "https://github.com/crafter-station/Muelle/releases/latest/download/Muelle-Setup.exe",
issues: "https://github.com/crafter-station/Muelle/issues",
- version: "0.1.20",
+ version: "0.1.21",
license: "MIT",
} as const;