Skip to content

Commit

Permalink
Updated hardware change handling
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Jul 7, 2022
1 parent 9f91ea4 commit fab76c1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,6 @@ ipcMain.on('show-acrylic', () => {
if (lastTheme && lastTheme.ColorPrevalence) {
tryVibrancy(mainWindow, { theme: getAccentColors().dark + (settings.useAcrylic ? "D0" : "70"), effect: (settings.useAcrylic ? "acrylic" : "blur") })
} else {
console.log(nativeTheme.themeSource)
tryVibrancy(mainWindow, { theme: (lastTheme && nativeTheme.themeSource === "light" ? (settings.useAcrylic ? "#DBDBDBDD" : "#DBDBDB70") : (settings.useAcrylic ? "#292929DD" : "#29292970")), effect: (settings.useAcrylic ? "acrylic" : "blur") })
}
} else {
Expand Down Expand Up @@ -1737,13 +1736,17 @@ function setAlwaysOnTop(onTop = true) {
return true
}

function restartPanel() {
function restartPanel(show = false) {
if (mainWindow) {
mainWindow.close()
mainWindow = null
}
setTimeout(() => {
if (mainWindow) {
mainWindow.close()
mainWindow = null
}
createPanel()
createPanel(show)
}, 100)
}

Expand Down Expand Up @@ -2593,6 +2596,7 @@ function handleAccentChange() {
let skipFirstMonChange = false
let handleChangeTimeout
function handleMonitorChange(e, d) {
console.log("Hardware change detected.")

// Skip event that happens at startup
if (!skipFirstMonChange) {
Expand All @@ -2611,8 +2615,7 @@ function handleMonitorChange(e, d) {
handleBackgroundUpdate(true) // Apply Time Of Day Adjustments

// If displays not shown, refresh mainWindow
if (!panelSize.visible)
restartPanel()
restartPanel(panelSize.visible)
})

handleChangeTimeout = false
Expand Down

0 comments on commit fab76c1

Please sign in to comment.