Electron / Linux : 把全屏还给之前的应用

Electron / Linux : Give fullscreen back to previous application

我在网页中使用 electron (BrowserWindow)。

我在第一页使用这个:

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

webpage.html 中,我使用:

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

我的问题是,如果我有全屏的视频播放器 mpvwebpage.html 也会全屏显示。 (这很好。)

但是当 webpage.html 关闭时我的视频播放器并没有全屏...

我怎样才能做到这一点?

我猜它与您的 linux 桌面环境相关,而不是 Electron 本身。如果可以,您可以尝试通过根据屏幕分辨率设置 BrowserWindow 的大小来模拟全屏行为。

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