Skip to content

fix: titlebar incorrectly displayed on frameless windows#40749

Merged
jkleinsc merged 3 commits intoelectron:mainfrom
brhenrique:fix-incorrect-title-bar-on-transparent-frameless-window
Jan 2, 2024
Merged

fix: titlebar incorrectly displayed on frameless windows#40749
jkleinsc merged 3 commits intoelectron:mainfrom
brhenrique:fix-incorrect-title-bar-on-transparent-frameless-window

Conversation

@brhenrique
Copy link
Contributor

@brhenrique brhenrique commented Dec 12, 2023

Description of Change

Fixes #39959.

  • Fixes a bug where Mica background won't work without the transparent: true setting
  • Fixes a bug where a title bar is displayed on frameless windows

A patch was added to fix Mica backgrounds on frameless windows, but it caused a side-effect in which a title bar gets displayed on frameless transparent windows.

This happens because, after the patch, WM_NCACTIVATE would be dispatched to DefWindowProc for frameless transparent windows. While this is necessary to make Mica work on these windows, it would cause an incorrect title bar to also be displayed.

To fix this, we are setting -1 as the lParam of DefWindowProc, which seems to prevent the non-client area from being displayed on window activation/deactivation:

When a visual style is not active for this window, this parameter is a handle to an optional update region for the nonclient area of the window. If this parameter is set to -1, DefWindowProc does not repaint the nonclient area to reflect the state change.

Transparent: False, Mica Transparent: True, Frame: False, Mica Transparent: True, Frame: True, Mica Transparent: True, Frame: False, No Mica
Mica Before -
Mica After -
Title Bar Before -
Title Bar After -

Checklist

Release Notes

Notes: fix incorrect title bar shown on frameless transparent windows

@brhenrique brhenrique requested a review from a team as a code owner December 12, 2023 12:42
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Dec 12, 2023
@brhenrique
Copy link
Contributor Author

cc @zcbenz @clavin

@zcbenz zcbenz added semver/patch backwards-compatible bug fixes target/27-x-y PR should also be added to the "27-x-y" branch. target/28-x-y PR should also be added to the "28-x-y" branch. target/29-x-y PR should also be added to the "29-x-y" branch. labels Dec 13, 2023
@michalzaq12
Copy link
Contributor

Good job, but I noticed two things (regarding frameless window):

  • strange behavior when we set transparet: true with Mica enabled. Mica does not work on initial page load. But it starts working after resizing the window. Without transparet: true, mica works as intended.
  • Maximizing a window with Mica enabled, causes the entire window to crash

@brhenrique
Copy link
Contributor Author

Good job, but I noticed two things (regarding frameless window):

  • strange behavior when we set transparet: true with Mica enabled. Mica does not work on initial page load. But it starts working after resizing the window. Without transparet: true, mica works as intended.
  • Maximizing a window with Mica enabled, causes the entire window to crash

I see, but both issues seem to also be present in the latest stable, right? I think there should be a separate PR for them, since this one is focused on different problems.

@Cloudkkk
Copy link

🥹Is there any blocking point for this PR? When can we expect it to be fixed? It's really important to me. Thanks

@clavin clavin self-requested a review December 19, 2023 19:12
Copy link
Member

@clavin clavin left a comment

Choose a reason for hiding this comment

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

Well done! Thank you so much for investigating and fixing this 😊

I have built and manually tested this change and can confirm it works. ✅

I have one small change to request 😅 but after that this should be good to merge. I'll also make sure the backports for this PR land swiftly after.

@Auhnip
Copy link

Auhnip commented Dec 22, 2023

I recently came across this pull request and noticed that it contains the exact fix I need for a bug that's been a bit of a roadblock for me. Is there any chance it could be reviewed and merged soon? It's important to me. thanks~

Copy link
Member

@clavin clavin left a comment

Choose a reason for hiding this comment

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

I went and pushed the change I described to your branch—I hope that's alright—so that we can get this fix merged asap 😄

@jkleinsc jkleinsc merged commit a208d45 into electron:main Jan 2, 2024
@release-clerk
Copy link

release-clerk bot commented Jan 2, 2024

Release Notes Persisted

fix incorrect title bar shown on frameless transparent windows

@trop
Copy link
Contributor

trop bot commented Jan 2, 2024

I was unable to backport this PR to "27-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot removed the target/27-x-y PR should also be added to the "27-x-y" branch. label Jan 2, 2024
@trop
Copy link
Contributor

trop bot commented Jan 2, 2024

I was unable to backport this PR to "28-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot added needs-manual-bp/27-x-y needs-manual-bp/28-x-y and removed target/28-x-y PR should also be added to the "28-x-y" branch. labels Jan 2, 2024
@trop
Copy link
Contributor

trop bot commented Jan 2, 2024

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

@trop trop bot added in-flight/29-x-y merged/29-x-y PR was merged to the "29-x-y" branch. and removed target/29-x-y PR should also be added to the "29-x-y" branch. in-flight/29-x-y labels Jan 2, 2024
clavin added a commit that referenced this pull request Jan 2, 2024
Manual backport of #40749

Co-authored-by: Bruno Henrique da Silva <bruno.d@miro.com>
@trop
Copy link
Contributor

trop bot commented Jan 3, 2024

@clavin has manually backported this PR to "28-x-y", please check out #40867

clavin added a commit that referenced this pull request Jan 3, 2024
Manual backport of #40749 (a208d45)

Co-authored-by: Bruno Henrique da Silva <bruno.d@miro.com>
@trop
Copy link
Contributor

trop bot commented Jan 3, 2024

@clavin has manually backported this PR to "27-x-y", please check out #40868

codebytere pushed a commit that referenced this pull request Jan 3, 2024
Manual backport of #40749 (a208d45)

Co-authored-by: Bruno Henrique da Silva <bruno.d@miro.com>
@trop trop bot added merged/27-x-y PR was merged to the "27-x-y" branch. and removed in-flight/27-x-y in-flight/28-x-y labels Jan 3, 2024
codebytere pushed a commit that referenced this pull request Jan 3, 2024
Manual backport of #40749

Co-authored-by: Bruno Henrique da Silva <bruno.d@miro.com>
@trop trop bot added the merged/28-x-y PR was merged to the "28-x-y" branch. label Jan 3, 2024
@wujunliang
Copy link

37.2.5还是有这个bug
wechat_2025-08-04_113601_551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/27-x-y PR was merged to the "27-x-y" branch. merged/28-x-y PR was merged to the "28-x-y" branch. merged/29-x-y PR was merged to the "29-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

9 participants