Files
cinny-desktop/src-tauri/src/main.rs
StevenDoesStuffs 095b8fc561 Add system tray support (#166)
* Added sytem tray with hide/show buttons

* Split tray into separate module

* Fix persistent console window

* Show/hide window on tray icon click

---------

Co-authored-by: serxka <serxka@protonmail.com>
Co-authored-by: Milo <40355097+serxka@users.noreply.github.com>
Co-authored-by: greentore <117551249+greentore@users.noreply.github.com>
2023-10-21 21:34:32 +11:00

33 lines
835 B
Rust

#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
#[cfg(target_os = "macos")]
mod menu;
mod tray;
fn main() {
let builder = tauri::Builder::default();
#[cfg(target_os = "macos")]
let builder = builder.menu(menu::menu());
let builder = builder
.system_tray(tray::system_tray())
.on_system_tray_event(tray::system_tray_handler);
builder
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(run_event_handler)
}
fn run_event_handler<R: tauri::Runtime>(app: &tauri::AppHandle<R>, event: tauri::RunEvent) {
match event {
tauri::RunEvent::WindowEvent { label, event, .. } => {
tray::window_event_handler(app, &label, &event);
}
_ => {}
}
}