mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-11 10:59:06 +08:00
[fix] avoid blocking Windows shutdown and restore display modes
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "platform/windows/gui/slint_backend.h"
|
||||
#include "platform/windows/gui/shutdown_session_guard.h"
|
||||
#include "platform/windows/gui/session_end_observer.h"
|
||||
#include "platform/windows/gui/tray/win_tray.h"
|
||||
#include "platform/windows/gui/window_icons.h"
|
||||
#include "platform/windows/gui/window_taskbar.h"
|
||||
@@ -989,8 +989,7 @@ void DragWindow(WindowHandle& component, int phase, float mouse_x,
|
||||
|
||||
struct GuiApplication::SlintUi {
|
||||
#if _WIN32
|
||||
std::unique_ptr<ShutdownSessionGuard> shutdown_guard;
|
||||
std::wstring_view shutdown_reason;
|
||||
SessionEndObserver session_end;
|
||||
#endif
|
||||
gallery::Workspace gallery;
|
||||
std::filesystem::path gallery_path;
|
||||
@@ -1397,8 +1396,7 @@ void GuiApplication::InitializeUi() {
|
||||
ui_->main->set_lan_mode(config_center_->GetConnectionMode() ==
|
||||
ConfigCenter::CONNECTION_MODE::DIRECT_IP);
|
||||
#if _WIN32
|
||||
ui_->shutdown_guard =
|
||||
std::make_unique<ShutdownSessionGuard>(windows_rdp_handoff_connected_);
|
||||
ui_->session_end.Start();
|
||||
#endif
|
||||
ui_->sponsorship_prompt_pending =
|
||||
config_center_->GetSponsorshipPromptDismissedVersion() != CROSSDESK_VERSION;
|
||||
@@ -2533,6 +2531,12 @@ void GuiApplication::BindServerCallbacks() {
|
||||
}
|
||||
|
||||
void GuiApplication::Tick() {
|
||||
#if _WIN32
|
||||
if (ui_) {
|
||||
ui_->session_end.Start(); // Retry a transient native-window creation failure.
|
||||
if (ui_->session_end.Ending()) exit_ = true;
|
||||
}
|
||||
#endif
|
||||
if (exit_) {
|
||||
BeginShutdown();
|
||||
if (ShutdownDrained()) slint::quit_event_loop();
|
||||
@@ -2647,11 +2651,6 @@ void GuiApplication::Tick() {
|
||||
? std::string("ConnectionFailed")
|
||||
: lan_error_;
|
||||
ui_->main->set_lan_message(UiText(lan_message));
|
||||
#if _WIN32
|
||||
if (ui_->shutdown_guard) {
|
||||
ui_->shutdown_guard->Update(ui_->shutdown_reason);
|
||||
}
|
||||
#endif
|
||||
PollUpdateCheck();
|
||||
HandleSessionCleanup();
|
||||
HandlePasswordChangeResult();
|
||||
@@ -3280,9 +3279,6 @@ void GuiApplication::UpdateLocalization() {
|
||||
return;
|
||||
}
|
||||
#if _WIN32
|
||||
static std::vector<std::wstring> shutdown_reasons(localization::GetSupportedLanguages().size());
|
||||
ui_->shutdown_reason = localization::GetWindowsLocalizedLabel(
|
||||
language, "shutdown_reason", L"Remote session active.", shutdown_reasons);
|
||||
const bool available = SupportsServiceAutostart();
|
||||
for (const auto& main : {ui_->main, ui_->wall}) {
|
||||
main->set_service_autostart_platform(true);
|
||||
@@ -7081,9 +7077,6 @@ void GuiApplication::Cleanup() {
|
||||
return;
|
||||
}
|
||||
ui_->file_dialog_lifetime.reset();
|
||||
#if _WIN32
|
||||
ui_->shutdown_guard.reset();
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
CancelNativeFileDialog();
|
||||
#endif
|
||||
|
||||
@@ -433,7 +433,6 @@ inline constexpr TranslationRow kTranslationRows[] = {
|
||||
{"近期连接", {"近期连接", "Recent Connections", "Недавние подключения", "近期連線", "最近の接続", "최근 연결", "Aktuelle Verbindungen", "Connexions récentes", "Conexiones recientes", "Conexões recentes"}},
|
||||
{"返回", {"返回", "Back", "Назад", "返回", "戻る", "뒤로", "Zurück", "Retour", "Volver", "Voltar"}},
|
||||
{"还原窗口", {"还原窗口", "Restore window", "Восстановить окно", "還原視窗", "復元ウィンドウ", "복원 창", "Fenster „Wiederherstellen“.", "Fenêtre de restauration", "Restaurar ventana", "Janela de restauração"}},
|
||||
{"远程控制连接中,保留连接以确认或取消关机。", {"远程控制连接中,保留连接以确认或取消关机。", "Remote session active. Keeping the connection available to confirm or cancel shutdown.", "Удалённый сеанс активен. Соединение сохранено для подтверждения или отмены выключения.", "遠端控制連線中,保留連線以確認或取消關機。", "リモート接続中です。シャットダウンの確認または取り消しのため、接続を維持しています。", "원격 세션이 활성화되어 있습니다. 종료 확인 또는 취소를 위해 연결을 유지합니다.", "Remotesitzung aktiv. Die Verbindung bleibt zum Bestätigen oder Abbrechen des Herunterfahrens bestehen.", "Session distante active. La connexion reste disponible pour confirmer ou annuler l’arrêt.", "Sesión remota activa. Se mantiene la conexión para confirmar o cancelar el apagado.", "Sessão remota ativa. A conexão é mantida para confirmar ou cancelar o desligamento."}},
|
||||
{"远程桌面", {"远程桌面", "Remote Desktop", "Удаленный рабочий стол", "遠端桌面", "リモートデスクトップ", "원격 데스크톱", "Remotedesktop", "Bureau à distance", "Escritorio remoto", "Área de Trabalho Remota"}},
|
||||
{"远端 IP / 端口", {"远端 IP / 端口", "Remote IP / Port", "Удалённый IP / Порт", "遠端 IP / 埠", "リモートIP/ポート", "원격 IP / 포트", "Remote-IP/Port", "IP/port distant", "IP/puerto remoto", "IP/Porta Remota"}},
|
||||
{"远端 Windows 服务不可用", {"远端 Windows 服务不可用", "Remote Windows service unavailable", "Служба Windows на удаленной стороне недоступна", "遠端 Windows 服務不可用", "リモート Windows サービスが利用できない", "원격 Windows 서비스를 사용할 수 없습니다.", "Remote-Windows-Dienst nicht verfügbar", "Service Windows distant indisponible", "Servicio remoto de Windows no disponible", "Serviço remoto do Windows indisponível"}},
|
||||
@@ -840,7 +839,6 @@ inline constexpr NamedTranslation kNamedTranslations[] = {
|
||||
{"privacy_unlock_lock", "锁定"},
|
||||
{"privacy_screen_unlock_hint", "按下快捷键,解除隐私屏"},
|
||||
{"exit_program", "退出"},
|
||||
{"shutdown_reason", "远程控制连接中,保留连接以确认或取消关机。"},
|
||||
{"pause_video_when_minimized", "最小化时暂停视频"},
|
||||
{"pause_video_when_minimized_hint", "控制窗口最小化时暂停接收视频,降低本机解码资源占用。"},
|
||||
{"system_permissions", "系统权限"},
|
||||
@@ -1352,7 +1350,6 @@ inline constexpr const char* kSlintLiterals[] = {
|
||||
X(privacy_unlock_lock) \
|
||||
X(privacy_screen_unlock_hint) \
|
||||
X(exit_program) \
|
||||
X(shutdown_reason) \
|
||||
X(pause_video_when_minimized) \
|
||||
X(pause_video_when_minimized_hint) \
|
||||
X(system_permissions) \
|
||||
|
||||
Reference in New Issue
Block a user