Skip to content

Commit

Permalink
Remember window position #216
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jun 21, 2022
1 parent 3bf1ce5 commit 8ce8ffe
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ if (dev === false) {
app.on("second-instance", () => {
logger.log("Already running, focusing window")

window_codes.maximize()
if (settings.window.maximized === true) {
window_codes.maximize()
}

window_codes.show()
})
}
Expand Down Expand Up @@ -248,6 +251,7 @@ const settings_file = {
y: 0,
height: 1900,
width: 1000,
maximized: true,
},
}

Expand Down Expand Up @@ -288,11 +292,18 @@ if (settings.window === undefined) {
y: 0,
height: 1900,
width: 1000,
maximized: true,
}

saveSettings()
}

if (settings.window.maximized === undefined) {
settings.window.maximized = true

saveSettings()
}

if (settings.settings.analytics === undefined) {
settings.settings.analytics = true

Expand All @@ -317,7 +328,10 @@ if (settings.settings.hardware_acceleration === false) {
const showAppFromTray = () => {
const toggle = () => {
if (codes_shown === false) {
window_codes.maximize()
if (settings.window.maximized === true) {
window_codes.maximize()
}

window_codes.show()

codes_shown = true
Expand Down Expand Up @@ -475,6 +489,7 @@ const createWindows = () => {
*/
const positionWindow = () => {
settings.window = window_codes.getBounds()
settings.window.maximized = window_codes.isMaximized()

window_settings.setBounds(settings.window)
window_tools.setBounds(settings.window)
Expand Down Expand Up @@ -511,8 +526,8 @@ const createWindows = () => {
icon: path.join(__dirname, "img/icon.png"),
x: settings.window.x,
y: settings.window.y,
width: 1900,
height: 1000,
width: settings.window.width,
height: settings.window.height,
minWidth: 1000,
minHeight: 600,
show: false,
Expand Down Expand Up @@ -587,6 +602,10 @@ const createWindows = () => {
positionWindow()
})

window_codes.on("resized", () => {
positionWindow()
})

// Enable remote module
remote.enable(window_security.webContents)
remote.enable(window_codes.webContents)
Expand Down Expand Up @@ -939,7 +958,10 @@ app.whenReady()

setTimeout(() => {
if (args[1] !== "--hidden") {
window_codes.maximize()
if (settings.window.maximized === true) {
window_codes.maximize()
}

window_codes.show()

codes_shown = true
Expand Down Expand Up @@ -1061,7 +1083,10 @@ ipc.on("toApplicationFromConfirm", () => {
if (authenticated === false) {
settings = JSON.parse(fs.readFileSync(path.join(folder_path, "settings", "settings.json"), "utf-8"))

window_codes.maximize()
if (settings.window.maximized === true) {
window_codes.maximize()
}

window_codes.show()

setTimeout(() => {
Expand Down

0 comments on commit 8ce8ffe

Please sign in to comment.