opt: prevent duplicate window instance on windows
This commit is contained in:
parent
45c0e10102
commit
1da141e6a7
@ -1310,7 +1310,7 @@ bool callUniLinksUriHandler(Uri uri) {
|
|||||||
Future.delayed(Duration.zero, () {
|
Future.delayed(Duration.zero, () {
|
||||||
rustDeskWinManager.newRemoteDesktop(peerId);
|
rustDeskWinManager.newRemoteDesktop(peerId);
|
||||||
});
|
});
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ class RustDeskMultiWindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Remove active window which has [`windowId`]
|
/// Remove active window which has [`windowId`]
|
||||||
///
|
///
|
||||||
/// [Availability]
|
/// [Availability]
|
||||||
/// This function should only be called from main window.
|
/// This function should only be called from main window.
|
||||||
/// For other windows, please post a unregister(hide) event to main window handler:
|
/// For other windows, please post a unregister(hide) event to main window handler:
|
||||||
|
@ -52,18 +52,20 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
free_c_args(c_args, args_len);
|
free_c_args(c_args, args_len);
|
||||||
|
|
||||||
// uni links dispatch
|
// uni links dispatch
|
||||||
// only do uni links when dispatch a rustdesk links
|
HWND hwnd = ::FindWindow(_T("FLUTTER_RUNNER_WIN32_WINDOW"), _T("RustDesk"));
|
||||||
auto prefix = std::string(uniLinksPrefix);
|
if (hwnd != NULL) {
|
||||||
if (!command_line_arguments.empty() && command_line_arguments.front().compare(0, prefix.size(), prefix.c_str()) == 0) {
|
if (!command_line_arguments.empty()) {
|
||||||
HWND hwnd = ::FindWindow(_T("FLUTTER_RUNNER_WIN32_WINDOW"), _T("RustDesk"));
|
// Dispatch command line arguments
|
||||||
if (hwnd != NULL) {
|
|
||||||
DispatchToUniLinksDesktop(hwnd);
|
DispatchToUniLinksDesktop(hwnd);
|
||||||
|
} else {
|
||||||
|
// Not called with arguments, or just open the app shortcut on desktop.
|
||||||
|
// So we just show the main window instead.
|
||||||
::ShowWindow(hwnd, SW_NORMAL);
|
::ShowWindow(hwnd, SW_NORMAL);
|
||||||
::SetForegroundWindow(hwnd);
|
::SetForegroundWindow(hwnd);
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach to console when present (e.g., 'flutter run') or create a
|
// Attach to console when present (e.g., 'flutter run') or create a
|
||||||
// new console when running with a debugger.
|
// new console when running with a debugger.
|
||||||
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent())
|
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent())
|
||||||
|
@ -322,7 +322,7 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
|||||||
"RustDesk",
|
"RustDesk",
|
||||||
(WM_USER + 2) as _, // referred from unilinks desktop pub
|
(WM_USER + 2) as _, // referred from unilinks desktop pub
|
||||||
uni_links.as_str(),
|
uni_links.as_str(),
|
||||||
true,
|
false,
|
||||||
);
|
);
|
||||||
return if res { None } else { Some(Vec::new()) };
|
return if res { None } else { Some(Vec::new()) };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user