Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

fix(windows): allow existing session to foreground (#16349)

Tayfur Yıldız17feabbcabe8
diff --git a/flutter/windows/runner/main.cpp b/flutter/windows/runner/main.cpp
index ea9152ec7..747d6f586 100644
--- a/flutter/windows/runner/main.cpp
+++ b/flutter/windows/runner/main.cpp
@@ -104,6 +104,14 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
}
if (!allow_multiple_instances) {
if (!command_line_arguments.empty()) {
+ // The process launched by the browser owns the foreground permission.
+ // Transfer it to the existing RustDesk process before dispatching the
+ // URI so that it can bring an existing session to the foreground.
+ DWORD pid = 0;
+ ::GetWindowThreadProcessId(hwnd, &pid);
+ if (pid != 0) {
+ ::AllowSetForegroundWindow(pid);
+ }
// Dispatch command line arguments
DispatchToUniLinksDesktop(hwnd);
} else {