mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
opt: close main window when exit from tray on macOS
This commit is contained in:
10
src/ipc.rs
10
src/ipc.rs
@@ -36,6 +36,8 @@ pub enum PrivacyModeState {
|
||||
OffByPeer,
|
||||
OffUnknown,
|
||||
}
|
||||
// IPC actions here.
|
||||
pub const IPC_ACTION_CLOSE: &str = "close";
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(tag = "t", content = "c")]
|
||||
@@ -871,6 +873,14 @@ pub async fn send_url_scheme(url: String) -> ResultType<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Emit `close` events to ipc.
|
||||
pub fn close_all_instances() -> ResultType<bool> {
|
||||
match crate::ipc::send_url_scheme(IPC_ACTION_CLOSE.to_owned()) {
|
||||
Ok(_) => Ok(true),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -211,6 +211,7 @@ pub fn uninstall(show_new_window: bool) -> bool {
|
||||
);
|
||||
if uninstalled {
|
||||
crate::ipc::set_option("stop-service", "Y");
|
||||
let _ = crate::ipc::close_all_instances();
|
||||
// leave ipc a little time
|
||||
std::thread::sleep(std::time::Duration::from_millis(300));
|
||||
std::process::Command::new("launchctl")
|
||||
|
||||
Reference in New Issue
Block a user