From b48d0f2cbe0c75c7ce0beeeb85445e33770b642f Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 17 Nov 2021 19:36:25 +0900 Subject: [PATCH] fix: setContentProtection affects BrowserWindow frame (#31830) Co-authored-by: Micha Hanselmann --- shell/browser/native_window_views.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 233ccc3ef07ba..edefa8f2fc0a1 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -1126,6 +1126,8 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) { void NativeWindowViews::SetContentProtection(bool enable) { #if defined(OS_WIN) HWND hwnd = GetAcceleratedWidget(); + DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE; + ::SetWindowDisplayAffinity(hwnd, affinity); if (!layered_) { // Workaround to prevent black window on screen capture after hiding and // showing the BrowserWindow. @@ -1134,8 +1136,6 @@ void NativeWindowViews::SetContentProtection(bool enable) { ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style); layered_ = true; } - DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE; - ::SetWindowDisplayAffinity(hwnd, affinity); #endif }