Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions apps/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern crate objc;
mod app_handle;
mod commands;
mod constants;
mod placement;
mod tray;
mod window_custom;

Expand Down Expand Up @@ -106,8 +107,14 @@ fn main() {

#[cfg(not(debug_assertions))]
{
app = app.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
println!("{}, {argv:?}, {cwd}", app.package_info().name);
app = app.plugin(tauri_plugin_single_instance::init(|app, _, _| {
if let Some(settings) = app.get_webview_window(SETTINGS_WINDOW_NAME) {
for result in [settings.show(), settings.unminimize(), settings.set_focus()] {
if let Err(error) = result {
log::warn!("Could not bring settings forward after a second launch: {error}");
}
}
}
}));
}

Expand All @@ -119,6 +126,7 @@ fn main() {
app = app
.manage(Pinned(AtomicBool::new(false)))
.manage(HideTaskbarWhenPinned(AtomicBool::new(false)))
.manage(placement::PlacementState::default())
.setup(move |app| {
debug!("starting app...");
let window = app.get_webview_window(MAIN_WINDOW_NAME).unwrap();
Expand Down Expand Up @@ -174,6 +182,9 @@ fn main() {
open_settings,
set_hide_taskbar_when_pinned,
open_config_dir,
placement::get_monitors,
placement::apply_placement,
placement::release_placement,
]);

app
Expand Down Expand Up @@ -203,7 +214,7 @@ fn main() {
}

WEvent::Resized(_) | WEvent::Moved(_) => {
if label == MAIN_WINDOW_NAME {
if label == MAIN_WINDOW_NAME && !app.state::<placement::PlacementState>().is_active() {
// Also save state whenever the main window is moved or resized so
// we persist the latest bounds even if the process is terminated
app.save_window_state(StateFlags::POSITION | StateFlags::SIZE);
Expand Down
Loading
Loading