Skip to content

Commit 35be765

Browse files
trop[bot]Micha Hanselmann
andauthored
fix: black window on screen capture when content protection is enabled (#31551)
Co-authored-by: Micha Hanselmann <mhanselmann@microsoft.com>
1 parent eecda46 commit 35be765

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

shell/browser/native_window_views.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,17 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
11251125

11261126
void NativeWindowViews::SetContentProtection(bool enable) {
11271127
#if defined(OS_WIN)
1128+
HWND hwnd = GetAcceleratedWidget();
1129+
if (!layered_) {
1130+
// Workaround to prevent black window on screen capture after hiding and
1131+
// showing the BrowserWindow.
1132+
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
1133+
ex_style |= WS_EX_LAYERED;
1134+
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
1135+
layered_ = true;
1136+
}
11281137
DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE;
1129-
::SetWindowDisplayAffinity(GetAcceleratedWidget(), affinity);
1138+
::SetWindowDisplayAffinity(hwnd, affinity);
11301139
#endif
11311140
}
11321141

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy