Bug 1575635 - [1/1] Only use parent window's fullscreen state r=win-reviewers,mhowell

When we open a new window on top of a fullscreen window, we deliberately
make that window "normal" (non-fullscreen, non-maximized), which was
documented as having been "a standard [W]indows convention" [1].
Chromium does the same (with fiddly differences involving the window
size).

Unfortunately, we do this by checking if there are _any_ fullscreen
windows open -- which produces false positives on multimonitor or
multi-virtual-desktop setups.

Therefore, adjust the code to match the original comment, and only take
the parent window into account. This seems likely to better match user
expectations.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=575195#c5

Differential Revision: https://phabricator.services.mozilla.com/D197823
This commit is contained in:
Ray Kraesig 2024-01-09 22:54:46 +00:00
parent f28b3bb7ed
commit 973287f3eb

View File

@ -503,37 +503,6 @@ uint32_t nsAppShellService::CalculateWindowZLevel(nsIAppWindow* aParent,
return zLevel;
}
#ifdef XP_WIN
/*
* Checks to see if any existing window is currently in fullscreen mode.
*/
static bool CheckForFullscreenWindow() {
nsCOMPtr<nsIWindowMediator> wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
if (!wm) return false;
nsCOMPtr<nsISimpleEnumerator> windowList;
wm->GetAppWindowEnumerator(nullptr, getter_AddRefs(windowList));
if (!windowList) return false;
for (;;) {
bool more = false;
windowList->HasMoreElements(&more);
if (!more) return false;
nsCOMPtr<nsISupports> supportsWindow;
windowList->GetNext(getter_AddRefs(supportsWindow));
nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supportsWindow));
if (baseWin) {
nsCOMPtr<nsIWidget> widget;
baseWin->GetMainWidget(getter_AddRefs(widget));
if (widget && widget->SizeMode() == nsSizeMode_Fullscreen) {
return true;
}
}
}
}
#endif
/*
* Just do the window-making part of CreateTopLevelWindow
*/
@ -554,7 +523,13 @@ nsresult nsAppShellService::JustCreateTopWindow(
// If the parent is currently fullscreen, tell the child to ignore persisted
// full screen states. This way new browser windows open on top of fullscreen
// windows normally.
if (window && CheckForFullscreenWindow()) window->IgnoreXULSizeMode(true);
if (nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(aParent)) {
nsCOMPtr<nsIWidget> widget;
baseWin->GetMainWidget(getter_AddRefs(widget));
if (widget && widget->SizeMode() == nsSizeMode_Fullscreen) {
window->IgnoreXULSizeMode(true);
}
}
#endif
widget::InitData widgetInitData;