An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
windows kill flutter main window when --server close (#8077)
21pagesc2b7810c3375
diff --git a/src/core_main.rs b/src/core_main.rsindex 5e5c36ef4..d2fbb8443 100644--- a/src/core_main.rs+++ b/src/core_main.rs@@ -565,7 +565,7 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin{use winapi::um::winuser::WM_USER;let res = crate::platform::send_message_to_hnwd(- "FLUTTER_RUNNER_WIN32_WINDOW",+ &crate::platform::FLUTTER_RUNNER_WIN32_WINDOW_CLASS,&crate::get_app_name(),(WM_USER + 2) as _, // referred from unilinks desktop pubuni_links.as_str(),diff --git a/src/ipc.rs b/src/ipc.rsindex bc88fe7f7..02a5d9429 100644--- a/src/ipc.rs+++ b/src/ipc.rs@@ -356,6 +356,8 @@ async fn handle(data: Data, stream: &mut Connection) {crate::server::input_service::fix_key_down_timeout_at_exit();if is_server() {let _ = privacy_mode::turn_off_privacy(0, Some(PrivacyModeState::OffByPeer));+ #[cfg(all(windows, feature = "flutter"))]+ crate::platform::kill_flutter_main_window();}std::process::exit(0);}diff --git a/src/platform/windows.rs b/src/platform/windows.rsindex 3072c5623..ab939fe08 100644--- a/src/platform/windows.rs+++ b/src/platform/windows.rs@@ -65,6 +65,8 @@ use windows_service::{use winreg::enums::*;use winreg::RegKey;+pub const FLUTTER_RUNNER_WIN32_WINDOW_CLASS: &'static str = "FLUTTER_RUNNER_WIN32_WINDOW";+pub fn get_focused_display(displays: Vec<DisplayInfo>) -> Option<usize> {unsafe {let hWnd = GetForegroundWindow();@@ -2419,3 +2421,33 @@ pub fn is_x64() -> bool {}unsafe { sys_info.u.s().wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 }}++#[cfg(feature = "flutter")]+pub fn kill_flutter_main_window() {+ // It is used to kill the hidden flutter main window process, it can also kill the install window process+ log::info!("kill flutter main window");+ unsafe {+ let window_name = wide_string(&crate::get_app_name());+ let class_name = wide_string(FLUTTER_RUNNER_WIN32_WINDOW_CLASS);+ let hwnd = FindWindowW(class_name.as_ptr(), window_name.as_ptr());+ if hwnd.is_null() {+ return;+ }+ let mut process_id: u32 = 0;+ GetWindowThreadProcessId(hwnd, &mut process_id as *mut u32);+ if process_id == 0 {+ return;+ }+ let output = Command::new("taskkill")+ .arg("/F")+ .arg("/PID")+ .arg(process_id.to_string())+ .output()+ .expect("Failed to execute command");+ if output.status.success() {+ log::info!("kill flutter main window success");+ } else {+ log::error!("kill flutter main window failed");+ }+ }+}