Skip to content

Commit

Permalink
fix(media): enable roundedCorners again as it prevents the app from c…
Browse files Browse the repository at this point in the history
…losing

see electron/electron#28686

closes #59
  • Loading branch information
BenShelton committed Jul 17, 2021
1 parent b86e073 commit fb250f7
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions packages/media/app/main/src/window.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow } from 'electron'
import { BrowserWindow } from 'electron'
import { URL } from 'url'
import { join } from 'path'
import { checkExists } from '@library-api/core'
Expand All @@ -20,13 +20,6 @@ function checkDevTools (window: BrowserWindow): void {
window.webContents.openDevTools({ mode: 'right' })
}

function saveWindowConfig (window: BrowserWindow, key: 'controlWindow' | 'displayWindow'): void {
window.on('close', () => {
const { x, y, width, height } = window.getBounds()
store.set(key, { x, y, width, height })
})
}

export async function createControlWindow (): Promise<BrowserWindow> {
const storeKey = 'controlWindow'
const windowSettings = store.get(storeKey)
Expand All @@ -40,10 +33,15 @@ export async function createControlWindow (): Promise<BrowserWindow> {
})

checkDevTools(controlWindow)
saveWindowConfig(controlWindow, storeKey)

controlWindow.on('close', () => {
if (controlWindow) {
const { x, y, width, height } = controlWindow.getBounds()
store.set('controlWindow', { x, y, width, height })
}
})
controlWindow.on('closed', () => {
app.quit()
controlWindow = null
displayWindow?.close()
})

const catalogExists = await checkExists(CATALOG_PATH)
Expand All @@ -62,7 +60,8 @@ export async function createDisplayWindow (): Promise<BrowserWindow> {
// this prevents Zoom from showing this window as an option
// alwaysOnTop: true,
frame: false,
roundedCorners: false,
// TODO: Enable this when fixed, see https://github.com/electron/electron/issues/28686
// roundedCorners: false,
webPreferences: {
preload,
// TODO: This is so we can use local video src in the renderer, there should be a better way
Expand All @@ -73,7 +72,15 @@ export async function createDisplayWindow (): Promise<BrowserWindow> {
displayWindow.setAspectRatio(16 / 9)

// checkDevTools(displayWindow)
saveWindowConfig(displayWindow, storeKey)
displayWindow.on('close', () => {
if (displayWindow) {
const { x, y, width, height } = displayWindow.getBounds()
store.set('displayWindow', { x, y, width, height })
}
})
displayWindow.on('closed', () => {
displayWindow = null
})

await displayWindow.loadURL(pageUrl + '#display')
return displayWindow
Expand Down

0 comments on commit fb250f7

Please sign in to comment.