From 2c05608a763d53306f090ab9295b2a45ecb1b964 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 12:33:06 +0200 Subject: [PATCH] fix: preserve transparency across setResizable toggles on Windows (#51217) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After #49428 made `NativeWindowViews::CanResize()` return `resizable_` for frameless windows (instead of `resizable_ && thick_frame_`), `HWNDMessageHandler::SizeConstraintsChanged()` started adding `WS_THICKFRAME` to the window style whenever `CanResize()` reported true. `WS_THICKFRAME` is incompatible with layered (translucent) windows and destroys their transparency. `SetContentSizeConstraints` already guards against this by skipping `OnSizeConstraintsChanged()` when `!thick_frame_`. `SetResizable` did not, so toggling resizability on a transparent window (e.g. `setResizable(false)` then `setResizable(true)`) caused the Chromium path to add `WS_THICKFRAME` and strip transparency. Apply the same guard in `SetResizable`. Min/max constraints are still enforced — Chromium reads them from the widget delegate on every `WM_GETMINMAXINFO`, independent of `SizeConstraintsChanged()`. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- shell/browser/native_window_views.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 10ed1e9844..b9ee131e4a 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -965,10 +965,18 @@ void NativeWindowViews::SetResizable(bool resizable) { gfx::Size window_size = GetSize(); SetSizeConstraints(extensions::SizeConstraints(window_size, window_size)); } + // Forcing OnSizeConstraintsChanged on Windows when !thick_frame_ would + // cause HWNDMessageHandler::SizeConstraintsChanged() to add WS_THICKFRAME + // based on CanResize(), which destroys transparency on layered windows. + // Min/max are still enforced through WM_GETMINMAXINFO directly from the + // widget delegate. +#if BUILDFLAG(IS_WIN) + if (thick_frame_ && widget() && widget()->widget_delegate()) + widget()->OnSizeConstraintsChanged(); + UpdateThickFrame(); +#else if (widget() && widget()->widget_delegate()) widget()->OnSizeConstraintsChanged(); -#if BUILDFLAG(IS_WIN) - UpdateThickFrame(); #endif } }