Skip to content

fix: broken transparent window styles on resizable change#48378

Merged
codebytere merged 7 commits intoelectron:mainfrom
zoy-l:fix_resize
Oct 9, 2025
Merged

fix: broken transparent window styles on resizable change#48378
codebytere merged 7 commits intoelectron:mainfrom
zoy-l:fix_resize

Conversation

@zoy-l
Copy link
Contributor

@zoy-l zoy-l commented Sep 25, 2025

Description of Change

Fixes #48421

If resizable: false is set during titleBarOverlay initialization, the maximize button is still available.

Reason: When setting up a transparent window during initialization, calling SetCanResize(true) triggers OnSizeConstraintsChanged. The internal check finds CanResize is true, and since we removed the is_translucent_ check, this causes an unintended window-style flag to be set.

Change Description:
Override the internal CanResize function to prevent inconsistencies with Chromium’s internal state.
SetResizable no longer needs to repeatedly trigger OnSizeConstraintsChanged and call SetMaximizable.

Background:
Previous Process

  1. Calling SetResizable(true) first triggered OnSizeConstraintsChanged.
  2. At that moment, the internal can_resize flag was still false.
  3. The canMaximize check (delegate->CanMaximize() && can_resize) evaluated to false, which applied a disabled style.
  4. SetMaximizable was then called to restore the correct style.
  5. Finally, SetCanResize updated Chromium’s internal state and triggered OnSizeConstraintsChanged again, correctly applying the style.

To fix the background material, the !is_translucent_ check for can_resize was removed in HWNDMessageHandler::SizeConstraintsChanged, which exposed this issue. See fix_resolve_dynamic_background_material_update_issue_on_windows_11.patch for reference.

This brings two changes that need to be confirmed.: one is that windows with thickFrame: false can no longer get the maximize button unless implemented manually. The other is that when thickFrame is false, isResizable is always false under normal circumstances.

Note: In previous versions, transparent windows did not support resizing by dragging the borders.

Checklist

Release Notes

Notes: Fixed an issue where changing the resizable property on a window would break the styles of a transparent window.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Sep 25, 2025
codebytere
codebytere previously approved these changes Sep 25, 2025
@codebytere codebytere dismissed their stale review September 25, 2025 20:07

meant to comment

Copy link
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.

@zoy-l the failures are related, see e.g.:

not ok 401 BrowserWindow module window states resizable state does affect maximizability when disabled and enabled

@zoy-l
Copy link
Contributor Author

zoy-l commented Sep 26, 2025

@zoy-l the failures are related, see e.g.:

not ok 401 BrowserWindow module window states resizable state does affect maximizability when disabled and enabled

I’ll fix it later.

@zoy-l zoy-l marked this pull request as draft September 29, 2025 18:29
@zoy-l
Copy link
Contributor Author

zoy-l commented Sep 29, 2025

Hmm, this seems a bit off. I need to test it again.😅

@zoy-l zoy-l marked this pull request as ready for review September 30, 2025 14:00
@nikwen
Copy link
Member

nikwen commented Sep 30, 2025

Notes: To fix the background material, the !is_translucent_ check for can_resize was removed in HWNDMessageHandler::SizeConstraintsChanged, which exposed this issue. See fix_resolve_dynamic_background_material_update_issue_on_windows_11.patch for reference.

This brings two changes that need to be confirmed.: one is that windows with thickFrame: false can no longer get the maximize button unless implemented manually. The other is that when thickFrame is false, isResizable is always false under normal circumstances.

The release notes are meant for app developers upgrading their Electron version. They should be relatively simple overall.

Example: "Fixed issue where changing resizable on a window caused <explain bug>."

Could you update them, please?

@zoy-l
Copy link
Contributor Author

zoy-l commented Sep 30, 2025

@nikwen 👌

@zoy-l zoy-l changed the title fix: resizable wrong api call fix: broken transparent window styles on resizable change Sep 30, 2025
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. labels Oct 3, 2025
@electron-cation electron-cation bot added new-pr 🌱 PR opened recently and removed new-pr 🌱 PR opened recently labels Oct 3, 2025
@codebytere codebytere merged commit 3a53c71 into electron:main Oct 9, 2025
103 of 105 checks passed
@release-clerk
Copy link

release-clerk bot commented Oct 9, 2025

Release Notes Persisted

Fixed an issue where changing the resizable property on a window would break the styles of a transparent window.

@trop
Copy link
Contributor

trop bot commented Oct 9, 2025

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

@trop trop bot added the in-flight/38-x-y label Oct 9, 2025
@trop
Copy link
Contributor

trop bot commented Oct 9, 2025

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

@trop trop bot removed the target/38-x-y PR should also be added to the "38-x-y" branch. label Oct 9, 2025
@trop
Copy link
Contributor

trop bot commented Oct 9, 2025

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

@trop trop bot added in-flight/37-x-y in-flight/39-x-y and removed target/37-x-y PR should also be added to the "37-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. labels Oct 9, 2025
@trop trop bot added merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. and removed in-flight/38-x-y in-flight/39-x-y labels Oct 10, 2025
@nikwen
Copy link
Member

nikwen commented Oct 14, 2025

Looks like this PR caused a regression: #48554

@trop trop bot added merged/37-x-y PR was merged to the "37-x-y" branch. and removed in-flight/37-x-y labels Oct 21, 2025
@zoy-l zoy-l mentioned this pull request Oct 22, 2025
5 tasks
TheCommieAxolotl pushed a commit to TheCommieAxolotl/electron that referenced this pull request Nov 2, 2025
…8378)

* fix: wrong api call

* fix: consistency of the resize state

* fix: edge cases

* chore: add detailed comments

* fix: lint

* chore: only windows

* chore: use transparent
nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
…8378)

* fix: wrong api call

* fix: consistency of the resize state

* fix: edge cases

* chore: add detailed comments

* fix: lint

* chore: only windows

* chore: use transparent
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
…8378)

* fix: wrong api call

* fix: consistency of the resize state

* fix: edge cases

* chore: add detailed comments

* fix: lint

* chore: only windows

* chore: use transparent
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
…8378)

* fix: wrong api call

* fix: consistency of the resize state

* fix: edge cases

* chore: add detailed comments

* fix: lint

* chore: only windows

* chore: use transparent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting a transparent window to be resizable breaks transparency

3 participants