Skip to content
Merged
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
8 changes: 6 additions & 2 deletions dataans/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ const BACKUPS_DIR: &str = "backups";

fn toggle_app_visibility(app: &AppHandle) -> Result<()> {
if let Some(window) = app.get_webview_window(MAIN_WINDOW_NAME) {
if window.is_visible().unwrap_or(false) {
if window.is_visible().unwrap_or(false) && window.is_focused().unwrap_or(false) {
info!("Hide main window");
window.hide()?;
} else if window.is_visible().unwrap_or(false) && !window.is_focused().unwrap_or(false) {
info!("Focus main window");
// `.set_focus()` doesn't work well on Linux, so we have to hide and show the window to bring it to the front.
window.hide()?;
window.show()?;
} else {
info!("Show main window");
window.show()?;
window.set_focus()?;
}
} else {
error!("{MAIN_WINDOW_NAME} window not found!");
Expand Down