From 13752968eaac3cdd7fec878ed9a7c6886b8a9fb3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 11 Jan 2020 23:13:02 +0100 Subject: [PATCH] Fix closing minimized top level windows under Windows 10 Minimized windows don't seem to get any events after "Close" menu item is selected from the system menu, so they were never actually destroyed when closing them in this way. Fix this by explicitly waking up the message loop after deleting the window to ensure that the delayed destruction does happen. Closes #18622. See https://github.com/wxWidgets/wxWidgets/pull/1690 --- include/wx/msw/toplevel.h | 1 + src/msw/toplevel.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index 5cef6b1e8a..cf6356754a 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -55,6 +55,7 @@ public: virtual bool IsIconized() const wxOVERRIDE; virtual void SetIcons(const wxIconBundle& icons ) wxOVERRIDE; virtual void Restore() wxOVERRIDE; + virtual bool Destroy() wxOVERRIDE; virtual void SetLayoutDirection(wxLayoutDirection dir) wxOVERRIDE; diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index e954f19d14..0a7de130e2 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -823,6 +823,22 @@ void wxTopLevelWindowMSW::Restore() DoShowWindow(SW_RESTORE); } +bool wxTopLevelWindowMSW::Destroy() +{ + if ( !wxTopLevelWindowBase::Destroy() ) + return false; + + // Under Windows 10 iconized windows don't get any messages, so delayed + // destruction doesn't work for them if we don't force a message dispatch + // here (and it doesn't seem useful to test for MSWIsIconized() as doing + // this doesn't do any harm for non-iconized windows neither). For that + // matter, doing this shouldn't do any harm under previous OS versions + // neither, so checking for the OS version doesn't seem useful too. + wxWakeUpIdle(); + + return true; +} + void wxTopLevelWindowMSW::SetLayoutDirection(wxLayoutDirection dir) { if ( dir == wxLayout_Default )