Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron app across 2 displays?

Tags:

electron

Can an electron app run one window across 2 monitors? I'm not able to drag the edge across to the other monitor. is this possible?

I know I can do this to access the second screen.

    const electron = require('electron')
  const {app, BrowserWindow} = require('electron')

  let win

  app.on('ready', () => {
     let displays = electron.screen.getAllDisplays()
     let externalDisplay = displays.find((display) => {
     return display.bounds.x !== 0 || display.bounds.y !== 0
   })

if (externalDisplay) {
  win = new BrowserWindow({
    x: externalDisplay.bounds.x + 50,
    y: externalDisplay.bounds.y + 50
  })
  win.loadURL('https://github.com')
}
})

however, I dont want 2 windows just one across 2 displays.

like image 566
Mel Pacheco Avatar asked Feb 03 '26 07:02

Mel Pacheco


2 Answers

You can drag the electron window like any other window.

If you want to set the window size, you either do it when a BrowserWindow is created or via BrowserWindow.setSize() to modify the size see BrowserWindow docs

like image 96
Hans Koch Avatar answered Feb 05 '26 22:02

Hans Koch


That was real problem, that it was impossible to set via BrowserWindow.setSize() values gather than height and width of first screen, to open window stretched on few screens

But finally I have found, the solution is

BrowserWindow.setMinimumSize(W, H);

that allows to set width, like 10`000px, for few monitors, and it will be applied unlike setSize

like image 23
Sasha Kos Avatar answered Feb 06 '26 00:02

Sasha Kos