mirror of
https://github.com/heyman/heynote.git
synced 2024-11-28 19:03:45 +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() {
|
async function createWindow() {
|
||||||
// default window size
|
// read any stored window settings from config, or use defaults
|
||||||
let windowConfig = {
|
let windowConfig = {
|
||||||
width: 900,
|
width: CONFIG.get("windowConfig.width", 900) as number,
|
||||||
height: 680,
|
height: CONFIG.get("windowConfig.height", 680) as number,
|
||||||
isMaximized: false,
|
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({
|
win = new BrowserWindow(Object.assign({
|
||||||
title: 'heynote',
|
title: 'heynote',
|
||||||
@ -80,11 +79,14 @@ async function createWindow() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
}, windowConfig))
|
}, windowConfig))
|
||||||
|
|
||||||
// maximize window if it was maximized last time
|
// maximize window if it was maximized last time
|
||||||
if (windowConfig.isMaximized) {
|
if (windowConfig.isMaximized) {
|
||||||
win.maximize()
|
win.maximize()
|
||||||
}
|
}
|
||||||
|
if (windowConfig.isFullScreen) {
|
||||||
|
win.setFullScreen(true)
|
||||||
|
}
|
||||||
|
|
||||||
win.on("close", (event) => {
|
win.on("close", (event) => {
|
||||||
// Prevent the window from closing, and send a message to the renderer which will in turn
|
// Prevent the window from closing, and send a message to the renderer which will in turn
|
||||||
@ -95,7 +97,8 @@ async function createWindow() {
|
|||||||
} else {
|
} else {
|
||||||
// save window config
|
// save window config
|
||||||
Object.assign(windowConfig, {
|
Object.assign(windowConfig, {
|
||||||
isMaximized: win.isMaximized()
|
isMaximized: win.isMaximized(),
|
||||||
|
isFullScreen: win.isFullScreen(),
|
||||||
}, win.getNormalBounds())
|
}, win.getNormalBounds())
|
||||||
CONFIG.set("windowConfig", windowConfig)
|
CONFIG.set("windowConfig", windowConfig)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user