Skip to content

Commit d9d413a

Browse files
committed
Revert "Bug 1824053 - [2/4] Cloak and clear new windows on creation r=win-reviewers,handyman"
This reverts commit 8ef94cf.
1 parent 2bedd89 commit d9d413a

File tree

2 files changed

+1
-70
lines changed

2 files changed

+1
-70
lines changed

widget/windows/nsWindow.cpp

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,64 +1705,6 @@ void nsWindow::Show(bool aState) {
17051705
// top level windows:
17061706
syncInvalidate = true;
17071707

1708-
// Cloak (or uncloak) the window.
1709-
//
1710-
// (DWMWA_CLOAK is effectively orthogonal to any cloaking done by the
1711-
// shell to implement virtual desktops; we don't have to worry about
1712-
// accidentally forcing something on another desktop to become visible.)
1713-
constexpr static const auto CloakWindow = [](HWND hwnd, BOOL state) {
1714-
::DwmSetWindowAttribute(hwnd, DWMWA_CLOAK, &state, sizeof(state));
1715-
};
1716-
1717-
// Clear the window using a theme-appropriate color.
1718-
constexpr static const auto ClearWindow = [](HWND hwnd) {
1719-
// default background color from current theme
1720-
auto const bgcolor = LookAndFeel::Color(
1721-
StyleSystemColor::Window, PreferenceSheet::ColorSchemeForChrome(),
1722-
LookAndFeel::UseStandins::No, NS_RGB(0, 0, 0));
1723-
1724-
HBRUSH brush = ::CreateSolidBrush(NSRGB_2_COLOREF(bgcolor));
1725-
if (NS_WARN_IF(!brush)) {
1726-
// GDI object cap hit, possibly?
1727-
return;
1728-
}
1729-
auto const _releaseBrush =
1730-
MakeScopeExit([&] { ::DeleteObject(brush); });
1731-
1732-
HDC hdc = ::GetWindowDC(hwnd);
1733-
MOZ_ASSERT(hdc);
1734-
auto const _cleanupDC =
1735-
MakeScopeExit([&] { ::ReleaseDC(hwnd, hdc); });
1736-
1737-
RECT rect;
1738-
::GetWindowRect(hwnd, &rect); // includes non-client area
1739-
1740-
// Convert from screen- to client-coordinates, accounting for the
1741-
// desktop (or, in theory, us) possibly being WS_EX_LAYOUTRTL...
1742-
::MapWindowPoints(HWND_DESKTOP, hwnd, (LPPOINT)&rect, 2);
1743-
// ... then convert from client- to window- coordinates, with no
1744-
// separate RTL-handling needed.
1745-
::OffsetRect(&rect, -rect.left, -rect.top);
1746-
1747-
::FillRect(hdc, &rect, brush);
1748-
};
1749-
1750-
if (!mHasBeenShown) {
1751-
// On creation, the window's content is not specified; in practice,
1752-
// it's observed to usually be full of bright white, regardless of any
1753-
// window-class options. DWM will happily render that unspecified
1754-
// content to the screen before we get a chance to process a
1755-
// WM_ERASEBKGND event (or, indeed, anything else). To avoid dark-mode
1756-
// users being assaulted with a bright white flash, we need to draw
1757-
// something on top of that at least once before showing the window.
1758-
//
1759-
// Unfortunately, there's a bit of a catch-22 here: until the window
1760-
// has been set "visible" at least once, it doesn't have a backing
1761-
// surface, so we can't draw anything to it! To work around this, we
1762-
// cloak the window before "showing" it.
1763-
CloakWindow(mWnd, TRUE);
1764-
}
1765-
17661708
// Set the cursor before showing the window to avoid the default wait
17671709
// cursor.
17681710
SetCursor(Cursor{eCursor_standard});
@@ -1789,16 +1731,6 @@ void nsWindow::Show(bool aState) {
17891731
}
17901732
break;
17911733
}
1792-
1793-
if (!mHasBeenShown) {
1794-
// Now that ::ShowWindow() has been called once, the window surface
1795-
// actually exists, so we can draw to it. Fill it with the theme's
1796-
// background color before uncloaking it to complete the Show().
1797-
ClearWindow(mWnd);
1798-
CloakWindow(mWnd, FALSE);
1799-
mHasBeenShown = false;
1800-
}
1801-
18021734
} else {
18031735
DWORD flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW;
18041736
if (wasVisible) {
@@ -5701,7 +5633,7 @@ bool nsWindow::ProcessMessageInternal(UINT msg, WPARAM& wParam, LPARAM& lParam,
57015633
} break;
57025634

57035635
// Say we've dealt with erasing the background. (This is actually handled in
5704-
// WM_PAINT or at window-creation time, as necessary.)
5636+
// WM_PAINT, where necessary.)
57055637
case WM_ERASEBKGND: {
57065638
*aRetValue = 1;
57075639
result = true;

widget/windows/nsWindow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ class nsWindow final : public nsBaseWidget {
757757
bool mIsEarlyBlankWindow = false;
758758
bool mIsShowingPreXULSkeletonUI = false;
759759
bool mResizable = false;
760-
bool mHasBeenShown = false;
761760
// Whether we're an alert window. Alert windows don't have taskbar icons and
762761
// don't steal focus from other windows when opened. They're also expected to
763762
// be of type WindowType::Dialog.

0 commit comments

Comments
 (0)