MCPcopy Create free account
hub / github.com/GCWing/BitFun / show_main_window

Function show_main_window

src/apps/desktop/src/theme.rs:1008–1069  ·  view source on GitHub ↗
(app: tauri::AppHandle)

Source from the content-addressed store, hash-verified

1006
1007#[tauri::command]
1008pub async fn show_main_window(app: tauri::AppHandle) -> Result<(), String> {
1009 let total_started_at = Instant::now();
1010 if let Some(main_window) = app.get_webview_window("main") {
1011 #[cfg(target_os = "windows")]
1012 {
1013 // Work around Windows startup flicker: avoid creating the native window
1014 // in maximized mode, and maximize it right before showing instead.
1015 let step_started_at = Instant::now();
1016 main_window.maximize().map_err(|e| {
1017 error!("Failed to maximize main window: {}", e);
1018 format!("Failed to maximize main window: {}", e)
1019 })?;
1020 debug!(
1021 "Main window show step completed: step=maximize duration_ms={}",
1022 step_started_at.elapsed().as_millis()
1023 );
1024
1025 let wait_started_at = Instant::now();
1026 let show_wait_outcome = wait_for_windows_maximize_before_show_async(&main_window).await;
1027 debug!(
1028 "Main window show step completed: step=wait_for_maximize_state outcome={} duration_ms={}",
1029 show_wait_outcome,
1030 wait_started_at.elapsed().as_millis()
1031 );
1032 }
1033
1034 let step_started_at = Instant::now();
1035 main_window.show().map_err(|e| {
1036 error!("Failed to show main window: {}", e);
1037 format!("Failed to show main window: {}", e)
1038 })?;
1039 debug!(
1040 "Main window show step completed: step=show duration_ms={}",
1041 step_started_at.elapsed().as_millis()
1042 );
1043
1044 #[cfg(target_os = "macos")]
1045 {
1046 crate::cancel_main_window_close_request_on_macos();
1047 crate::mark_main_window_hidden_on_macos(false);
1048 }
1049
1050 let step_started_at = Instant::now();
1051 main_window.set_focus().map_err(|e| {
1052 error!("Failed to focus main window: {}", e);
1053 format!("Failed to focus main window: {}", e)
1054 })?;
1055 debug!(
1056 "Main window show step completed: step=focus duration_ms={}",
1057 step_started_at.elapsed().as_millis()
1058 );
1059 } else {
1060 error!("Main window not found");
1061 return Err("Main window not found".to_string());
1062 }
1063
1064 debug!(
1065 "Main window shown: total_duration_ms={}",

Callers

nothing calls this directly

Tested by

no test coverage detected