Expand description
Setting the host console/terminal window icon (#577).
§Capability-reported, never assumed
Most terminals do not let a running program change their window icon, and
they do not say so — the API call succeeds and nothing happens. Windows
Terminal is the case that matters most: GetConsoleWindow returns a real
handle to a hidden pseudo-console window, so WM_SETICON succeeds against
a window nobody can see.
A function that returns Ok(()) there would be worse than one that fails:
the caller would ship a feature that silently does nothing on the default
terminal of every recent Windows install. So support is probed and
reported, and set_host_icon refuses rather than pretending.
§What is supported
Classic Windows console (conhost.exe) only, for now. Everything else
reports IconSupport::Unsupported with a reason. Linux/X11 is a
plausible later addition; macOS Terminal.app and iTerm2, Windows Terminal,
Wayland compositors, and most modern emulators deliberately reserve the
window decoration to themselves, and no in-process API changes that.
Modules§
- ico
- Locating the best image inside an
.icoblob (#577).
Enums§
- Icon
Error - Why setting an icon failed.
- Icon
Scope - Which window an icon operation targets.
- Icon
Source - Where an icon comes from.
- Icon
Support - Whether this process can set its host window’s icon.
- Stock
Icon - A stock icon provided by the operating system.
Functions§
- host_
icon_ support - Whether this process’s host window can accept an icon.
- icon_
support - Whether a window can accept an icon.
- set_
host_ icon - Set the icon on this process’s host console window.
- set_
icon - Set the icon on the window named by
scope.