Fix apparent activation loss after hiding previous popup
Commit 58d4b0e209
introduced a regression:
if a previous popup still existed when the new one was shown, dismissing
the second popup would result in the owner window losing its "active"
appearance.
This was due to the fact that ::GetActiveWindow() still returned the
former popup when it was about to be dismissed, so it was too early to
call it in WM_NCACTIVATE handler. Do it now in DismissOnDeactivate()
itself which is both simpler and more correct.
This commit is contained in:
@@ -152,7 +152,7 @@ public:
|
||||
WXLPARAM lParam) wxOVERRIDE;
|
||||
|
||||
private:
|
||||
void DismissOnDeactivate(WXHWND hwndActive);
|
||||
void DismissOnDeactivate();
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxPopupTransientWindow);
|
||||
wxDECLARE_NO_COPY_CLASS(wxPopupTransientWindow);
|
||||
|
@@ -192,7 +192,7 @@ void wxPopupTransientWindow::Dismiss()
|
||||
Hide();
|
||||
}
|
||||
|
||||
void wxPopupTransientWindow::DismissOnDeactivate(WXHWND hwndActive)
|
||||
void wxPopupTransientWindow::DismissOnDeactivate()
|
||||
{
|
||||
// Hide the window automatically when it loses activation.
|
||||
Dismiss();
|
||||
@@ -203,7 +203,7 @@ void wxPopupTransientWindow::DismissOnDeactivate(WXHWND hwndActive)
|
||||
wxWindow* const owner = MSWGetOwner();
|
||||
if ( owner )
|
||||
{
|
||||
if ( hwndActive != GetHwndOf(owner) )
|
||||
if ( ::GetActiveWindow() != GetHwndOf(owner) )
|
||||
{
|
||||
::SendMessage(GetHwndOf(owner), WM_NCACTIVATE, FALSE, 0);
|
||||
}
|
||||
@@ -218,18 +218,17 @@ wxPopupTransientWindow::MSWHandleMessage(WXLRESULT *result,
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_NCACTIVATE:
|
||||
if ( !wParam )
|
||||
case WM_ACTIVATE:
|
||||
if ( wParam == WA_INACTIVE )
|
||||
{
|
||||
// We need to dismiss this window, however doing it directly
|
||||
// from here seems to confuse ::ShowWindow(), which ends up
|
||||
// calling this handler, and may result in losing activation
|
||||
// entirely, so postpone it slightly.
|
||||
//
|
||||
// Note that we do use the currently active window, just in
|
||||
// case it changes between now and the next idle event.
|
||||
CallAfter(&wxPopupTransientWindow::DismissOnDeactivate,
|
||||
::GetActiveWindow());
|
||||
// Also note that the active window hasn't changed yet, so we
|
||||
// postpone calling it until DismissOnDeactivate() is executed.
|
||||
CallAfter(&wxPopupTransientWindow::DismissOnDeactivate);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user