Show each site's own icon; restore the native title bar

Both previous attempts asked a question about a domain, and a domain does
not know which product it is serving. Google's favicon service returned a
marketing site's icon for anything behind a login and nothing for a
private host; Simple Icons returned one flat brand mark where the real
one is multicoloured and, for Gmail, carries the unread count.

The page already holds the answer - fetched, authenticated, current. The
injected script now reads link[rel~="icon"] and reports the best one:
largest declared sizes wins, an Apple touch icon counts as 180, and an
.ico is penalised as usually the 16px tab icon. It rechecks on the same
tick as the unread count, which is when a site like Gmail redraws its
icon with a badge. The URL is stored, so the nav is right at launch
rather than blank until every page has loaded.

The custom frame is gone with it: ordinary macOS title bar, traffic
lights where every other window puts them, and the bar following the
app's Light/Dark choice through set_theme. A window that behaves like a
window beats one that looks bespoke.
This commit is contained in:
2026-09-01 15:03:09 +02:00
parent ffedb72b83
commit 17d13d2505
17 changed files with 186 additions and 358 deletions
+33
View File
@@ -52,6 +52,13 @@ pub struct NotificationClick {
pub notification_id: String,
}
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct IconEvent {
pub app_id: String,
pub icon: String,
}
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HiddenEvent {
@@ -183,6 +190,31 @@ fn handle_sentinel(
notify(&handle, &from, &name, &title, &format!("{total} unread"), String::new());
}
// The site told us its own icon. Stored rather than merely shown,
// so the nav is right at launch instead of blank until every page
// has finished loading.
"icon" => {
let Some(url) = params.get("u") else { return };
let state = handle.state::<crate::commands::AppState>();
let changed = {
let mut cfg = state.config.lock().unwrap();
match cfg.apps.iter_mut().find(|a| a.id == from) {
Some(a) if a.icon.as_deref() != Some(url.as_str()) => {
a.icon = Some(url.clone());
true
}
_ => false,
}
};
if changed {
let _ = state.save();
let _ = handle.emit(
"icon-changed",
IconEvent { app_id: from.clone(), icon: url.clone() },
);
}
}
"manage" => {
let _ = handle.emit("manage-hidden", from.clone());
}
@@ -722,6 +754,7 @@ mod tests {
group_id: None,
user_agent: None,
hidden: vec![".ad".into()],
icon: None,
zoom: 1.0,
order: 0,
};