Skip to content

Commit 973287f

Browse files
committed
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
1 parent f28b3bb commit 973287f

File tree

1 file changed

+7
-32
lines changed

1 file changed

+7
-32
lines changed

xpfe/appshell/nsAppShellService.cpp

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -503,37 +503,6 @@ uint32_t nsAppShellService::CalculateWindowZLevel(nsIAppWindow* aParent,
503503
return zLevel;
504504
}
505505

506-
#ifdef XP_WIN
507-
/*
508-
* Checks to see if any existing window is currently in fullscreen mode.
509-
*/
510-
static bool CheckForFullscreenWindow() {
511-
nsCOMPtr<nsIWindowMediator> wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
512-
if (!wm) return false;
513-
514-
nsCOMPtr<nsISimpleEnumerator> windowList;
515-
wm->GetAppWindowEnumerator(nullptr, getter_AddRefs(windowList));
516-
if (!windowList) return false;
517-
518-
for (;;) {
519-
bool more = false;
520-
windowList->HasMoreElements(&more);
521-
if (!more) return false;
522-
523-
nsCOMPtr<nsISupports> supportsWindow;
524-
windowList->GetNext(getter_AddRefs(supportsWindow));
525-
nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supportsWindow));
526-
if (baseWin) {
527-
nsCOMPtr<nsIWidget> widget;
528-
baseWin->GetMainWidget(getter_AddRefs(widget));
529-
if (widget && widget->SizeMode() == nsSizeMode_Fullscreen) {
530-
return true;
531-
}
532-
}
533-
}
534-
}
535-
#endif
536-
537506
/*
538507
* Just do the window-making part of CreateTopLevelWindow
539508
*/
@@ -554,7 +523,13 @@ nsresult nsAppShellService::JustCreateTopWindow(
554523
// If the parent is currently fullscreen, tell the child to ignore persisted
555524
// full screen states. This way new browser windows open on top of fullscreen
556525
// windows normally.
557-
if (window && CheckForFullscreenWindow()) window->IgnoreXULSizeMode(true);
526+
if (nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(aParent)) {
527+
nsCOMPtr<nsIWidget> widget;
528+
baseWin->GetMainWidget(getter_AddRefs(widget));
529+
if (widget && widget->SizeMode() == nsSizeMode_Fullscreen) {
530+
window->IgnoreXULSizeMode(true);
531+
}
532+
}
558533
#endif
559534

560535
widget::InitData widgetInitData;

0 commit comments

Comments
 (0)