Set the Wayland app id late enough for it to take
The launcher and the task bar have shown a generic tile for a working window since the call was written. set_xdg_app_id sat at the top of run(), on the reasoning that the app id is read when the surface is created — true, and beside the point: the call goes through Slint's global context, and there is no global context until something installs a platform. That is BackendSelector inside shared_gpu, or AppWindow::new falling back to the default, and both happen further down. Called before either, it returned NoPlatform and did nothing at all. It moves to just after the window is constructed, which is not the same as shown — run() is far below — so there is a platform to talk to and the surface does not exist yet. The failure was logged at debug, which is why a year of grey squares went unremarked: the whole symptom is invisible from inside the application. It is a warning now, naming the consequence.
This commit is contained in:
+29
-29
File diff suppressed because one or more lines are too long
+37
-24
@@ -1126,30 +1126,6 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
|||||||
let entries = Rc::new(RefCell::new(collect(&paths)));
|
let entries = Rc::new(RefCell::new(collect(&paths)));
|
||||||
log::info!("{} image(s) to browse", entries.borrow().len());
|
log::info!("{} image(s) to browse", entries.borrow().len());
|
||||||
|
|
||||||
// TRACES: FR-PLAT-LIN-1
|
|
||||||
// The name the compositor knows this window by, and the reason the
|
|
||||||
// launcher shows a real icon rather than a grey square.
|
|
||||||
//
|
|
||||||
// `app.slint` sets `icon:`, and that is genuinely embedded (see
|
|
||||||
// `build.rs`) — but a Wayland compositor ignores a client-set icon
|
|
||||||
// entirely. It takes the icon from the `.desktop` file whose basename
|
|
||||||
// matches the surface's `app_id`, and nothing else. So the embedded icon
|
|
||||||
// is what X11 and the window itself use, and *this* is what GNOME's
|
|
||||||
// overview, dash and alt-tab use. Both are needed and neither substitutes
|
|
||||||
// for the other.
|
|
||||||
//
|
|
||||||
// The string must equal the installed `.desktop` file's basename exactly:
|
|
||||||
// `packaging/paris.tourolle.darkroom.desktop`. It matches the Android
|
|
||||||
// package id (`AndroidManifest.xml`) on purpose — one application, one
|
|
||||||
// reverse-DNS name on both platforms.
|
|
||||||
//
|
|
||||||
// Before the window, necessarily: it is read when the surface is created.
|
|
||||||
if let Err(e) = slint::set_xdg_app_id("paris.tourolle.darkroom") {
|
|
||||||
// Not fatal. On X11 and on Android this does nothing useful, and a
|
|
||||||
// missing app id costs an icon rather than a working application.
|
|
||||||
log::debug!("could not set the xdg app id: {e}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Everything between here and `window.run()` at the bottom happens before
|
// Everything between here and `window.run()` at the bottom happens before
|
||||||
// the event loop exists, and on Android that is not merely a slow start:
|
// the event loop exists, and on Android that is not merely a slow start:
|
||||||
// `android_main` calls this, and nothing drains the activity's input
|
// `android_main` calls this, and nothing drains the activity's input
|
||||||
@@ -1180,6 +1156,43 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
|||||||
let before_window = std::time::Instant::now();
|
let before_window = std::time::Instant::now();
|
||||||
let window = AppWindow::new()?;
|
let window = AppWindow::new()?;
|
||||||
log::info!("window built in {} ms", before_window.elapsed().as_millis());
|
log::info!("window built in {} ms", before_window.elapsed().as_millis());
|
||||||
|
|
||||||
|
// TRACES: FR-PLAT-LIN-1
|
||||||
|
// The name the compositor knows this window by, and the reason the
|
||||||
|
// launcher shows a real icon rather than a grey square.
|
||||||
|
//
|
||||||
|
// `app.slint` sets `icon:`, and that is genuinely embedded (see
|
||||||
|
// `build.rs`) — but a Wayland compositor ignores a client-set icon
|
||||||
|
// entirely. It takes the icon from the `.desktop` file whose basename
|
||||||
|
// matches the surface's `app_id`, and nothing else. So the embedded icon
|
||||||
|
// is what X11 and the window itself use, and *this* is what GNOME's
|
||||||
|
// overview, dash and alt-tab use. Both are needed and neither substitutes
|
||||||
|
// for the other.
|
||||||
|
//
|
||||||
|
// The string must equal the installed `.desktop` file's basename exactly:
|
||||||
|
// `packaging/paris.tourolle.darkroom.desktop`. It matches the Android
|
||||||
|
// package id (`AndroidManifest.xml`) on purpose — one application, one
|
||||||
|
// reverse-DNS name on both platforms.
|
||||||
|
//
|
||||||
|
// **After the window is constructed, and before it is shown.** This used
|
||||||
|
// to sit at the top of `run`, on the reasoning that the app id is read
|
||||||
|
// when the surface is created — which is true, and still left it never
|
||||||
|
// set. `slint::set_xdg_app_id` goes through the global context, and there
|
||||||
|
// is no global context until something installs a Slint platform: either
|
||||||
|
// `BackendSelector` in `shared_gpu`, or `AppWindow::new` falling back to
|
||||||
|
// the default. Called before both, it returned `NoPlatform` and did
|
||||||
|
// nothing, and GNOME showed a generic tile for the window from the day
|
||||||
|
// the call was written. Constructing a window is not showing it — `run`
|
||||||
|
// is far below — so this is both late enough to have a platform and early
|
||||||
|
// enough to be read.
|
||||||
|
if let Err(e) = slint::set_xdg_app_id("paris.tourolle.darkroom") {
|
||||||
|
// Not fatal, but not silent either: the cost is the launcher and the
|
||||||
|
// task bar showing a grey square for a window that is working
|
||||||
|
// perfectly, which is invisible from inside the application and was
|
||||||
|
// missed for exactly that reason. X11 and Android reach here too,
|
||||||
|
// where the call is a no-op and the message is merely noise at debug.
|
||||||
|
log::warn!("could not set the xdg app id, so the launcher icon will be generic: {e}");
|
||||||
|
}
|
||||||
// The version the About page shows. Taken from the crate rather than
|
// The version the About page shows. Taken from the crate rather than
|
||||||
// passed in, so it is the version of the code that is running and cannot
|
// passed in, so it is the version of the code that is running and cannot
|
||||||
// be set to something else by a caller.
|
// be set to something else by a caller.
|
||||||
|
|||||||
Reference in New Issue
Block a user