mirror of
https://github.com/heyman/heynote.git
synced 2024-12-26 16:48:48 +01:00
Restore fullscreen mode if the program was in fullscreen when quitting
Read specific keys from CONFIG.windowConfig instead of using Object.assign for whatever is in the config file.
This commit is contained in:
parent
80febafd26
commit
ddc184fb24
@ -55,14 +55,13 @@ let contentSaved = false
|
||||
|
||||
|
||||
async function createWindow() {
|
||||
// default window size
|
||||
// read any stored window settings from config, or use defaults
|
||||
let windowConfig = {
|
||||
width: 900,
|
||||
height: 680,
|
||||
isMaximized: false,
|
||||
width: CONFIG.get("windowConfig.width", 900) as number,
|
||||
height: CONFIG.get("windowConfig.height", 680) as number,
|
||||
isMaximized: CONFIG.get("windowConfig.isMaximized", false) as boolean,
|
||||
isFullScreen: CONFIG.get("windowConfig.isFullScreen", false) as boolean,
|
||||
}
|
||||
// read any stored window settings from config
|
||||
Object.assign(windowConfig, CONFIG.get("windowConfig"))
|
||||
|
||||
win = new BrowserWindow(Object.assign({
|
||||
title: 'heynote',
|
||||
@ -80,11 +79,14 @@ async function createWindow() {
|
||||
},
|
||||
|
||||
}, windowConfig))
|
||||
|
||||
|
||||
// maximize window if it was maximized last time
|
||||
if (windowConfig.isMaximized) {
|
||||
win.maximize()
|
||||
}
|
||||
if (windowConfig.isFullScreen) {
|
||||
win.setFullScreen(true)
|
||||
}
|
||||
|
||||
win.on("close", (event) => {
|
||||
// Prevent the window from closing, and send a message to the renderer which will in turn
|
||||
@ -95,7 +97,8 @@ async function createWindow() {
|
||||
} else {
|
||||
// save window config
|
||||
Object.assign(windowConfig, {
|
||||
isMaximized: win.isMaximized()
|
||||
isMaximized: win.isMaximized(),
|
||||
isFullScreen: win.isFullScreen(),
|
||||
}, win.getNormalBounds())
|
||||
CONFIG.set("windowConfig", windowConfig)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user