Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: BrowserWindow backgroundColor #30777

Merged

Conversation

samuelmaddock
Copy link
Member

@samuelmaddock samuelmaddock commented Aug 31, 2021

Description of Change

fixes #30759

The renderer in Blink now sets its own background color which is determined from the logic in WebViewImpl::BaseBackgroundColor().

To set this background color for the main frame, we must use WebContents::SetPageBaseBackgroundColor(SkColor).

In #30136, we had reverted using this API because it ended up breaking BrowserWindow transparency. To get this to work, we can see from WebViewImpl::BaseBackgroundColor() that there's a property to enable transparency, override_base_background_color_to_transparent_.

To override the base background color to be transparent, we must call RenderWidgetHostOwnerDelegate::SetBackgroundOpaque(false) which we can do by invoking RenderWidgetHostViewBase::SetBackgroundColor(SK_ColorTRANSPARENT).

cc @codebytere

Transparent window using https://gist.github.com/b52f026c763057f97f745fade82758fd from #30136
image

Background color using https://gist.github.com/4256f388d41ef0d974645a11ab72b1fe from #30759
image

Checklist

Release Notes

Notes: Fixed BrowserWindow's backgroundColor option not having an effect.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Aug 31, 2021
@samuelmaddock samuelmaddock added target/14-x-y semver/minor backwards-compatible functionality labels Aug 31, 2021
@VerteDinde VerteDinde added the backport-check-skip Skip trop's backport validity checking label Aug 31, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 31, 2021
@samuelmaddock samuelmaddock added semver/patch backwards-compatible bug fixes and removed semver/minor backwards-compatible functionality labels Sep 1, 2021
@jkleinsc jkleinsc merged commit 439a295 into electron:15-x-y Sep 2, 2021
@release-clerk
Copy link

release-clerk bot commented Sep 2, 2021

Release Notes Persisted

Fixed BrowserWindow's backgroundColor option not having an effect.

@trop
Copy link
Contributor

trop bot commented Sep 2, 2021

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

@weifeiyue
Copy link

weifeiyue commented Sep 7, 2021

@codebytere will you backported this PR to "13-x-y"? BrowserView can also be fixed?

@bpasero
Copy link
Contributor

bpasero commented Sep 30, 2021

Can this be backported?

// explicitly set by calling
// RenderWidgetHostOwnerDelegate::SetBackgroundOpaque(false).
// RenderWidgetHostViewBase::SetBackgroundColor() will do this for us.
if (web_preferences->IsEnabled(options::kTransparent)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is undocumented.
Ref: #16212 (comment)

Choose a reason for hiding this comment

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

@jkleinsc @ChALkeR just a reminder to add this to the docs :)

@theolivenbaum
Copy link

Is this available on 16 already? If so still not fixing the intermittent loss of transparency there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-check-skip Skip trop's backport validity checking semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants