Skip to content

Commit

Permalink
enhance: open larger electron window if supported by display dimensions
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Hale <[email protected]>
  • Loading branch information
njhale committed Aug 19, 2024
1 parent 981e45e commit 29e2f2f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions electron/main.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, shell, BrowserWindow } from 'electron';
import { app, shell, screen, BrowserWindow } from 'electron';
import { getPort } from 'get-port-please';
import { startAppServer } from '../server/app.mjs';
import { join, dirname } from 'path';
Expand Down Expand Up @@ -69,11 +69,13 @@ async function startServer(isPackaged) {
}

function createWindow(url) {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
const isMac = os.platform() === 'darwin';
const win = new BrowserWindow({
width: 1024,
height: 720,
frame: isMac ? false : true, // Use frame: true for Windows and Linux
width: Math.min(width, 1280),
height: Math.min(height, 960),
center: true,
frame: !isMac,
webPreferences: {
preload: join(app.getAppPath(), 'electron/preload.js'),
nodeIntegration: true,
Expand Down

0 comments on commit 29e2f2f

Please sign in to comment.