filip
filip

Reputation: 700

X11 xorg Electron App cant open in fullscreen

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`)

    //// 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)

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. The screen

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:

Upvotes: 4

Views: 3036

Answers (4)

Jimbly
Jimbly

Reputation: 344

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);
}

Upvotes: 0

Plantt
Plantt

Reputation: 342

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:

  1. The window is frameless
  2. Changes to the window size & toggling fullscreen sometimes behave weird

Upvotes: 2

filip
filip

Reputation: 700

The Problem was the app wasn't run from electron itself, my script started the index.html file, not the app!

Upvotes: 1

Joshua
Joshua

Reputation: 5322

This 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.

Upvotes: 3

Related Questions