Skip to content

Commit b1cd70f

Browse files
deermichelMicha Hanselmann
authored andcommitted
fix: black window on screen capture when content protection is enabled (electron#31340)
Co-authored-by: Micha Hanselmann <mhanselmann@microsoft.com>
1 parent 03d9992 commit b1cd70f

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
@@ -1105,8 +1105,17 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
11051105

11061106
void NativeWindowViews::SetContentProtection(bool enable) {
11071107
#if defined(OS_WIN)
1108+
HWND hwnd = GetAcceleratedWidget();
1109+
if (!layered_) {
1110+
// Workaround to prevent black window on screen capture after hiding and
1111+
// showing the BrowserWindow.
1112+
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
1113+
ex_style |= WS_EX_LAYERED;
1114+
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
1115+
layered_ = true;
1116+
}
11081117
DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE;
1109-
::SetWindowDisplayAffinity(GetAcceleratedWidget(), affinity);
1118+
::SetWindowDisplayAffinity(hwnd, affinity);
11101119
#endif
11111120
}
11121121

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