Skip to content

Commit

Permalink
reduce white flickering in dark mode (#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmerAL committed Sep 13, 2023
1 parent f8d6d15 commit 757583f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 0 additions & 6 deletions css/webviews.css
Expand Up @@ -3,12 +3,6 @@
position: relative;
}

/* Webpages assume the page background will always be white, but the Electron API to set this is broken on Windows and Linux (https://github.com/electron/electron/issues/20447) - there, the view will always be transparent.
Therefore, the webview background should always be white, except on the new tab page. */
body:not(.is-ntp) #webviews {
background-color: white;
}

.arrow-indicator {
width: 140px;
height: 140px;
Expand Down
5 changes: 4 additions & 1 deletion main/viewManager.js
Expand Up @@ -321,7 +321,10 @@ ipc.on('loadURLInView', function (e, args) {

// wait until the first URL is loaded to set the background color so that new tabs can use a custom background
if (!viewStateMap[args.id].loadedInitialURL) {
viewMap[args.id].setBackgroundColor('#fff')
// Give the site a chance to display something before setting the background, in case it has its own dark theme
viewMap[args.id].webContents.once('dom-ready', function() {
viewMap[args.id].setBackgroundColor('#fff')
})
// If the view has no URL, it won't be attached yet
if (args.id === windows.getState(win).selectedView) {
win.setBrowserView(viewMap[args.id])
Expand Down

0 comments on commit 757583f

Please sign in to comment.