Commit 5fe142be authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez Committed by dsmith@mozilla.com
Browse files

Bug 1977581 - Keep activating the parent window on Windows when destroying a...

Bug 1977581 - Keep activating the parent window on Windows when destroying a child. r=win-reviewers,handyman, a=dsmith

Bug 1902315 removed a PlaceBehind call here, which in this case happened
to also activate the window (via the aActivate = true parameter).

Keep raising the window manually, but with simpler APIs.

Differential Revision: https://phabricator.services.mozilla.com/D258743
parent 78b1e3e8
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -547,6 +547,19 @@ NS_IMETHODIMP AppWindow::Destroy() {
  if (mWindow) mWindow->Show(false);
#endif

  // Raise and focus our parent explicitly on Windows, if visible. Apparently
  // Windows gets the z-order and focus wrong otherwise for nested modal
  // windows, see bug 1977581.
#ifdef XP_WIN
  if (nsCOMPtr<nsIBaseWindow> parent = do_QueryReferent(mParentWindow)) {
    nsCOMPtr<nsIWidget> parentWidget;
    parent->GetMainWidget(getter_AddRefs(parentWidget));
    if (parentWidget && parentWidget->IsVisible()) {
      parentWidget->SetFocus(nsIWidget::Raise::Yes, dom::CallerType::System);
    }
  }
#endif

  RemoveTooltipSupport();

  mDOMWindow = nullptr;