-
Notifications
You must be signed in to change notification settings - Fork 17.1k
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
38.3.0
What operating system(s) are you using?
Ubuntu
Operating System Version
Ubuntu 24.04
What arch are you using?
x64
Last Known Working Electron version
No response
Does the issue also appear in Chromium / Google Chrome?
No
Expected Behavior
An 800x600 window should be able to keep consistent dimensions after creation, including when it loses focus.
Actual Behavior
An 800x600 window goes on a journey after you create it, first starting at 800x600 absolute bounds (which is incorrect: see #48589), then growing to its proper size after creation and then shrinking to about 785x580 if you click out of it to lose focus.
Logs from the Fiddle:
Main window bounds at creation: { x: 645, y: 172, width: 800, height: 600 }
Main window bounds after 1s: { x: 0, y: 0, width: 844, height: 644 }
Main window bounds after blur (assuming you manually de-focused it): { x: 0, y: 0, width: 822, height: 625 }
Testcase Gist URL
https://gist.github.com/mitchchn/7487efc43b208a3624ba464cb156860d
Additional Information
Some context to help diagnose the root cause: on Wayland (and in GNOME specifically), Electron draws all window decorations using CSD, including titlebars, borderes, and shadows.
This means that an 800x600 BrowserWindow actually sits inside a larger 844x644 transparent frame into which the active shadows are drawn. When the window goes inactive, the shadows are drawn thinner, so the transparent frame shrinks. This incorrectly causes the client area of the window to shrink as well. (But for some reason everything works fine after the first time the window loses focus on subsequent focus cycles.)