diff --git a/docs/changes.txt b/docs/changes.txt index cafb0c207c..58906a5396 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -167,6 +167,7 @@ wxMSW: - Avoid bogus assert after calling wxDatePickerCtrl::SetRange(). - Add solution file for building with MSVS 2014 (Peter Tissen). - Correct wxGetOsDescription() for Windows 10 (Tobias Taschner). +- Don't send wxActivateEvent for minimized windows (bzcdr). wxOSX/Cocoa: diff --git a/interface/wx/event.h b/interface/wx/event.h index 413c293ba9..3148c50966 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -3005,6 +3005,11 @@ public: a @c wxEVT_ACTIVATE or @c wxEVT_ACTIVATE_APP event. @endEventTable + @note Until wxWidgets 3.1.0 activation events could be sent by wxMSW when + the window was minimized. This reflected the native MSW behaviour but was + often surprising and unexpected, so starting from 3.1.0 such events are not + sent any more when the window is in the minimized state. + @library{wxcore} @category{events} diff --git a/src/msw/window.cpp b/src/msw/window.cpp index bfa3efd17c..34707fad7c 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4044,9 +4044,19 @@ bool wxWindowMSW::HandleDestroy() // --------------------------------------------------------------------------- bool wxWindowMSW::HandleActivate(int state, - bool WXUNUSED(minimized), - WXHWND WXUNUSED(activate)) + bool minimized, + WXHWND WXUNUSED(activate)) { + if ( minimized ) + { + // Getting activation event when the window is minimized, as happens + // e.g. when the window task bar icon is clicked, is unexpected and + // managed to even break the logic in wx itself (see #17128), so just + // don't do it as there doesn't seem to be any need to be notified + // about the activation of the window icon in the task bar in practice. + return false; + } + wxActivateEvent event(wxEVT_ACTIVATE, (state == WA_ACTIVE) || (state == WA_CLICKACTIVE), m_windowId,