我们有一个电子应用程序在 X11 上运行,没有窗口管理器 -> 直接在 XServer 上运行。
我们无法让电子进入全屏!
main.js
const { app, BrowserWindow } = require('electron')
let win;
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 400,
height: 300,
backgroundColor: '#ffffff',
fullscreen:true,
"web-preferences": { "web-security": false }
//icon: `file://${__dirname}/dist/assets/logo.png`
})
win.loadFile(`app/index.html`)
//// uncomment below to open the DevTools.
win.webContents.openDevTools()
// Event when the window is closed.
win.on('closed', function () {
win = null
})
}
// Create window on electron intialization
app.on('ready', createWindow)
我们也尝试过使用 setFullscreen,但没有效果。
xserver使用的是全屏,所以没有问题。 Chromium 以全屏启动 - 没有问题。
如果我们使用窗口管理器启动 Electron,我们可以随后按 F11 使其变为全尺寸,但仍然无法以编程方式工作
我们尝试过:
问题是应用程序不是从电子本身运行,我的脚本启动了index.html文件,而不是应用程序!
注意: 这是专门针对 Linux Xorg 的。它已经在 Fedora 39.0 GNOME Xorg、Electron v28.1.0 上进行了测试。
要使窗口在 Linux 上全屏显示,在 Xorg 窗口管理器中,您可以将
fullscreen
设置为 true 并将窗口初始设置为无框。然后删除全屏,您就可以随时将窗口设为全屏。
var window = new BrowserWindow({
fullscreen: true,
frame: false
});
window.setFullScreen(false);
唯一的问题是: