I was creating an Electron window on Linux on a 1920×1080 display but resulting viewport is 1px smaller (1919×1079). Window created like this:
const { app, BrowserWindow } = require('electron')
const path = require('node:path')
function createWindow () {
const mainWindow = new BrowserWindow({
frame: false,
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.setBounds({ x: 0, y: 0, width: 1920, height: 1080 })
mainWindow.loadFile('index.html')
mainWindow.show()
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
What options should be used to have viewport 1920×1080?
Window needs to be created like this:
const mainWindow = new BrowserWindow({
resizable: false, // <----- This options enables Electron window to take all space
frame: false,
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
Electron documentation on resizable option.