Closed martbrugg closed 2 weeks ago
30.0.5
Windows
Windows 11
x64
30.0.3
If i move the window with win.setPosition to the current screen and call win.center() aftwards I expect the window to be centered in this screen.
const { app, BrowserWindow } = require("electron"); const { screen } = require("electron/main"); const createWindow = () => { const win = new BrowserWindow({ width: 800, height: 600, }); win.loadFile("index.html"); }; app.whenReady().then(() => { createWindow(); //after primary window is shown i move it to a second screen an wait for the second window to appear setTimeout(() => { createDialogWindow(); }, 10000); }); const createDialogWindow = () => { const win = new BrowserWindow({ width: 400, height: 300, }); const cursor = screen.getCursorScreenPoint(); const currentScreen = screen.getDisplayNearestPoint(cursor); win.setPosition(currentScreen.workArea.x, currentScreen.workArea.y, false); win.center(); win.loadFile("index.html"); };
Dialog Window ist positioned in the left top corner of the screen.
Example https://gist.github.com/martbrugg/d553aabb9751853bb9188c8808b31bb2
the provided code example works till version 30.0.3. Starting with V3.0.4 this issue appears
Preflight Checklist
Electron Version
30.0.5
What operating system are you using?
Windows
Operating System Version
Windows 11
What arch are you using?
x64
Last Known Working Electron version
30.0.3
Expected Behavior
If i move the window with win.setPosition to the current screen and call win.center() aftwards I expect the window to be centered in this screen.
Actual Behavior
Dialog Window ist positioned in the left top corner of the screen.
Testcase Gist URL
Example https://gist.github.com/martbrugg/d553aabb9751853bb9188c8808b31bb2
Additional Information
the provided code example works till version 30.0.3. Starting with V3.0.4 this issue appears