Skip to content

fix: BrowserWindow backgroundColor#30778

Merged
zcbenz merged 2 commits intoelectron:mainfrom
samuelmaddock:fix/window-background-color-main
Sep 6, 2021
Merged

fix: BrowserWindow backgroundColor#30778
zcbenz merged 2 commits intoelectron:mainfrom
samuelmaddock:fix/window-background-color-main

Conversation

@samuelmaddock
Copy link
Copy Markdown
Member

@samuelmaddock samuelmaddock commented Sep 1, 2021

Description of Change

fixes #30759

Port of #30777 which targets v14+15. I manually ported this to latest because of the changes to WebPreferences in #30193

The code below would fail to convert a hex string to an SkColor which resulted in the RVHW's background color always being set to transparent.

web_preferences.Get(options::kBackgroundColor, &background_color_);

cc @codebytere @nornagon

Checklist

Release Notes

Notes: none

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Sep 1, 2021
@samuelmaddock samuelmaddock added no-backport semver/patch backwards-compatible bug fixes labels Sep 1, 2021
@samuelmaddock samuelmaddock force-pushed the fix/window-background-color-main branch from 1b87f50 to 84e32ef Compare September 1, 2021 03:31
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Sep 2, 2021
@samuelmaddock samuelmaddock force-pushed the fix/window-background-color-main branch 2 times, most recently from 819dae6 to cfb39c6 Compare September 2, 2021 21:09
@samuelmaddock
Copy link
Copy Markdown
Member Author

@nornagon I found a better approach for this.

To make a WebContents transparent, we only need to set the background color to SK_ColorTRANSPARENT. The transparent override in WebViewImpl::BaseBackgroundColor() isn't strictly necessary.

It also doesn't make sense to enforce transparency of the WebContents based on the options passed to BrowserWindow. The user should be able to change the background color to not be transparent at any time.

With these changes, WebContents transparency via transparent: true is equivalent to backgroundColor: '#00000000' or browserWindow.setBackgroundColor('#00000000').

@samuelmaddock samuelmaddock force-pushed the fix/window-background-color-main branch from cfb39c6 to 78a93c1 Compare September 2, 2021 22:29
@zcbenz zcbenz merged commit 7379e5e into electron:main Sep 6, 2021
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Sep 6, 2021

No Release Notes

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

Labels

no-backport semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BrowserWindow backgroundColor doesn't work in Electron 14 and 15

4 participants