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
+24 -2
View File
@@ -41,6 +41,11 @@ impl AppState {
config::save(&self.dir, &self.config.lock().unwrap())
}
/// Same, for the sentinel handlers that live outside this module.
pub fn save(&self) -> Result<(), String> {
self.persist()
}
/// Records a selector chosen by right-clicking it in the page.
pub fn add_hidden(&self, app_id: &str, selector: &str) -> Result<(), String> {
{
@@ -298,6 +303,7 @@ pub fn add_app(
group_id,
user_agent: None,
hidden: Vec::new(),
icon: None,
zoom: 1.0,
order,
};
@@ -448,11 +454,27 @@ pub fn set_nav_collapsed(collapsed: bool, state: State<'_, AppState>) -> Result<
}
#[tauri::command]
pub fn set_theme(theme: String, state: State<'_, AppState>) -> Result<(), String> {
state.config.lock().unwrap().settings.theme = theme;
pub fn set_theme(theme: String, app: AppHandle, state: State<'_, AppState>) -> Result<(), String> {
state.config.lock().unwrap().settings.theme = theme.clone();
apply_window_theme(&app, &theme);
state.persist()
}
/// Puts the window's own title bar in the same light or dark as the app.
///
/// `None` hands it back to the system, which is what "System" means — the bar
/// then follows the OS the way every other window does.
pub fn apply_window_theme(app: &AppHandle, theme: &str) {
let wanted = match theme {
"light" => Some(tauri::Theme::Light),
"dark" => Some(tauri::Theme::Dark),
_ => None,
};
if let Some(w) = app.get_window("main") {
let _ = w.set_theme(wanted);
}
}
// ------------------------------------------------------- hidden elements
/// Replaces an app's hidden selectors and re-applies them without a reload.