app: build as a windowed app so no console opens with it

The exe was a console-subsystem binary, so every launch allocated a console
window: from Explorer, from the Run key at login, everywhere. The PE header
now says windowed (`windows_subsystem = "windows"`), and Windows creates no
console for the process.

The printing modes still work from a shell: `attach_console` borrows the
console of whatever started the app, and does nothing when nothing did. The
daemon was already spawned with `DETACHED_PROCESS`, so it never had a window
of its own, and ffmpeg goes through `ffmpeg-sidecar`, which passes
`CREATE_NO_WINDOW` on each spawn.
This commit is contained in:
vhaudiquet committed 2026-11-19 18:49:30 +01:00
1 parent eabc3780c9
commit 673cddfff6
3 files changed
+28

No files matched your search

+22
View File
@@ -2,6 +2,11 @@
//!
//! Replaces `tauri-app`. The daemon keeps its IPC protocol; this app is a client of it.
//! `cargo run` opens the window; `cargo run -- --snap out.png` renders it headless.
//!
//! The binary is a windowed app on Windows, so launching it from Explorer, the Run key or the
//! login item never opens a console. The printing modes (`--games`, `--probe`, `--snap`) borrow
//! the console of the shell that started them (`attach_console`).
#![cfg_attr(target_os = "windows", windows_subsystem = "windows")]
mod app;
mod daemon;
@@ -19,9 +24,26 @@ mod settings;
mod theme;
mod ui;
/// Print to the shell that started this app, when there is one.
///
/// A windowed process has no console of its own, so `println!` from `--probe` or `--snap` would
/// go nowhere under `cmd`. The shell's console is still there to attach to; when the app is
/// started from Explorer or the login item there is none and this does nothing.
#[cfg(target_os = "windows")]
fn attach_console() {
use windows::Win32::System::Console::{ATTACH_PARENT_PROCESS, AttachConsole};
unsafe {
let _ = AttachConsole(ATTACH_PARENT_PROCESS);
}
}
#[cfg(not(target_os = "windows"))]
fn attach_console() {}
use rune::AppSpec;
fn main() {
attach_console();
if std::env::args().any(|arg| arg == "--games") {
println!("{} timelines", crate::history::timeline_paths().len());
return;