From dda052d38ab02951d0c3bc65adff3d14f8f40c38 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Dec 2019 16:47:49 +0100 Subject: [PATCH] Fix activation loss when hiding floating frame TLW in wxMSW Generalize the fix of d6fb86a81c099a49304eebefd14c1f416aac21ca and explicitly activate the parent when a TLW with wxFRAME_FLOAT_ON_PARENT style is hidden or minimized and not only when it is destroyed. Closes #18535. --- src/msw/toplevel.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index d2355b0179..e954f19d14 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -577,19 +577,6 @@ wxTopLevelWindowMSW::~wxTopLevelWindowMSW() delete m_menuSystem; SendDestroyEvent(); - - // after destroying an owned window, Windows activates the next top level - // window in Z order but it may be different from our owner (to reproduce - // this simply Alt-TAB to another application and back before closing the - // owned frame) whereas we always want to yield activation to our parent - if ( HasFlag(wxFRAME_FLOAT_ON_PARENT) ) - { - wxWindow *parent = GetParent(); - if ( parent ) - { - ::BringWindowToTop(GetHwndOf(parent)); - } - } } // ---------------------------------------------------------------------------- @@ -598,6 +585,26 @@ wxTopLevelWindowMSW::~wxTopLevelWindowMSW() void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd) { + // After hiding or minimizing an owned window, Windows activates the next + // top level window in Z order but it may be different from our owner (to + // reproduce this simply Alt-TAB to another application and back before + // closing the owned frame) whereas we always want to yield activation to + // our parent, so do it explicitly _before_ yielding activation. + switch ( nShowCmd ) + { + case SW_HIDE: + case SW_MINIMIZE: + if ( HasFlag(wxFRAME_FLOAT_ON_PARENT) ) + { + wxWindow *parent = GetParent(); + if ( parent ) + { + ::BringWindowToTop(GetHwndOf(parent)); + } + } + break; + } + ::ShowWindow(GetHwnd(), nShowCmd); #if wxUSE_TOOLTIPS