Skip to content

Commit

Permalink
fix: black window on screen capture when content protection is enabled (
Browse files Browse the repository at this point in the history
#31550)

Co-authored-by: Micha Hanselmann <mhanselmann@microsoft.com>
  • Loading branch information
trop[bot] and Micha Hanselmann committed Oct 22, 2021
1 parent 42aa56a commit 930dde3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion shell/browser/native_window_views.cc
Expand Up @@ -1108,8 +1108,17 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {

void NativeWindowViews::SetContentProtection(bool enable) {
#if defined(OS_WIN)
HWND hwnd = GetAcceleratedWidget();
if (!layered_) {
// Workaround to prevent black window on screen capture after hiding and
// showing the BrowserWindow.
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style |= WS_EX_LAYERED;
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
layered_ = true;
}
DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE;
::SetWindowDisplayAffinity(GetAcceleratedWidget(), affinity);
::SetWindowDisplayAffinity(hwnd, affinity);
#endif
}

Expand Down

0 comments on commit 930dde3

Please sign in to comment.