From 484130049da613470add1fd6902891ea093854f5 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Tue, 10 Sep 2013 03:14:21 -0700 Subject: [PATCH] On windows, ignore WM_QUERYENDSESSION and close upon WM_ENDSESSION. The messages can come through CFrame::MSWWindowProc and the wxApp implementation, so make sure to catch both. Fixes issue 6546. --- Source/Core/DolphinWX/Src/Frame.cpp | 15 +++++++++++++++ Source/Core/DolphinWX/Src/Main.cpp | 11 +++++++++++ Source/Core/DolphinWX/Src/Main.h | 1 + 3 files changed, 27 insertions(+) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 9c76cd5420..b54438b905 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -539,9 +539,24 @@ void CFrame::OnResize(wxSizeEvent& event) WXLRESULT CFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { if (WM_SYSCOMMAND == nMsg && (SC_SCREENSAVE == wParam || SC_MONITORPOWER == wParam)) + { return 0; + } + else if (nMsg == WM_QUERYENDSESSION) + { + // Indicate that the application will be able to close + return 1; + } + else if (nMsg == WM_ENDSESSION) + { + // Actually trigger the close now + Close(true); + return 0; + } else + { return wxFrame::MSWWindowProc(nMsg, wParam, lParam); + } } #endif diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index f904ceb0f6..30593ac637 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -71,6 +71,8 @@ IMPLEMENT_APP(DolphinApp) BEGIN_EVENT_TABLE(DolphinApp, wxApp) EVT_TIMER(wxID_ANY, DolphinApp::AfterInit) + EVT_QUERY_END_SESSION(DolphinApp::OnEndSession) + EVT_END_SESSION(DolphinApp::OnEndSession) END_EVENT_TABLE() #include @@ -433,6 +435,15 @@ void DolphinApp::InitLanguageSupport() } } +void DolphinApp::OnEndSession(wxCloseEvent& event) +{ + // Close if we've recieved wxEVT_END_SESSION (ignore wxEVT_QUERY_END_SESSION) + if (!event.CanVeto()) + { + main_frame->Close(true); + } +} + int DolphinApp::OnExit() { WiimoteReal::Shutdown(); diff --git a/Source/Core/DolphinWX/Src/Main.h b/Source/Core/DolphinWX/Src/Main.h index d3e1493e58..08d67e4dda 100644 --- a/Source/Core/DolphinWX/Src/Main.h +++ b/Source/Core/DolphinWX/Src/Main.h @@ -33,6 +33,7 @@ private: wxLocale *m_locale; void AfterInit(wxTimerEvent& WXUNUSED(event)); + void OnEndSession(wxCloseEvent& event); }; DECLARE_APP(DolphinApp);