mod commands; mod hotkeys; mod models; mod rect; mod storage; mod win32_window; mod window_manager; use tauri::{Emitter, Manager}; use tauri_plugin_global_shortcut::{Code, Modifiers, Shortcut, ShortcutState}; fn main() { win32_window::set_process_dpi_awareness(); tauri::Builder::default() .plugin( tauri_plugin_global_shortcut::Builder::new() .with_handler(|app, shortcut, event| { if event.state() != ShortcutState::Pressed { return; } let ctrl_1 = Shortcut::new(Some(Modifiers::CONTROL), Code::Digit1); let ctrl_r = Shortcut::new(Some(Modifiers::CONTROL), Code::KeyR); if shortcut == &ctrl_1 { let _ = app.emit("hotkey:start-window-picking", ()); } else if shortcut == &ctrl_r { let _ = app.emit("hotkey:start-annotation", ()); } }) .build(), ) .invoke_handler(tauri::generate_handler![ commands::save_project, commands::load_project, commands::get_virtual_screen_rect, commands::window_at, commands::foreground_window, commands::cursor_position, commands::tool_window_hwnds, commands::exit_app, ]) .setup(|app| { let handle = app.handle().clone(); window_manager::create_all_windows(&handle)?; let errors = hotkeys::register(&handle); hotkeys::emit_registration_errors(&handle, errors); Ok(()) }) .on_window_event(|window, event| { if matches!(event, tauri::WindowEvent::Destroyed) { if window.label() == "floating" { hotkeys::unregister(&window.app_handle()); } } }) .run(tauri::generate_context!()) .expect("error while running tauri application"); }