[fix] disconnect remote sessions when closing DeskHub

This commit is contained in:
dijunkun
2026-10-14 04:17:44 +08:00
parent 0a6356085d
commit 417ef7d58c
3 changed files with 30 additions and 13 deletions
@@ -1517,10 +1517,9 @@ void GuiApplication::BindMainCallbacks(bool gallery_window) {
}
});
main->window().on_close_requested([this, main] {
// Keep the application and all active sessions alive. The tray helper
// ensures that supported platforms still provide a way to restore the
// main window; Slint hides it regardless of tray availability.
if (main->get_gallery_mode()) HideGalleryWindow();
// Closing DeskHub disconnects its remote sessions. The connection window
// still minimizes to the tray without terminating the application.
if (main->get_gallery_mode()) CloseGalleryWindow();
else MinimizeMainWindowToTray();
return slint::CloseRequestResponse::HideWindow;
});
@@ -1539,7 +1538,7 @@ void GuiApplication::BindMainCallbacks(bool gallery_window) {
if (!ui_) {
return;
}
if (main->get_gallery_mode()) HideGalleryWindow();
if (main->get_gallery_mode()) CloseGalleryWindow();
else MinimizeMainWindowToTray();
main->hide();
});
@@ -4463,9 +4462,28 @@ void GuiApplication::ShowGalleryWindow() {
SyncGallery();
}
void GuiApplication::HideGalleryWindow() {
void GuiApplication::CloseGalleryWindow() {
if (!ui_) return;
ReleaseControl();
// Snapshot all receivers, not just the current wall page/group. Include
// requests without a live session so no queued work can reconnect on close.
std::set<std::string> disconnect_ids;
{
std::shared_lock lock(remote_sessions_mutex_);
for (const auto& [id, _] : remote_sessions_) disconnect_ids.insert(id);
}
for (const auto& [id, _] : pending_reconnects_) disconnect_ids.insert(id);
for (const auto& operation : ui_->batch_operations)
disconnect_ids.insert(operation.id);
{
std::lock_guard lock(pending_presence_probe_mutex_);
if (!pending_presence_remote_id_.empty())
disconnect_ids.insert(pending_presence_remote_id_);
}
// Reuse explicit disconnect: cancel retries, release input/media resources,
// and queue peer teardown without waiting for the transport on the UI thread.
for (const auto& id : disconnect_ids) CloseStreamTab(id);
need_to_rejoin_ = false;
ui_->wall->invoke_reset_gallery_transient();
ui_->wall->set_alias_open(false);
ui_->wall->set_delete_open(false);
@@ -4476,11 +4494,9 @@ void GuiApplication::HideGalleryWindow() {
ui_->wall->set_messages_open(false);
ResetSettingsUi(true);
ui_->gallery_requested_auth.clear();
if (!ui_->gallery_auth_id.empty()) {
ui_->gallery_auth_id.clear();
show_connection_status_window_ = false;
ui_->wall->set_connection_dialog_open(false);
}
ui_->gallery_auth_id.clear();
show_connection_status_window_ = false;
SyncConnectionDialog();
SyncWindowGeometry(true);
ui_->gallery_transition.Cancel();
ui_->wall->set_gallery_transitioning(false);
@@ -4497,6 +4513,7 @@ void GuiApplication::HideGalleryWindow() {
ui_->wall->hide();
ui_->gallery_synced = {};
SyncGallery();
SyncStreamWindow();
}
void GuiApplication::ToggleGalleryFullscreen() {
@@ -61,7 +61,7 @@ private:
void HandleCredentialRecovery();
void SyncMainWindow();
void ShowGalleryWindow();
void HideGalleryWindow();
void CloseGalleryWindow();
void SyncWindowGeometry(bool gallery_window);
void ToggleGalleryFullscreen();
void RestoreWindowGeometry(bool before_show = false,
+1 -1
View File
@@ -1,6 +1,6 @@
# 桌面墙(DeskHub)
主窗口“近期连接”标题行右侧、分组筛选左边的“桌面墙”按钮打开独立的桌面墙窗口。菜单与上方桌面标题共用一行,连接窗口保持紧凑尺寸。重复点击按钮会唤起已有桌面墙窗口,最小化时恢复显示,不创建重复窗口。每次启动软件只显示连接窗口;桌面墙首次打开时恢复保存的位置、尺寸及全屏状态;没有已保存尺寸时默认采用 960 × 720 逻辑像素(含标题栏,当前 macOS 的内容区为 960 × 688),两个窗口分别记忆位置。关闭桌面墙只隐藏该窗口并释放远程操控,保留设备连接;再次点击“桌面墙”即可打开。已断开的显示器所对应的位置会修正到可用屏幕内。
主窗口“近期连接”标题行右侧、分组筛选左边的“桌面墙”按钮打开独立的桌面墙窗口。菜单与上方桌面标题共用一行,连接窗口保持紧凑尺寸。重复点击按钮会唤起已有桌面墙窗口,最小化时恢复显示,不创建重复窗口。每次启动软件只显示连接窗口;桌面墙首次打开时恢复保存的位置、尺寸及全屏状态;没有已保存尺寸时默认采用 960 × 720 逻辑像素(含标题栏,当前 macOS 的内容区为 960 × 688),两个窗口分别记忆位置。关闭桌面墙时释放远程操控并断开全部远程设备连接,不受当前分组、分页和选中状态限制,共用连接的独立串流窗口也随之关闭;同时取消排队连接、密码重试和待重连请求。设备列表、分组与窗口布局保留,再次点击“桌面墙”可打开并手动重新连接设备。最小化窗口不会断开连接。已断开的显示器所对应的位置会修正到可用屏幕内。
桌面墙内容区不再重复显示“桌面墙”标题,顶部仅保留一行工具栏,距窗口内容区顶部 12 逻辑像素;分组、设备数量、“添加”、“选择/完成”、纯文字“精简模式”按钮和全屏图标共用这一行,不显示菜单及消息、更新角标。“添加”、“选择”和“精简模式”默认统一使用浅灰背景、灰色边框及相同的悬停、按下样式;进入选择或精简模式后,对应按钮以蓝色高亮表示当前状态。按钮按当前语言的文字宽度加统一左右内边距自适应,普通文字按钮宽度至少为 48 逻辑像素;内边距默认为 12 逻辑像素,窗口内容区宽度小于 720 时统一收紧为 8,保证最窄窗口下的多语言操作和已选数量可见。下拉按钮额外预留箭头及间距;“选择/完成”和“精简模式/退出精简”按两种状态中较宽的文字预留空间,切换时保持宽度稳定。“选择/完成”固定在视图控制按钮左侧,设备列表紧接工具栏下方,释放原有标题行占用的空间。桌面墙可以单独调整尺寸及全屏,不改变连接窗口的尺寸和位置。全局设置从主窗口菜单进入;设备操作和桌面墙连接的密码弹窗显示在桌面墙窗口内。