Skip to content

[Feature Request]: Let setFullScreen target a display (no workaround left on Wayland) #55761

Description

@nilovelez

Preflight Checklist

Problem Description

Apps that put a full-screen window on each display (presentation tools, kiosks, digital signage) need to choose the display for each window. Electron has no way to do that: win.setFullScreen(true) uses whatever display the window is on, and the usual workaround is to setBounds() the window onto the target display first.

On Wayland that workaround can't work: clients can't position their windows, and since 38.2 Electron runs natively on Wayland by default (#48833). The answer there was --ozone-platform=x11, but that is no longer an option either: some distributions no longer ship an X11 session (GNOME on Ubuntu 26.04 is Wayland only), and on our test machine (Dell laptop, Intel Iris Xe, Ubuntu 26.04) the app doesn't even paint through XWayland (XGetWindowAttributes failed, GPU process exiting with code 139). So on these desktops there is no workaround left.

What happens today: NativeWindowViews::SetFullScreen calls views::Widget::SetFullscreen(bool) with no display, so Chromium sends xdg_toplevel.set_fullscreen with a null output and the compositor decides. GNOME's Mutter puts a new window on the monitor under the mouse pointer, so a window meant for the projector often goes full screen on the laptop screen instead.

A minimal example, equivalent to what our app does:

const { app, BrowserWindow, screen } = require('electron')

app.whenReady().then(() => {
  const primary = screen.getPrimaryDisplay()
  const target = screen.getAllDisplays().find((d) => d.id !== primary.id)
  const win = new BrowserWindow({ ...target.bounds, fullscreen: true })
  win.loadURL('data:text/html,<h1>This should be on the second display</h1>')
})

On Windows, macOS and X11 the window goes full screen on the second display. On a Wayland session it goes full screen wherever the compositor puts it (on GNOME, the display under the pointer).

Proposed Solution

Let setFullScreen take the display to use:

win.setFullScreen(true, { displayId: display.id })

(and perhaps the same as a BrowserWindow constructor option), and pass it on to Chromium's existing views::Widget::SetFullscreen(bool fullscreen, int64_t target_display_id). On Wayland, Chromium already turns a target display into xdg_toplevel.set_fullscreen(output) with the matching wl_output (WaylandToplevelWindow::SetFullscreen). On Windows, macOS and X11, Electron could keep doing what apps do by hand today: move the window to the display's bounds, then go full screen.

Alternatives Considered

  • setBounds() to the target display, then setFullScreen(true): works on Windows, macOS and X11; on Wayland the position is ignored.
  • --ozone-platform=x11: not available on Wayland-only desktops, and on our machine the window doesn't paint through XWayland.
  • element.requestFullscreen({ screen }) (Window Management API): in Electron it only goes full screen on the current display ([Bug]: Multi-Screen Window Placement API not working #31103).
  • Checking where a window landed and moving or recreating it: on Wayland getBounds() always starts at 0,0, getScreenDetails().currentScreen reported the primary display, and new windows go to the pointer's display again.
  • Asking users to move the window with the desktop's shortcut (Super+Shift+arrow on GNOME). This is what we document now, but it is no fix for an app whose users are on stage.

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions