From 7d96ee2fe653a42c8cda8231cba2e205117018c5 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Wed, 19 Jan 2022 10:01:39 +0800 Subject: [PATCH] Bug 1740389; r=handyman, a=tjr Bug 1735071: Make Windows non-ePopupLevelTop popups respect owner z-order. r=edgar, a=tjr --- widget/windows/nsWindow.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 0b3c129edc..1dc25c6964 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -1587,7 +1587,20 @@ NS_IMETHODIMP nsWindow::Show(bool bState) // the popup. flags |= SWP_NOACTIVATE; HWND owner = ::GetWindow(mWnd, GW_OWNER); - ::SetWindowPos(mWnd, owner ? 0 : HWND_TOPMOST, 0, 0, 0, 0, flags); + if (owner) { + // ePopupLevelTop popups should be above all else. All other + // types should be placed in front of their owner, without + // changing the owner's z-level relative to other windows. + if (PopupLevel() != ePopupLevelTop) { + ::SetWindowPos(mWnd, owner, 0, 0, 0, 0, flags); + ::SetWindowPos(owner, mWnd, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + } else { + ::SetWindowPos(mWnd, HWND_TOP, 0, 0, 0, 0, flags); + } + } else { + ::SetWindowPos(mWnd, HWND_TOPMOST, 0, 0, 0, 0, flags); + } } else { if (mWindowType == eWindowType_dialog && !CanTakeFocus()) flags |= SWP_NOACTIVATE; @@ -3449,8 +3462,6 @@ nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen) taskbarInfo->PrepareFullScreenHWND(mWnd, TRUE); } } else { - if (mSizeMode != nsSizeMode_Fullscreen) - return NS_OK; SetSizeMode(mOldSizeMode); }