forked from 1b-agent/opencadstudio-upstream
fix(icon): draw every icon from the logo file
Two places still showed the old mark after the logo was redrawn. The window icon was built by drawing the letterforms stroke by stroke in code, background colour and all, which made it the one icon in the application not coming from assets/logo.svg. It now rasterises that file, fitted to the square without distorting whatever aspect the logo has. It returns nothing when the logo cannot be rendered, so the window falls back to the platform default instead of to something invented here -- which is how it ended up stale in the first place. The icon installed into the icon theme was only ever written from inside the desktop-entry write, behind that write's own "nothing changed" early return. The entry's text does not change when the logo does, so once it had been written the icon was never refreshed again. The two change for different reasons; the icon is now checked first and on its own terms. It already compares bytes, so an unchanged logo still costs only a read. Worth knowing on Wayland: the compositor ignores the window icon entirely and takes the dock icon from the desktop entry, so there the installed theme file is the only one that matters -- and it refreshes when the file associations are next set up, not at launch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
36e328f7d7
commit
7c8271c716
6 files changed
+154
-67
No files matched your search
@@ -514,6 +514,14 @@ mod linux_impl {
|
||||
StartupWMClass=OpenCADStudio\n"
|
||||
);
|
||||
|
||||
// The icon is checked first and on its own. It and the .desktop entry
|
||||
// change for different reasons — the entry only when this text does,
|
||||
// the icon whenever the logo is redrawn — so gating the icon on the
|
||||
// entry meant a new logo never reached the theme after the entry had
|
||||
// been written once. `install_icon` compares bytes itself, so this
|
||||
// costs a read when nothing has changed.
|
||||
install_icon()?;
|
||||
|
||||
// Nothing changed since last launch → skip the write and the (slow)
|
||||
// desktop-database refresh.
|
||||
if std::fs::read_to_string(&desktop_path).ok().as_deref() == Some(contents.as_str()) {
|
||||
@@ -523,8 +531,6 @@ mod linux_impl {
|
||||
std::fs::create_dir_all(&apps).map_err(|e| e.to_string())?;
|
||||
std::fs::write(&desktop_path, &contents).map_err(|e| e.to_string())?;
|
||||
|
||||
install_icon()?;
|
||||
|
||||
// Best-effort: refresh the MIME→app cache. Absent on minimal systems.
|
||||
let _ = std::process::Command::new("update-desktop-database")
|
||||
.arg(&apps)
|
||||
|
||||
Reference in new issue
Block a user