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 #30778

Merged

Conversation

samuelmaddock
Copy link
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 in the last 24 hours label Sep 1, 2021
@samuelmaddock samuelmaddock added no-backport semver/patch backwards-compatible bug fixes labels Sep 1, 2021
shell/browser/api/electron_api_browser_window.cc Outdated Show resolved Hide resolved
shell/browser/api/electron_api_web_contents.cc Outdated Show resolved Hide resolved
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours 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
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').

@zcbenz zcbenz merged commit 7379e5e into electron:main Sep 6, 2021
@release-clerk
Copy link

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