Bug 1875831: Only use one method to order popup windows. r=spohl

Currently for popup windows with a parent window we call `orderFront` and
`addChildWindow`, both of which set the popups window level. It appears that
we only need one of these for the popup to appear correctly, using both for
some reason has the side effect of also raising the parent window above all
other application windows. This patch skips the `orderFront` call when we are
also going to call `addChildWindow`.

Also removed the now redundant comment about _setWindowNumber.

Differential Revision: https://phabricator.services.mozilla.com/D205326
This commit is contained in:
Dave Townsend 2024-03-22 14:56:01 +00:00
Родитель 3cafefda9f
Коммит d29c94dd23
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -779,7 +779,9 @@ void nsCocoaWindow::Show(bool aState) {
// calls to ...orderFront: in TRY blocks. See bmo bug 470864.
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
[[mWindow contentView] setNeedsDisplay:YES];
[mWindow orderFront:nil];
if (!nativeParentWindow || mPopupLevel != PopupLevel::Parent) {
[mWindow orderFront:nil];
}
NS_OBJC_END_TRY_IGNORE_BLOCK;
SendSetZLevelEvent();
// If our popup window is a non-native context menu, tell the OS (and
@ -795,9 +797,7 @@ void nsCocoaWindow::Show(bool aState) {
// If a parent window was supplied and this is a popup at the parent
// level, set its child window. This will cause the child window to
// appear above the parent and move when the parent does. Setting this
// needs to happen after the _setWindowNumber calls above, otherwise the
// window doesn't focus properly.
// appear above the parent and move when the parent does.
if (nativeParentWindow && mPopupLevel == PopupLevel::Parent) {
[nativeParentWindow addChildWindow:mWindow ordered:NSWindowAbove];
}