Merge branch 'main' of github.com:flagon-io/g1t
1 file+16−30/1 viewed
| 26 | 26 | use tauri::{RunEvent, WebviewUrl, WebviewWindowBuilder, WindowEvent}; | |
| 27 | 27 | use tauri_plugin_window_state::{StateFlags, WindowExt}; | |
| 28 | 28 | ||
| 29 | + | /// What the window keeps between launches: its size, place, and whether it | |
| 30 | + | /// was maximized or full screen; not its frame. | |
| 31 | + | const KEPT: StateFlags = StateFlags::all().difference(StateFlags::DECORATIONS); | |
| 32 | + | ||
| 29 | 33 | /// The one window's label. | |
| 30 | 34 | pub const WINDOW: &str = "main"; | |
| 31 | 35 | ||
| ⋯ | |||
| 40 | 44 | .plugin(tauri_plugin_opener::init()) | |
| 41 | 45 | .plugin(tauri_plugin_updater::Builder::new().build()) | |
| 42 | 46 | // The window's size and place come back in setup, without the plugin | |
| 43 | − | // also showing it: at sign-in g1t may start in the tray. | |
| 44 | − | .plugin(tauri_plugin_window_state::Builder::new().skip_initial_state(WINDOW).with_denylist(&[settings::SETTINGS]).build()) | |
| 47 | + | // also showing it: at sign-in g1t may start in the tray. Whether it | |
| 48 | + | // has the system's frame is the title bar setting's (frame.rs), never | |
| 49 | + | // what an earlier run left: kept, it would put the frame back round | |
| 50 | + | // g1t's own title bar. | |
| 51 | + | .plugin( | |
| 52 | + | tauri_plugin_window_state::Builder::new() | |
| 53 | + | .with_state_flags(KEPT) | |
| 54 | + | .skip_initial_state(WINDOW) | |
| 55 | + | .with_denylist(&[settings::SETTINGS]) | |
| 56 | + | .build(), | |
| 57 | + | ) | |
| 45 | 58 | // Opening at sign-in, which settings turn on; the argument tells that start from someone's. | |
| 46 | 59 | .plugin(tauri_plugin_autostart::init(tauri_plugin_autostart::MacosLauncher::LaunchAgent, Some(vec![settings::AT_LOGIN]))) | |
| 47 | 60 | .manage(config::State::default()) | |
| ⋯ | |||
| 93 | 106 | let builder = builder.menu(menu::build(&handle)?); | |
| 94 | 107 | let window = frame::style(builder, custom).build()?; | |
| 95 | 108 | // Opened at sign-in, g1t waits in the tray; otherwise the window comes up where it was. | |
| 96 | − | let _ = window.restore_state(StateFlags::all() - StateFlags::VISIBLE); | |
| 109 | + | let _ = window.restore_state(KEPT - StateFlags::VISIBLE); | |
| 97 | 110 | #[cfg(not(target_os = "macos"))] | |
| 98 | 111 | frame::menu_bar(&window, custom); | |
| 99 | 112 | if !hidden { | |