Skip to content

fix: user resizable transparent windows on win32#49428

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

fix: user resizable transparent windows on win32#49428
jkleinsc merged 1 commit intoelectron:mainfrom
mayfield:win32-transparent-resize-fix

Conversation

@mayfield
Copy link
Copy Markdown
Contributor

@mayfield mayfield commented Jan 17, 2026

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
Copy link
Copy Markdown
Contributor

zoy-l commented Jan 20, 2026

@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 <noreply@anthropic.com>
@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
Copy link
Copy Markdown
Member

nikwen commented Jan 26, 2026

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.

Copy link
Copy Markdown
Member

@codebytere codebytere left a comment

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
Copy link
Copy Markdown
Contributor Author

mayfield commented Jan 28, 2026

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
Copy link
Copy Markdown
Contributor Author

mayfield commented Feb 9, 2026

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
76 checks passed
@welcome
Copy link
Copy Markdown

welcome bot commented Mar 16, 2026

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Mar 16, 2026

Release Notes Persisted

Fixed user resizing of transparent windows on win32 platform

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

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

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

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
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

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

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

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
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

7 participants