Search code examples
javascriptlinuxelectronfullscreen

Electron / Linux : Give fullscreen back to previous application


I'm using electron in webpages (BrowserWindow).

I use this in the first page :

MyWin = new BrowserWindow({show: false, fullscreen: true})
MyWin.loadURL('webpage.html');
MyWin.setAlwaysOnTop(true);
MyWin.once('ready-to-show', () => {
  MyWin.show();
  MyWin.focus();
})

And in the webpage.html, i use :

const remote = require('electron').remote;
var window = remote.getCurrentWindow();
window.close();

My problem is that if I have for example video player mpv in fullscreen, the webpage.html appears fullscreen as well. (Which is fine.)

But fullscreen is not given back to my video player when webpage.html is closed...

How can i achieve that ?


Solution

  • I guess it's more related to your linux desktop environment reather than electron itself. If you can, you could try to simulate the fullscreen behaviour by setting the size of your BrowserWindow according to your screen resolution.

     const { width, height } = electron.screen.getPrimaryDisplay().workAreaSize
     win = new BrowserWindow({ width, height, fullscreen: false })