Skip to content

fix: user resizable transparent windows on win32 - #49428

Merged
jkleinsc merged 1 commit into
electron:mainfrom
mayfield:win32-transparent-resize-fix
Mar 16, 2026
Merged

jkleinsc merged 1 commit into
electron:mainfrom
mayfield:win32-transparent-resize-fix

Conversation

@mayfield

@mayfield mayfield commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #48554

Description of Change

Frameless windows use hit-test based resize in chromium. Version 39 of electron regressed resizable windows that did not have a "frame" on win32.

Checklist

  • PR description included
  • npm test passes
    I ran tests but there were 245 fails that seemed to have nothing to do with my change. I don't know if HEAD is broken or if my windows VM is not setup correctly.
  • PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.

Release Notes

notes: Fixed user resizing of transparent windows on win32 platform

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jan 17, 2026
@mayfield

Copy link
Copy Markdown
Contributor Author

Here is my test matrix to gauge user impact...

commonOptions = {
  width: 800,
  height: 600,
  maxWidth: 1000,
  minWidth: 400,
}
version - options Sizable by user .isResizable() isMaximizable() .maximize() behavior .restore() after maximize() notes
38.0.0 - frame:true, transparent:false, thickFrame: true YES true true YES PASS
39.2.7 - frame:true, transparent:false, thickFrame: true YES true true YES PASS
40 +pr - frame:true, transparent:false, thickFrame: true YES true true YES PASS
38.0.0 - frame:true, transparent:true, thickFrame: true NO false true YES FAIL not transparent, has frame
39.2.7 - frame:true, transparent:true, thickFrame: true NO false false YES, ignores constraints PASS transparent, NO frame
40 +pr - frame:true, transparent:true, thickFrame: true NO false false YES, ignores constraints PASS transparent, NO frame
38.0.0 - frame:false, transparent:false, thickFrame: true YES true true YES YES
39.2.7 - frame:false, transparent:false, thickFrame: true YES true true YES YES
40 +pr - frame:false, transparent:false, thickFrame: true YES true true YES YES
38.0.0 - frame:false, transparent:true, thickFrame: true YES true true YES FAIL
39.2.7 - frame:false, transparent:true, thickFrame: true NO false false YES, ignores constraints PASS
40 +pr - frame:false, transparent:true, thickFrame: true YES true true YES FAIL
38.0.0 - frame:true, transparent:true, thickFrame: true, resizable: false NO false false YES, ignores constraints PASS affected by #48421
39.2.7 - frame:true, transparent:true, thickFrame: true, resizable: false NO false false YES, ignores constraints PASS unaffected by #48421
40 +pr - frame:true, transparent:true, thickFrame: true, resizable: false NO false false YES, ignores constraints PASS unaffected by #48421
38.0.0 - thickFrame:false NO false true YES PASS
39.2.7 - thickFrame:false NO false false YES PASS
40 +pr - thickFrame:false NO false false YES PASS
38.0.0 - thickFrame:false, frame:false YES true true YES PASS
39.2.7 - thickFrame:false, frame:false NO false false YES PASS
40 +pr - thickFrame:false, frame:false NO true true YES PASS
38.0.0 - thickFrame:false, frame:false, transparent:true YES true true YES FAIL
39.2.7 - thickFrame:false, frame:false, transparent:true NO false false YES, ignores constraints PASS
40 +pr - thickFrame:false, frame:false, transparent:true YES true true YES FAIL

@mayfield

Copy link
Copy Markdown
Contributor Author

Hi @zoy-l, Here is the PR for the win32 resize regression. I kept the changes as minimal as possible and attempted to keep behavior identical to docs/pre-39.

@zoy-l

zoy-l commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

@mayfield Hey, I'm not an API reviewer, so I can't really give any suggestions. Please be patient — someone will review it.
😃

steveseguin added a commit to steveseguin/electron that referenced this pull request Jan 22, 2026
This commit addresses the transparent window rendering issues on Windows:

1. Apply PR electron#49428 fix for CanResize() and IsResizable()
   - Frameless windows use hit-test based resize, not WS_THICKFRAME
   - CanResize() now returns resizable_ for frameless windows
   - IsResizable() simplified to delegate to CanResize()

2. Add SetIsTranslucent(false) for transparent windows after widget init
   - During widget creation, transparent windows get is_translucent_=true
   - This causes Win11 background material patch to call DefWindowProc(-1)
   - On some hardware, this causes black/grey backgrounds on focus events
   - Explicitly setting is_translucent_=false prevents this issue

3. Keep SetBackgroundMaterial() early return for transparent windows
   - Background materials (Mica/Acrylic) are not appropriate for transparent windows

Fixes: electron#48554
See: electron#49428

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jan 24, 2026
@mayfield

Copy link
Copy Markdown
Contributor Author

@nikwen I'm in fear that this is bit rotting. Can you provide any guidance or direct me towards avenues for raising the prio, i.e. sponsorship, proposals, better PR conformance? I apologize if I'm still not being patient enough, I do value your time.

@nikwen

nikwen commented Jan 26, 2026

Copy link
Copy Markdown
Member

Sorry, we currently have a long backlog of PRs. I'm not the right person to review this. I hope someone will get to it soon.

@codebytere codebytere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mayfield can you please verify your commit?

Comment on lines -1020 to -1023
#if BUILDFLAG(IS_WIN)
if (has_frame())
return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME;
#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has been around for ~9 years and your PR doesn't describe how this fixes it or why it regressed - why was this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a more in-depth discussion here #48554 (comment)

The PR's assertion is that window resizing for win32 is not a special-case because chromium facilitates resizing internally with its own hit-test method (outlined in above comment(s)). This hit-test method is, however, tied to CanResize, as it defers to the shell as the authority on what's permitted. This PR seeks to consolidate the behavior and expectations of IsResizable (and CanResize) to be more consistent, and remove the incorrect assumption that resizing on win32 requires the WS_THICKFRAME flag (in the most minimal way possible as a first time electron committer).

I should note, based on the comments in much of the electron shell/browser/native_window_view.cc code, I believe there is some confusion about what WS_THICKFRAME means. It's also an alias for WS_SIZEBOX and despite being very poorly documented by microsoft, more or less just means the window can be sized using an external OS border (https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles). It doesn't mean the window is not allowed to size itself, as chromium indeed can and does do.

@mayfield
mayfield force-pushed the win32-transparent-resize-fix branch from 8209374 to 7f83b3b Compare January 27, 2026 19:28
@mayfield mayfield changed the title Fix for user resizable transparent windows on win32 fix: user resizable transparent windows on win32 Jan 27, 2026
@codebytere

Copy link
Copy Markdown
Member

@mayfield this test failure looks related:

not ok 1 BrowserWindow module window states resizable state do not change window transparent without frame bounds when maximized
  resizable: expected true to be false
  AssertionError: resizable: expected true to be false
      at Context.<anonymous> (electron\spec\api-browser-window-spec.ts:5476:44)
      at processImmediate (node:internal/timers:504:21)

@mayfield

mayfield commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor Author

re: test failure

Looks like this test was changed as part of the original regression, 3a53c71

I think the remediation is to change this back to to.be.true('resizable').

If you agree, I can add a commit to this effect or if you prefer single commits, I can replace the current one.

Let me know what you think/prefer @codebytere.

@mayfield
mayfield force-pushed the win32-transparent-resize-fix branch from 7f83b3b to 1cff204 Compare January 30, 2026 01:03
@mayfield

mayfield commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

Hi @codebytere Let me know how I can help or what I should do next.

@jkleinsc

Copy link
Copy Markdown
Member

@mayfield can you rebase your PR with the latest from main?

@mayfield
mayfield force-pushed the win32-transparent-resize-fix branch from 1cff204 to 45deeab Compare February 26, 2026 22:22
test: revert win32 frameless and transparent resizable expectations
@mayfield
mayfield force-pushed the win32-transparent-resize-fix branch from 45deeab to d98a6e4 Compare February 26, 2026 22:31
@mayfield

Copy link
Copy Markdown
Contributor Author

@jkleinsc Should be rebased and combined into a single commit now

Ref: d98a6e4

@jkleinsc jkleinsc added target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. labels Feb 27, 2026
@github-actions github-actions Bot added the target/42-x-y PR should also be added to the "42-x-y" branch. label Mar 13, 2026
@mayfield

Copy link
Copy Markdown
Contributor Author

Hi again, in a couple days we celebrate the 2 month anniversary of this PR! :) Please let me know what I can do to help push this forward; I am at your disposal.

@jkleinsc jkleinsc added the semver/patch backwards-compatible bug fixes label Mar 16, 2026
@jkleinsc
jkleinsc merged commit eec3fe9 into electron:main Mar 16, 2026
75 checks passed
@welcome

welcome Bot commented Mar 16, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk

release-clerk Bot commented Mar 16, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed user resizing of transparent windows on win32 platform

@trop

trop Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #50298

@trop

trop Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #50299

@trop trop Bot removed the target/41-x-y PR should also be added to the "41-x-y" branch. label Mar 16, 2026
@trop

trop Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "39-x-y", please check out #50300

@trop

trop Bot commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "40-x-y", please check out #50301

@trop trop Bot added in-flight/42-x-y in-flight/39-x-y in-flight/40-x-y and removed target/42-x-y PR should also be added to the "42-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. labels Mar 16, 2026
@alfeddlove

This comment was marked as off-topic.

@trop trop Bot added merged/40-x-y PR was merged to the "40-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/40-x-y in-flight/39-x-y in-flight/41-x-y in-flight/42-x-y labels Mar 17, 2026
codebytere added a commit that referenced this pull request Apr 20, 2026
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()`.
jkleinsc pushed a commit that referenced this pull request Apr 21, 2026
…1175)

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()`.
ckerr pushed a commit that referenced this pull request Apr 21, 2026
…1218)

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 <[email protected]>
codebytere added a commit that referenced this pull request Apr 22, 2026
…1217)

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 <[email protected]>
DOMCHURCH added a commit to DOMCHURCH/Gnosis that referenced this pull request Sep 1, 2026
## The hidden audio window was being throttled

The single most consequential line here. The window that owns the
microphone is never visible -- it exists only to hold getUserMedia,
because the main process has no DOM -- and Chromium throttles timers and
audio callbacks in windows that are not visible. Throttled, its
ScriptProcessor stops firing at audio rate, which starves the three
things built on it: the tap feeding the wake-word detector, the recorder
capturing an utterance, and the level meter.

One cause, several symptoms that looked unrelated: "hey jarvis" not
responding after the panel closed, the panel appearing to lag, and a
recording that never finishes -- which leaves the recorder flag set, and
that flag gates the detector feed off entirely.

## The black rectangle, attempt three

Researched rather than guessed this time. electron/electron#49428
reports that Electron's Windows 11 background-material patch takes a
different path for a translucent window and can hand it an opaque
backing -- a black rectangle where the transparency should be, appearing
on focus events, on some hardware. Leaving backgroundMaterial unset
means "let the system decide", which is the case that goes wrong, so the
overlay now asks for "none" explicitly.

Stated plainly: this is the third attempt at this bug and I cannot
verify it from here. capturePage() reads the window's own buffer and
reports alpha 0 at every corner both before and after, because the
failure is in what the desktop compositor does with that buffer.
GNOSIS_OVERLAY_DIAGNOSTIC=1 on the packaged app is how a person checks
in ten seconds.

## The synthesiser was reading the layout out loud

Model output is written for eyes -- em dashes, bullets, backticks,
asterisks, arrows -- and Kokoro pronounces their names: "dot",
"asterisk", "circumflex". speakable() converts the marks that carry
PROSODY into the punctuation that produces it (a dash between clauses
becomes a comma, which is a breath) and removes the marks that are only
layout. Sentence punctuation and apostrophes are untouched: a full stop
is how a synthesiser knows a sentence ended.

Testing it caught a regression in my own first version, which stripped
$ and % -- turning "It costs $5 (50% off)" into "It costs 5 (50 off)".
Both are pronounced correctly by the synthesiser and are now left alone.

## Voice has a presence in the main window

It had none: the wake word is invisible until it fires, the overlay does
not exist until a conversation starts, and the only control was a switch
inside Settings. A feature you cannot see is one nobody uses, and one
whose failures are silent -- no Python, no transcription key, and the
window looked identical to a working install.

So there is a labelled microphone control in the title bar with four
states, one of which is the one that used to be invisible: enabled but
unable to hear, drawn as a warning rather than as "off", because off is
a choice and this is a failure. Clicking starts a conversation through
the same entry point the wake phrase uses. The state logic is in
web/src/voicestate.js -- plain JS beside a .d.ts, matching the
convention this repo already uses for logic worth testing outside a
component.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WBxSDiZUfnSi2TgvJDBgRK
DOMCHURCH added a commit to DOMCHURCH/Gnosis that referenced this pull request Sep 1, 2026
Fourth attempt at the black rectangle, and the first one that is a
guarantee rather than another theory.

The three before it were each reasoned from real evidence and each
wrong about the cause: the drop shadow was being clipped (true, and not
this); backdrop-filter hands a transparent window an opaque backing
(true, removing it was correct, still not this); Windows 11's
background-material path mishandles translucent windows
(electron/electron#49428, and "none" did not fix it either).

Through all of it capturePage() reported alpha 0 at every corner. The
window's own buffer was never wrong. What the desktop compositor did
with that buffer on this GPU was, and nothing in this process can reach
that — so no fix inside the page was ever going to work, and each new
theory was going to look as plausible as the last.

So the shape changes instead of the compositing. The window is opaque
and the panel fills it: a region that does not exist cannot composite
wrongly. The cost is the stadium outline — a 999px radius needs
transparent corners, and those corners ARE the bug — so it is a 16px
rounded rectangle now, with the corners rounded by Windows and the
shadow drawn by Windows outside the window, where nothing can clip it.
The layered material stays; the tints and rim now sit on a colour
instead of on the desktop.

s110's transparency assertions invert with it: they asserted the margin
was transparent, which it always was, while the user watched a black
box. They now assert every sample is PAINTED. If the panel is ever made
transparent again this fails, and it should — that needs to be
deliberate and re-verified on real hardware, not inherited.

Two bugs fell out of removing the 24px margin, both real and both
previously masked by it:

  - s90 hard-coded the pad as 24 and failed at every width when it
    became 0. It reads the constant out of voice.js now.
  - In the stacked layout the two exits hung 6px off the bottom of the
    panel. They were positioned against .right, which stacks to the
    bottom; they belong to the panel. Fixing it needed #expanded .right
    rather than .right, because a later rule in the same stylesheet
    re-declares position at equal specificity and wins on source order.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WBxSDiZUfnSi2TgvJDBgRK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v39.0.0-beta.3 resizability broken with transparent window

6 participants