electron icon indicating copy to clipboard operation
electron copied to clipboard

[Bug]: Open BrowserWindow on secondary screen on MAc

Open NykoKar opened this issue 1 year ago • 1 comments

Preflight Checklist

Electron Version

30.0.6

What operating system are you using?

macOS

Operating System Version

MasOS Somona 14.4.1 - M1

What arch are you using?

Other (specify below)

Last Known Working Electron version

No response

Expected Behavior

Create a BrowserWindow on my secondary screen near secondary screen

Actual Behavior

The BrowserWindow is created on the main screen.

Testcase Gist URL

https://gist.github.com/NykoKar/f3f8e7eaec0e980d42d53c1b050e378b

Additional Information

I followed this documentation: https://www.electronjs.org/docs/latest/api/screen It works on Windows but not on MacOS.

NykoKar avatar May 17 '24 09:05 NykoKar

A better gist (to test on Fiddle for example): https://gist.github.com/NykoKar/002b79bdaed2bf36ab8f9bc30dbefec3

NykoKar avatar May 17 '24 09:05 NykoKar

I'm sorry, I'm unable to reproduce this issue given the test case provided on macOS. I checked my display settings and the displays reported by screen.getAllDisplays() and everything seems to be working properly.

Check out the Electron community. There are also a bunch of helpful people in this Discord that should be willing to point you in the right direction. For your question, I'd recommend the Discord - we have many active help channels and mentors, as well as fellow devs, who can help you out.

clavin avatar May 21 '24 22:05 clavin

@clavin Thank you for your feedback but I'm not sure you understand my issue (because I really think there is one) so I'll try to explain it better.

I have two screens next to each other (main in front of me, secondary on my right) and the function screen.getAllDisplays() also give me the right values:

[
  {
    id: 2,
    label: 'DELL U2720Q',
    bounds: { x: 0, y: 0, width: 3008, height: 1692 },
    workArea: { x: 0, y: 25, width: 3008, height: 1667 },
    accelerometerSupport: 'unknown',
    monochrome: false,
    colorDepth: 24,
    colorSpace: '{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}',
    depthPerComponent: 8,
    size: { width: 3008, height: 1692 },
    displayFrequency: 59,
    workAreaSize: { width: 3008, height: 1667 },
    scaleFactor: 2,
    rotation: 0,
    internal: false,
    touchSupport: 'unknown'
  },
  {
    id: 1,
    label: 'VG248',
    bounds: { x: 3008, y: 0, width: 1920, height: 1080 },
    workArea: { x: 3008, y: 25, width: 1920, height: 1055 },
    accelerometerSupport: 'unknown',
    monochrome: false,
    colorDepth: 24,
    colorSpace: '{r:[0.6502, 0.3292], g:[0.3301, 0.6229], b:[0.1513, 0.3292], w:[0.3127, 0.3290]}, transfer:BT709_APPLE, matrix:RGB, range:FULL}',
    depthPerComponent: 8,
    size: { width: 1920, height: 1080 },
    displayFrequency: 60,
    workAreaSize: { width: 1920, height: 1055 },
    scaleFactor: 1,
    rotation: 0,
    internal: false,
    touchSupport: 'unknown'
  }
]

So the second monitor, which is the VG248, has

bounds: { x: 3008, y: 0, width: 1920, height: 1080 },

So, to create a BrowserWindow on this monitor, I put these parameters on the constructor (x & y + 50 as indicated on electron's documentation ): new BrowserWindow({ x: 3008 + 50, y: 0 + 50, })

On my side, this BrowserWindow will be created on my primary screen whereas it should be displayed on my secondary as I have put coordinate of my secondary monitor.

Additional information: I'm working on a mac mini. So, maybe there is a difference of behaviour between macbook with 1 external screen and mac mini with 2 external screens, just an idea.

NykoKar avatar May 22 '24 08:05 NykoKar

Hello, hello.

Additional information: this works well in production (only). But it still doesn't work when the project is run locally.

NykoKar avatar Jun 12 '24 13:06 NykoKar

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!

Any progress ? same problem here.

100cm avatar Sep 11 '24 05:09 100cm

bump

NykoKar avatar Sep 11 '24 06:09 NykoKar

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!

I have resolved.

100cm avatar Dec 11 '24 02:12 100cm

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!