From 53bd8aae73aab8b45d968a19f7ae8e86f425b0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Fri, 24 Jul 2026 11:21:42 +0200 Subject: [PATCH] [client] Keep tray quit state across an aborted Windows session end An aborted session end (WM_ENDSESSION with wParam == 0) cleared the shared shutdown flag, re-enabling hide-on-close cancels and dialogs while a tray quit was still tearing down. Track the session-end and tray-quit sources as separate flags; aborting a session end only clears its own state. --- client/ui/services/shutdown.go | 19 +++++++++++++------ client/ui/shutdown_windows.go | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/ui/services/shutdown.go b/client/ui/services/shutdown.go index 81d517099..0da51940c 100644 --- a/client/ui/services/shutdown.go +++ b/client/ui/services/shutdown.go @@ -2,16 +2,23 @@ package services import "sync/atomic" -var shuttingDown atomic.Bool +var ( + sessionEnding atomic.Bool + quitting atomic.Bool +) -func BeginShutdown() { - shuttingDown.Store(true) +func BeginSessionEnd() { + sessionEnding.Store(true) } -func AbortShutdown() { - shuttingDown.Store(false) +func AbortSessionEnd() { + sessionEnding.Store(false) +} + +func BeginShutdown() { + quitting.Store(true) } func ShuttingDown() bool { - return shuttingDown.Load() + return sessionEnding.Load() || quitting.Load() } diff --git a/client/ui/shutdown_windows.go b/client/ui/shutdown_windows.go index 2f351b1ce..fbb92a518 100644 --- a/client/ui/shutdown_windows.go +++ b/client/ui/shutdown_windows.go @@ -19,11 +19,11 @@ func endSessionInterceptor() func(hwnd uintptr, msg uint32, wParam, lParam uintp return func(_ uintptr, msg uint32, wParam, _ uintptr) (uintptr, bool) { switch msg { case wmQueryEndSession: - services.BeginShutdown() + services.BeginSessionEnd() return 1, true case wmEndSession: if wParam == 0 { - services.AbortShutdown() + services.AbortSessionEnd() return 0, true } log.Info("windows session is ending; exiting immediately")