Skip to content

[Bug]: Can't position BrowserWindow onto 2nd display with Wayland #43493

Closed as not planned

Description

@jlit

Preflight Checklist

Electron Version

32.0.1

What operating system(s) are you using?

Ubuntu, Other Linux

Operating System Version

Raspbian Debian Bookworm v12

What arch are you using?

Other (specify below)

Last Known Working Electron version

No response

Expected Behavior

With two displays I expect to be able to create a BrowserWindow with an (x, y) position that places the window on the 2nd display. This works as expected on MacOS and presumably other OSes but not on a Raspberry Pi running Bookworm, which uses Wayland, by default, instead of X11. Maybe be related to #40886. Switching Bookworm to X11 solves the problem.

Actual Behavior

Setting (x,y) coordinates in the new BrowserWindow arguments does one of three things, depending upon the window width/height and x/y. Either:

  • positions the window as expected on the active display
  • positions the window so that one or more edges (right and/or bottom) of the window are located at the edge of the active display
  • positions the window at the top left (roughly 0,0, but with about 10 pixels of margin) of the active display

There is no way to get a window onto the 2nd display.

Replicated in attached gist or using the code from https://github.com/electron/electron-quick-start, just adding x and y properties in main.js:

function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    x: 1024,
    y: 1152,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

Combinations tested from the display with width: 2048, height: 1152. I can't make sense of this. What I want is 800x600 at 1024, 1152 because that would place the window on the 2nd display, fullscreen. What really confuses be is when the x,y numbers get big, the window stops going to top left and ends up at the lower right corner.

  • {width: 800, height: 600, x: 125, y: 153} - positioned as expected
  • {width: 800, height: 600, x: 1023, y: 1151} - top left
  • {width: 800, height: 600, x: 1024, y: 1152} - top left
  • {width: 800, height: 600, x: 1025, y: 1153} - top left
  • {width: 750, height: 550, x: 1025, y: 1153} - top left
  • {width: 400, height: 300, x: 1023, y: 1151} - top left
  • {width: 750, height: 550, x: 1525, y: 1653} - right edge roughly mid screen, bottom of window on bottom of active display
  • {width: 800, height: 600, x: 2025, y: 2153} - lower right (bottom and right of window along edge of active display)
  • {width: 800, height: 600, x: 525, y: 553} - right edge roughly mid screen, bottom of window on bottom of active display
image

Display information from my pi is shown below. Note that the 2nd display is positioned at (1024, 1152) and is also visible in screen layout on screenshot above.

[
  {
    accelerometerSupport: 'unknown',
    bounds: { x: 1024, y: 1152, width: 1024, height: 768 },
    colorDepth: 24,
    colorSpace: '{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}',
    depthPerComponent: 8,
    detected: true,
    displayFrequency: 74.89952850341797,
    id: 33,
    internal: false,
    label: '',
    maximumCursorSize: { width: 0, height: 0 },
    monochrome: false,
    nativeOrigin: { x: 1024, y: 1152 },
    rotation: 0,
    scaleFactor: 1,
    size: { width: 1024, height: 768 },
    workArea: { x: 1024, y: 1152, width: 1024, height: 768 },
    workAreaSize: { width: 1024, height: 768 },
    touchSupport: 'unknown'
  },

  {
    accelerometerSupport: 'unknown',
    bounds: { x: 0, y: 0, width: 2048, height: 1152 },
    colorDepth: 24,
    colorSpace: '{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}',
    depthPerComponent: 8,
    detected: true,
    displayFrequency: 59.82716369628906,
    id: 35,
    internal: false,
    label: '',
    maximumCursorSize: { width: 0, height: 0 },
    monochrome: false,
    nativeOrigin: { x: 0, y: 0 },
    rotation: 0,
    scaleFactor: 1,
    size: { width: 2048, height: 1152 },
    workArea: { x: 0, y: 0, width: 2048, height: 1152 },
    workAreaSize: { width: 2048, height: 1152 },
    touchSupport: 'unknown'
  }
]

Testcase Gist URL

https://gist.github.com/de9b86a7601145082b2b4194c2f8a4d7

Additional Information

Architecture = ARMV71

Activity

  1. added
    has-repro-gist
    on Aug 27, 2024
  2. moved this to 👀 Unsorted Items in 32-x-yon Aug 27, 2024
  3. moved this to 👀 Unsorted Items in 33-x-yon Sep 4, 2024
  4. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 32-x-yon Sep 4, 2024
  5. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 33-x-yon Sep 4, 2024
  6. electron-issue-triage commented on Dec 4, 2024

    @electron-issue-triage

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  7. electron-issue-triage commented on Jan 4, 2025

    @electron-issue-triage

    This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

32-x-y33-x-ybug 🪲component/BrowserWindowhas-repro-gistplatform/linuxstalewayland

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions