Skip to content

fix: BrowserWindow backgroundColor#30777

Merged
jkleinsc merged 1 commit into
electron:15-x-yfrom
samuelmaddock:fix/window-background-color
Sep 2, 2021
Merged

fix: BrowserWindow backgroundColor#30777
jkleinsc merged 1 commit into
electron:15-x-yfrom
samuelmaddock:fix/window-background-color

Conversation

@samuelmaddock

@samuelmaddock samuelmaddock commented Aug 31, 2021

Copy link
Copy Markdown
Member

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

release-clerk Bot commented Sep 2, 2021

Copy link
Copy Markdown

Release Notes Persisted

Fixed BrowserWindow's backgroundColor option not having an effect.

@trop

trop Bot commented Sep 2, 2021

Copy link
Copy Markdown
Contributor

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

@weifeiyue

weifeiyue commented Sep 7, 2021

Copy link
Copy Markdown

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

@bpasero

bpasero commented Sep 30, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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)

Copy link
Copy Markdown

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

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.

8 participants