We have an electron app running on X11 without a Window Manager -> directly on the XServer.
We can't get electron to get in fullscreen!
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`)
//// unment 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)
We also tried using setFullscreen, nothing works.
The xserver uses the whole screen, so there's no problem with it. Chromium started in fullscreen - no problems.
If we start Electron with an Window Manager, we can press F11 afterwards to make it full size but still doesn't work programmaticly
We tried:
- Setting the width and height with the resolution from the screen itself in the BrowserWindow Constructor.
- Setting Kiosk with .setKiosk(true) and in options kiosk: true
- Setting Fullscreen with .setFullscreen(true) and fullscreen: true
We have an electron app running on X11 without a Window Manager -> directly on the XServer.
We can't get electron to get in fullscreen!
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`)
//// unment 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)
We also tried using setFullscreen, nothing works.
The xserver uses the whole screen, so there's no problem with it. Chromium started in fullscreen - no problems.
If we start Electron with an Window Manager, we can press F11 afterwards to make it full size but still doesn't work programmaticly
We tried:
- Setting the width and height with the resolution from the screen itself in the BrowserWindow Constructor.
- Setting Kiosk with .setKiosk(true) and in options kiosk: true
- Setting Fullscreen with .setFullscreen(true) and fullscreen: true
- 1 Hi, I know this is an old question, but how did you manage to run electron app on raspbian lite I just have x-server installed and ssh-ed it. I used electron-packager and built packages but after copying files it does not work. I need to have a very minimal version of Debian and oh I did not install node as i suppose it is not needed to run packaged apps – Rati_Ge Commented May 17, 2019 at 0:47
- We didn't even package it. It is a bad practise to do so, but it was just a school project so we didn't care => we just started with "electron ." so no packager or anything else. @Rati_Ge – filip Commented May 18, 2019 at 8:28
- 1 I See but cannot understand why packing or creating .deb is a bad idea there after all if this is a mercial product you can not force clients to download full node environment and npm and restore staff during install and leave sources open on the device. – Rati_Ge Commented May 18, 2019 at 17:47
- No no! Packaging is the way to go!! I meant that I didn't package it because it was just a school project. That's why I can't help you with that. Packaging is best practice. Now that I read my ment I should rephrase that lol – filip Commented May 18, 2019 at 22:45
4 Answers
Reset to default 3This might not be what you want but there is a option called kiosk
this is basically fullscreen mode exept the page covers the entire screen. Also you can't escape from it until kiosk mode is turned off.
To activate you can either call setKiosk(true)
. Or set kiosk: true
in the browser window options
setKiosk
Docs.
Note: This is specifically for Linux Xorg. It has been tested on Fedora 39.0 GNOME Xorg, Electron v28.1.0.
To make the window fullscreenable on Linux, in Xorg window manager, you can set fullscreen
to true and set the window initially frameless. Then remove the fullscreen and you can make the window fullscreen whenever you want to.
var window = new BrowserWindow({
fullscreen: true,
frame: false
});
window.setFullScreen(false);
The only problems with this are:
- The window is frameless
- Changes to the window size & toggling fullscreen sometimes behave weird
The Problem was the app wasn't run from electron itself, my script started the index.html file, not the app!
Since toggling fullscreen of a running app works fine, a fix that worked for me on Ubuntu was to "create" the window not in fullscreen and then immediately toggle fullscreen:
var window = new BrowserWindow({
fullscreen: process.platform === 'linux' ? false : true,
});
if (process.platform === 'linux') {
window.setFullScreen(true);
}