Skip to content

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

feat(notifications): display macOS banners on app attention and suppress native toasts

Saivarshith Mitukula4d03cb31bf5e
diff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rs
index 1cbccd4..50dae90 100644
--- a/apps/dock/src/app.rs
+++ b/apps/dock/src/app.rs
@@ -3985,11 +3985,19 @@ impl App {
self.sync_attention_visuals()?;
self.render()?;
}
- if self.config.notification_badges && !self.config.muted_apps.contains(&app_id) {
+ if (self.config.notification_badges || self.config.notifications)
+ && !self.config.muted_apps.contains(&app_id)
+ {
let title = tracker::title(hwnd);
- self.notifications.push(
+ 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(),
- title.clone(),
+ app_name,
title,
String::new(),
None,
@@ -3998,12 +4006,52 @@ impl App {
self.config.notification_dnd || !self.config.notifications,
false,
);
- let _ = self.render();
+ if self.config.notification_badges {
+ let _ = self.render();
+ }
+ if pushed.is_some() {
+ self.show_active_banners();
+ }
}
}
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;
@@ -4039,38 +4087,8 @@ impl App {
let _ = self.render();
}
- if pushed.is_some() && !self.fullscreen {
- 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,
- );
+ if pushed.is_some() {
+ self.show_active_banners();
}
}
@@ -5488,6 +5506,7 @@ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, w: WPARAM, l: LPARAM) ->
}
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 {
@@ -5787,6 +5806,9 @@ 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));
}
@@ -5815,6 +5837,7 @@ 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() };
diff --git a/crates/muelle-shell/src/system.rs b/crates/muelle-shell/src/system.rs
index 7a2cbb7..6f8758d 100644
--- a/crates/muelle-shell/src/system.rs
+++ b/crates/muelle-shell/src/system.rs
@@ -9,7 +9,9 @@ use windows::{
},
System::Com::CoTaskMemFree,
System::Registry::{
- HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, RRF_RT_REG_DWORD, RRF_RT_REG_SZ, RegGetValueW,
+ 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,
},
UI::{
HiDpi::{GetDpiForMonitor, MDT_EFFECTIVE_DPI},
@@ -45,6 +47,34 @@ 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 {