[Bug]: titleBarOverlay and ready-to-show conflict
- Dominant language
- C++
- Stars
- 123k
- Forks
- 17.5k
- Avg merge
- 14h 28m
- Merged PRs (30d)
- 870
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
28.2.0
### What operating system are you using?
Windows
### Operating System Version
Windows 11 23H2
### What arch are you using?
x64
### Last Known Working Electron version
_No response_
### Expected Behavior
When creating a `BrowserWindow`, set `show: false` in the options and listen for the `ready-to-show` event of the window. When the event is triggered, the window will be displayed. Generally speaking, this will run normally. But when `titleBarStyle:' hidden` and ` titleBarOverlay: true` are set in the options, window will not send a `ready-to-show` event unless `show` in the options is set to `true`.
### Actual Behavior
My code is as follows:
```typescript
import { app, BrowserWindow, Menu } from 'electron'
import { join } from 'path'
/** 主窗口 */
let mainWindow: BrowserWindow | null = null
/** 创建主窗口 */
function createWindow() {
mainWindow = new BrowserWindow({
width: 900,
height: 670,
show: false,
backgroundColor: 'rgb(32, 32, 32)',
titleBarStyle: 'hidden',
titleBarOverlay: {
color: 'rgba(0, 0, 0, 0)',
symbolColor: 'rgb(255, 255, 255)',
height: 32
},
webPreferences: {
preload: join(__dirname, '../preload/index.js')
}
})
mainWindow.on('closed', () => {
mainWindow = null
})
mainWindow.on('ready-to-show', () => {
console.log('ready')
mainWindow?.show()
})
mainWindow.webContents.loadURL('https://electronjs.org')
}
/**
* 初始化
*/
function initialize(): void {
app.whenReady().then(() => {
createWindow()
})
}
// 取消默认菜单栏
Menu.setApplicationMenu(null)
// 初始化程序
initialize()
```
The console will not print `ready`, and the window will not be displayed, but when I set show to true, the window will be displayed normally, and after it is displayed, it will print `ready`. This means that the window will be displayed before `ready-to-show`, but this is not what I need. I want the window to be displayed after `ready-to-show`.
### Testcase Gist URL
_No response_
### Additional Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.