titleBarOverlay height resolves incorrectly after Windows DPI scaling
- Dominant language
- C++
- Stars
- 123k
- Forks
- 17.5k
- Avg merge
- 14h 22m
- Merged PRs (30d)
- 873
Description
### Preflight Checklist
- [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.
### Electron Version
43.0.0
### What operating system(s) are you using?
Windows
### Operating System Version
Windows 10, Windows 11
### What arch are you using?
x64
### Last Known Working Electron version
Unknown
### Does the issue also appear in Chromium / Google Chrome?
I don't know how to test
### Expected Behavior
When using `titleBarStyle: "hidden"` with `titleBarOverlay.height` set to `36`, the native Windows title bar overlay controls should align with the configured `36px` overlay height.
In the attached testcase, the renderer draws a minimal custom title bar:
```css
.title-bar {
-webkit-app-region: drag;
height: 36px;
background-color: #ffcece;
border-bottom: 1px solid #fb6363;
}
```
The expected behavior is that the red bottom border remains visible and is not covered by the native Windows title bar overlay controls.
### Actual Behavior
At Windows display scale values 150% and 175%, the native title bar overlay controls cover the red bottom border of the renderer title bar.
100%
125%
150%
175%
Observed display scale results:
| Windows display scale | Result |
| --------------------- | -------------------------------- |
| 100% | Correct |
| 125% | Correct |
| 150% | Broken: bottom border is covered |
| 175% | Broken: bottom border is covered |
| 200% | Correct |
| 225% | Correct |
This was tested on both Windows 10 and Windows 11 (screenshots from Windows 10).
### Testcase Gist URL
https://gist.github.com/Barakat/36160722024ed4233ec4d6a043da1480
### Additional Information
This is a minimal single-file reproduction using only `main.js`.
Testcase:
```js
const { app, BrowserWindow } = require("electron");
app.whenReady().then(() => {
const win = new BrowserWindow({
width: 300,
height: 300,
titleBarStyle: "hidden",
titleBarOverlay: {
color: "#fafafa",
symbolColor: "#4c4c4c",
height: 36,
},
});
const html = `
html, body {
margin: 0;
height: 100%;
}
.title-bar {
-webkit-app-region: drag;
height: 36px;
background-color: #ffcece;
border-bottom: 1px solid #fb6363;
}
`;
win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`);
});
app.on("window-all-closed", () => {
app.quit();
});
```
Run commands:
```bash
notepad main.js
npm init -y
npm install electron@latest --save-dev
npx electron main.js
```
Change the scaling settings from the Display Settings.
Contributor guide
Research direction
Begin with the supplied main.js reproduction and run it with electron@latest on Windows at the listed display-scale values. Compare titleBarOverlay.height with the 36px renderer title bar, focusing on 150% and 175%. Done means the native controls no longer cover the red bottom border at those scales.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100