fix: black window on screen capture when content protection is enabled (#31340)
Co-authored-by: Micha Hanselmann <mhanselmann@microsoft.com>
This commit is contained in:
parent
371b521dd2
commit
95f81f5980
1 changed files with 10 additions and 1 deletions
|
@ -1105,8 +1105,17 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
||||||
|
|
||||||
void NativeWindowViews::SetContentProtection(bool enable) {
|
void NativeWindowViews::SetContentProtection(bool enable) {
|
||||||
#if defined(OS_WIN)
|
#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;
|
DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE;
|
||||||
::SetWindowDisplayAffinity(GetAcceleratedWidget(), affinity);
|
::SetWindowDisplayAffinity(hwnd, affinity);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue