Skip to content

Commit 9349836

Browse files
committed
Bug 2064534 - set window taskbar concealment more consistently r=win-reviewers,handyman
I think our previous attempt to fix this in bug 1957069 was calling OnWindowMaximized() too early for windows that didn't adopt the PreXULSkeletonUI. Now we wait to call it until the window is shown. We also call it if we're turning on the custom titlebar, which we know is when Windows has trouble figuring this out. Additionally, add a pref to always clear NonRudeHWND for non-fullscreen windows once they are showing. Differential Revision: https://phabricator.services.mozilla.com/D320225
1 parent 224c0c0 commit 9349836

4 files changed

Lines changed: 68 additions & 14 deletions

File tree

‎modules/libpref/init/StaticPrefList.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21069,6 +21069,15 @@
2106921069
value: 2
2107021070
mirror: always
2107121071

21072+
# Whether to always set "NonRudeHWND" on non-fullscreen visible windows,
21073+
# which seems to give us the benefit of using "NonRudeHWND" for the
21074+
# fullscreen_marking_method without causing issues with the taskbar showing
21075+
# when Firefox is fullscreen. (bug 1965699)
21076+
- name: widget.windows.fullscreen_set_nonrudehwnd
21077+
type: RelaxedAtomicBool
21078+
value: true
21079+
mirror: always
21080+
2107221081
# Whether to open the Windows file and folder pickers "remotely" (in a utility
2107321082
# process) or "locally" (in the main process).
2107421083
#

‎widget/windows/nsWindow.cpp‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,17 +1651,6 @@ void nsWindow::Show(bool aState) {
16511651
::NotifyWinEvent(EVENT_OBJECT_FOCUS, mWnd, OBJID_CLIENT, CHILDID_SELF);
16521652
}
16531653
#endif // defined(ACCESSIBILITY)
1654-
1655-
// A window that took over the pre-XUL skeleton UI was born in its size mode
1656-
// rather than transitioning into it, so
1657-
// TaskbarConcealer::OnWindowMaximized() was never called and Windows may
1658-
// misdetect the maximized window as fullscreen. BrowserGlue applies the
1659-
// custom titlebar before showing the window, so mCustomNonClient is already
1660-
// accurate here.
1661-
if (mCustomNonClient &&
1662-
mFrameState->GetSizeMode() == nsSizeMode_Maximized) {
1663-
TaskbarConcealer::OnWindowMaximized(this, /* aForce = */ true);
1664-
}
16651654
}
16661655

16671656
MOZ_ASSERT_IF(mWindowType == WindowType::Popup,
@@ -1832,6 +1821,16 @@ void nsWindow::Show(bool aState) {
18321821
}
18331822
}
18341823

1824+
if (aState && mWnd) {
1825+
// Windows may misdetect a maximized window with a custom non-client area as
1826+
// fullscreen, which stops an auto-hiding taskbar from appearing. It makes
1827+
// that determination when the window is shown, so the not-fullscreen state
1828+
// has to be re-asserted here: marking it any earlier (when the size mode
1829+
// was set, while the window was still hidden) happens too soon to take
1830+
// effect. See bug 1957069 and bug 2064534.
1831+
TaskbarConcealer::OnWindowShown(this);
1832+
}
1833+
18351834
if (!wasVisible && aState) {
18361835
Invalidate();
18371836
if (syncInvalidate && !mInDtor && !mOnDestroyCalled) {
@@ -2830,6 +2829,15 @@ void nsWindow::SetCustomTitlebar(bool aCustomTitlebar) {
28302829
if (ShouldAssociateWithWinAppSDK()) {
28312830
WindowsUIUtils::SetIsTitlebarCollapsed(mWnd, mCustomNonClient);
28322831
}
2832+
2833+
if (mCustomNonClient && mIsVisible &&
2834+
mFrameState->GetSizeMode() == nsSizeMode_Maximized) {
2835+
// Acquiring a custom non-client area is what makes Windows liable to
2836+
// misdetect this maximized window as fullscreen, so re-assert the
2837+
// not-fullscreen state if that happens after the window is already up. See
2838+
// bug 1957069 and bug 2064534.
2839+
TaskbarConcealer::OnWindowMaximized(this, /* aForce = */ true);
2840+
}
28332841
}
28342842

28352843
void nsWindow::SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) {

‎widget/windows/nsWindowTaskbarConcealer.cpp‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void TaskbarConcealerImpl::MarkAsHidingTaskbar(HWND aWnd, bool aMark) {
335335
//
336336
// [0] https://web.archive.org/web/20211223073250/https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist2-markfullscreenwindow
337337

338-
const char* const sMark = aMark ? "true" : "false";
338+
const char* const sMark = aMark ? "false" : "true";
339339

340340
bool const useNonRudeHWND = !!(mMarkingMethod & MarkingMethod::NonRudeHwnd);
341341
bool const usePrepareFullScreen =
@@ -344,9 +344,25 @@ void TaskbarConcealerImpl::MarkAsHidingTaskbar(HWND aWnd, bool aMark) {
344344
// at least one must be set
345345
MOZ_ASSERT(useNonRudeHWND || usePrepareFullScreen);
346346

347-
if (useNonRudeHWND) {
347+
// `PrepareFullScreen()` is known to sometimes fail to clear a misdetection,
348+
// no matter how many times it is called (bug 1949079 comment 15, bug
349+
// 2064534). "NonRudeHWND" is consulted whenever Windows performs a
350+
// fullscreen check rather than being a one-shot signal, so set it as well
351+
// to cover those cases.
352+
//
353+
// Only do so once the window is actually on screen. Per the third bullet
354+
// point above, a window that had this property before it was shown may
355+
// never afterwards be treatable as fullscreen -- which is what bug 1965699
356+
// (fullscreen video failing to conceal the taskbar) appeared to be. Marking
357+
// a window as hiding the taskbar still removes the property outright, so
358+
// going fullscreen clears it either way.
359+
bool forceUseNonRudeHWND =
360+
!aMark && ::IsWindowVisible(aWnd) &&
361+
StaticPrefs::widget_windows_fullscreen_set_nonrudehwnd();
362+
if (useNonRudeHWND || forceUseNonRudeHWND) {
348363
MOZ_LOG(sTaskbarConcealerLog, LogLevel::Info,
349-
("Setting %p[L\"NonRudeHWND\"] to %s", aWnd, sMark));
364+
("Setting %p[L\"NonRudeHWND\"] to %s (forceUseNonRudeHWND is %d)",
365+
aWnd, sMark, forceUseNonRudeHWND ? 1 : 0));
350366

351367
// (setting the property to `FALSE` is not known to be functionally distinct
352368
// from removing it)
@@ -427,6 +443,8 @@ void nsWindow::TaskbarConcealer::OnWindowMaximized(nsWindow* aWin,
427443
// If we're not using a custom nonclient area, then it's obvious to Windows
428444
// that we're not trying to be fullscreen, so the bug won't occur.
429445
if (!aWin->mCustomNonClient) {
446+
MOZ_LOG(sTaskbarConcealerLog, LogLevel::Info,
447+
("... skipped: HWND %p has no custom non-client area", aWin->mWnd));
430448
return;
431449
}
432450

@@ -440,6 +458,20 @@ void nsWindow::TaskbarConcealer::OnWindowMaximized(nsWindow* aWin,
440458
(TaskbarConcealerImpl{}).MarkAsHidingTaskbar(aWin->mWnd, false);
441459
}
442460

461+
void nsWindow::TaskbarConcealer::OnWindowShown(nsWindow* aWin) {
462+
const nsSizeMode sizeMode = aWin->mFrameState->GetSizeMode();
463+
464+
MOZ_LOG(sTaskbarConcealerLog, LogLevel::Info,
465+
("==> OnWindowShown() for HWND %p: sizeMode %d, customNonClient %d",
466+
aWin->mWnd, int(sizeMode), int(aWin->mCustomNonClient)));
467+
468+
if (sizeMode != nsSizeMode_Maximized) {
469+
return;
470+
}
471+
472+
OnWindowMaximized(aWin, /* aForce = */ true);
473+
}
474+
443475
void nsWindow::TaskbarConcealer::OnFullscreenChanged(nsWindow* aWin,
444476
bool enteredFullscreen) {
445477
MOZ_LOG(sTaskbarConcealerLog, LogLevel::Info,

‎widget/windows/nsWindowTaskbarConcealer.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class nsWindow::TaskbarConcealer {
2727
// OnFullscreenChanged.
2828
static void OnWindowMaximized(nsWindow* aWin, bool aForce = false);
2929

30+
// To be called when a window becomes visible. Windows decides whether a
31+
// window is fullscreen when it is shown, so a maximized window needs its
32+
// state re-asserted at that point.
33+
static void OnWindowShown(nsWindow* aWin);
34+
3035
// To be called when the Gecko-fullscreen state of a window changes.
3136
static void OnFullscreenChanged(nsWindow* aWin, bool enteredFullscreen);
3237

0 commit comments

Comments
 (0)