diff --git a/patches/chromium/fix_activate_background_material_on_windows.patch b/patches/chromium/fix_activate_background_material_on_windows.patch index cc6d4a4e421ad..0d8019c4a1a13 100644 --- a/patches/chromium/fix_activate_background_material_on_windows.patch +++ b/patches/chromium/fix_activate_background_material_on_windows.patch @@ -1,19 +1,23 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: clavin -Date: Wed, 30 Aug 2023 18:15:36 -0700 +Date: Mon, 11 Dec 2023 20:43:34 -0300 Subject: fix: activate background material on windows This patch adds a condition to the HWND message handler to allow windows with translucent background materials to become activated. +It also ensures the lParam of WM_NCACTIVATE is set to -1 so as to not repaint +the client area, which can lead to a title bar incorrectly being displayed in +frameless windows. + This patch likely can't be upstreamed as-is, as Chromium doesn't have this use case in mind currently. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 13268bd89c710690eed5296f4b2157e9476f195e..37de479e95d49f4d2b1d8164c9e3f6a7bcd82612 100644 +index 13268bd89c710690eed5296f4b2157e9476f195e..0491dc500896a9ce0c8ad95ada6a175c9e94f3d3 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc -@@ -1094,7 +1094,7 @@ void HWNDMessageHandler::FrameTypeChanged() { +@@ -1094,13 +1094,13 @@ void HWNDMessageHandler::FrameTypeChanged() { void HWNDMessageHandler::PaintAsActiveChanged() { if (!delegate_->HasNonClientView() || !delegate_->CanActivate() || @@ -22,3 +26,34 @@ index 13268bd89c710690eed5296f4b2157e9476f195e..37de479e95d49f4d2b1d8164c9e3f6a7 (delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN)) { return; } + + DefWindowProcWithRedrawLock(WM_NCACTIVATE, delegate_->ShouldPaintAsActive(), +- 0); ++ delegate_->HasFrame() ? 0 : -1); + } + + void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon, +@@ -2393,17 +2393,18 @@ LRESULT HWNDMessageHandler::OnNCActivate(UINT message, + if (IsVisible()) + delegate_->SchedulePaint(); + +- // Calling DefWindowProc is only necessary if there's a system frame being +- // drawn. Otherwise it can draw an incorrect title bar and cause visual +- // corruption. +- if (!delegate_->HasFrame() || ++ // If the window is translucent, it may have the Mica background. ++ // In that case, it's necessary to call |DefWindowProc|, but we can ++ // pass -1 in the lParam to prevent any non-client area elements from ++ // being displayed. ++ if ((!delegate_->HasFrame() && !is_translucent_) || + delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { + SetMsgHandled(TRUE); + return TRUE; + } + + return DefWindowProcWithRedrawLock(WM_NCACTIVATE, paint_as_active || active, +- 0); ++ delegate_->HasFrame() ? 0 : -1); + } + + LRESULT HWNDMessageHandler::OnNCCalcSize(BOOL mode, LPARAM l_param) { diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc index d60675f31feab..e9dab479abe19 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc @@ -135,12 +135,12 @@ void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated( bool ElectronDesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const { - // Window should be marked as opaque if no transparency setting has been set, - // otherwise videos rendered in the window will trigger a DirectComposition - // redraw for every frame. + // Window should be marked as opaque if no transparency setting has been + // set, otherwise animations or videos rendered in the window will trigger a + // DirectComposition redraw for every frame. // https://github.com/electron/electron/pull/39895 return native_window_view_->GetOpacity() < 1.0 || - native_window_view_->transparent(); + native_window_view_->IsTranslucent(); } } // namespace electron