mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-04 16:57:00 +01:00
feat(app): one window at a time, share link as an argument
A second launch hands its request to the open window and exits: over a Unix socket in the user's runtime directory, or a named pipe on Windows whose name carries a random key from the user's config directory, so another account cannot take the name first. The open window comes forward, and a share link given as the first such argument opens the Add form with it filled in. Setup failures are logged and the app runs without the lock.
This commit is contained in:
1 parent
7e734dbf19
commit
4a54af3245
7 files changed
+388
-1
No files matched your search
@@ -31,6 +31,17 @@ fn main() -> anyhow::Result<()> {
|
||||
);
|
||||
let dirs = AppDirs::ensure().context("resolve app directories")?;
|
||||
|
||||
// Before the window: a second launch hands its request to the first and
|
||||
// never opens one.
|
||||
let request = pstr_app::instance::Request::from_args(std::env::args().skip(1));
|
||||
let instance = match pstr_app::instance::claim(&runtime, &dirs, &request) {
|
||||
pstr_app::instance::Claim::First(listener) => listener,
|
||||
pstr_app::instance::Claim::Handed => {
|
||||
tracing::info!("handed over to the window already open");
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let window = pstr_app::window::WindowState::load(&dirs.window_file());
|
||||
let mut viewport = egui::ViewportBuilder::default();
|
||||
// X11 and Windows take the icon from the window. Wayland ignores this and
|
||||
@@ -57,7 +68,7 @@ fn main() -> anyhow::Result<()> {
|
||||
"proton-stream",
|
||||
options,
|
||||
Box::new(move |cc| {
|
||||
pstr_app::app::App::new(cc, runtime, dirs)
|
||||
pstr_app::app::App::new(cc, runtime, dirs, instance, request)
|
||||
.map(|app| Box::new(app) as Box<dyn eframe::App>)
|
||||
.map_err(|error| error.into())
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user