Skip to content

Commit

Permalink
Merge pull request #1236 from quintushr/master
Browse files Browse the repository at this point in the history
Maximizing the desktop application window upon opening
  • Loading branch information
perry-mitchell authored Nov 3, 2023
2 parents 22ec563 + 8abd91d commit 092d352
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/main/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const DEFAULT_CONFIG = {
windowHeight: 600,
windowWidth: 800,
windowX: null,
windowY: null
windowY: null,
isMaximize: false
};

export async function getConfigValue<T>(key: string): Promise<T> {
Expand Down
13 changes: 13 additions & 0 deletions source/main/services/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async function createVaultWindow() {
const height = await getConfigValue<number>("windowHeight");
const x = await getConfigValue<number>("windowX");
const y = await getConfigValue<number>("windowY");
const isMaximize = await getConfigValue<boolean>("isMaximize");
const config: BrowserWindowConstructorOptions = {
width,
height,
Expand All @@ -38,6 +39,9 @@ async function createVaultWindow() {
config.y = y;
}
const win = new BrowserWindow(config);
if (isMaximize) {
win.maximize();
}
enableWebContents(win.webContents);
win.on("closed", () => {
win.removeAllListeners();
Expand All @@ -47,6 +51,15 @@ async function createVaultWindow() {
"resize",
debounce(() => handleWindowBoundsUpdate(win), 750, false)
);

win.on("maximize", async () => {
await setConfigValue("isMaximize", win.isMaximized());
});

win.on("unmaximize", async () => {
await setConfigValue("isMaximize", win.isMaximized());
});

win.on(
"move",
debounce(() => handleWindowBoundsUpdate(win), 750, false)
Expand Down

0 comments on commit 092d352

Please sign in to comment.