diff --git a/sources/suspend-handler/SuspendHandlerWindows.cpp b/sources/suspend-handler/SuspendHandlerWindows.cpp index adbb3f2f4..c7c27b4f6 100644 --- a/sources/suspend-handler/SuspendHandlerWindows.cpp +++ b/sources/suspend-handler/SuspendHandlerWindows.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #pragma comment (lib, "WtsApi32.Lib") @@ -49,7 +50,12 @@ namespace static void SuspendHandlerQueueHandler(WPARAM wparam) { - if (instance != nullptr) + if (wparam == 0) + { + auto instance = QCoreApplication::instance(); + QUEUE_CALL_0(instance, quit); + } + else if (instance != nullptr) { MSG message{}; QByteArray eventType; diff --git a/sources/systray/SystrayWindows.cpp b/sources/systray/SystrayWindows.cpp index 301e28600..0d455b1a9 100644 --- a/sources/systray/SystrayWindows.cpp +++ b/sources/systray/SystrayWindows.cpp @@ -71,6 +71,13 @@ static LRESULT CALLBACK _tray_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, } return true; + case WM_QUERYENDSESSION: + if (queueHandler != nullptr && lparam == 0) + { + queueHandler(0); + } + return false; + case WM_CLOSE: DestroyWindow(hwnd); hwnd = nullptr;