Repository navigation
fix: user resizable transparent windows on win32 - #49428
Conversation
|
Here is my test matrix to gauge user impact... commonOptions = {
width: 800,
height: 600,
maxWidth: 1000,
minWidth: 400,
}
|
|
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. |
|
@mayfield Hey, I'm not an API reviewer, so I can't really give any suggestions. Please be patient — someone will review it. |
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]>
|
@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. |
|
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
left a comment
There was a problem hiding this comment.
@mayfield can you please verify your commit?
| #if BUILDFLAG(IS_WIN) | ||
| if (has_frame()) | ||
| return ::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_THICKFRAME; | ||
| #endif |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
8209374 to
7f83b3b
Compare
|
@mayfield this test failure looks related: |
|
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 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. |
7f83b3b to
1cff204
Compare
|
Hi @codebytere Let me know how I can help or what I should do next. |
|
@mayfield can you rebase your PR with the latest from main? |
1cff204 to
45deeab
Compare
test: revert win32 frameless and transparent resizable expectations
45deeab to
d98a6e4
Compare
|
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. |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
|
Release Notes Persisted
|
|
I have automatically backported this PR to "41-x-y", please check out #50298 |
|
I have automatically backported this PR to "42-x-y", please check out #50299 |
|
I have automatically backported this PR to "39-x-y", please check out #50300 |
|
I have automatically backported this PR to "40-x-y", please check out #50301 |
This comment was marked as off-topic.
This comment was marked as off-topic.
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()`.
…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()`.
…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]>
…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]>
## 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
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
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
npm testpassesI 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.
Release Notes
notes: Fixed user resizing of transparent windows on win32 platform