fix: safer check for WCO button updates (#34833)
This commit is contained in:
parent
459404f536
commit
2eb0e5dcab
2 changed files with 38 additions and 3 deletions
|
@ -876,7 +876,7 @@ bool NativeWindowViews::IsMovable() {
|
||||||
void NativeWindowViews::SetMinimizable(bool minimizable) {
|
void NativeWindowViews::SetMinimizable(bool minimizable) {
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
FlipWindowStyle(GetAcceleratedWidget(), minimizable, WS_MINIMIZEBOX);
|
FlipWindowStyle(GetAcceleratedWidget(), minimizable, WS_MINIMIZEBOX);
|
||||||
if (titlebar_overlay_enabled()) {
|
if (IsWindowControlsOverlayEnabled()) {
|
||||||
auto* frame_view =
|
auto* frame_view =
|
||||||
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
|
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
|
||||||
frame_view->caption_button_container()->UpdateButtons();
|
frame_view->caption_button_container()->UpdateButtons();
|
||||||
|
@ -896,7 +896,7 @@ bool NativeWindowViews::IsMinimizable() {
|
||||||
void NativeWindowViews::SetMaximizable(bool maximizable) {
|
void NativeWindowViews::SetMaximizable(bool maximizable) {
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
FlipWindowStyle(GetAcceleratedWidget(), maximizable, WS_MAXIMIZEBOX);
|
FlipWindowStyle(GetAcceleratedWidget(), maximizable, WS_MAXIMIZEBOX);
|
||||||
if (titlebar_overlay_enabled()) {
|
if (IsWindowControlsOverlayEnabled()) {
|
||||||
auto* frame_view =
|
auto* frame_view =
|
||||||
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
|
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
|
||||||
frame_view->caption_button_container()->UpdateButtons();
|
frame_view->caption_button_container()->UpdateButtons();
|
||||||
|
@ -936,7 +936,7 @@ void NativeWindowViews::SetClosable(bool closable) {
|
||||||
} else {
|
} else {
|
||||||
EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
EnableMenuItem(menu, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||||
}
|
}
|
||||||
if (titlebar_overlay_enabled()) {
|
if (IsWindowControlsOverlayEnabled()) {
|
||||||
auto* frame_view =
|
auto* frame_view =
|
||||||
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
|
static_cast<WinFrameView*>(widget()->non_client_view()->frame_view());
|
||||||
frame_view->caption_button_container()->UpdateButtons();
|
frame_view->caption_button_container()->UpdateButtons();
|
||||||
|
|
|
@ -2427,6 +2427,41 @@ describe('BrowserWindow module', () => {
|
||||||
ifit(process.platform === 'darwin')('sets Window Control Overlay with hidden inset title bar', async () => {
|
ifit(process.platform === 'darwin')('sets Window Control Overlay with hidden inset title bar', async () => {
|
||||||
await testWindowsOverlay('hiddenInset');
|
await testWindowsOverlay('hiddenInset');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ifdescribe(process.platform === 'win32')('when an invalid titleBarStyle is initially set', () => {
|
||||||
|
let w: BrowserWindow;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
contextIsolation: false
|
||||||
|
},
|
||||||
|
titleBarOverlay: {
|
||||||
|
color: '#0000f0',
|
||||||
|
symbolColor: '#ffffff'
|
||||||
|
},
|
||||||
|
titleBarStyle: 'hiddenInset'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await closeAllWindows();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not crash changing minimizability ', () => {
|
||||||
|
expect(() => {
|
||||||
|
w.setMinimizable(false);
|
||||||
|
}).to.not.throw();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not crash changing maximizability', () => {
|
||||||
|
expect(() => {
|
||||||
|
w.setMaximizable(false);
|
||||||
|
}).to.not.throw();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(['win32', 'darwin'].includes(process.platform))('"titleBarOverlay" option', () => {
|
ifdescribe(['win32', 'darwin'].includes(process.platform))('"titleBarOverlay" option', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue