fix: fire show event when BrowserWindow shown via maximize() (#32979)
This commit is contained in:
parent
86e746c36b
commit
e589e9b259
3 changed files with 31 additions and 5 deletions
|
@ -580,11 +580,13 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(IS_LINUX)
|
||||||
void NativeWindowViews::Maximize() {
|
void NativeWindowViews::Maximize() {
|
||||||
if (IsVisible())
|
if (IsVisible()) {
|
||||||
widget()->Maximize();
|
widget()->Maximize();
|
||||||
else
|
} else {
|
||||||
widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED,
|
widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED,
|
||||||
gfx::Rect());
|
gfx::Rect());
|
||||||
|
NotifyWindowShow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -178,12 +178,13 @@ HHOOK NativeWindowViews::mouse_hook_ = NULL;
|
||||||
void NativeWindowViews::Maximize() {
|
void NativeWindowViews::Maximize() {
|
||||||
// Only use Maximize() when window is NOT transparent style
|
// Only use Maximize() when window is NOT transparent style
|
||||||
if (!transparent()) {
|
if (!transparent()) {
|
||||||
if (IsVisible())
|
if (IsVisible()) {
|
||||||
widget()->Maximize();
|
widget()->Maximize();
|
||||||
else
|
} else {
|
||||||
widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED,
|
widget()->native_widget_private()->Show(ui::SHOW_STATE_MAXIMIZED,
|
||||||
gfx::Rect());
|
gfx::Rect());
|
||||||
return;
|
NotifyWindowShow();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
restore_bounds_ = GetBounds();
|
restore_bounds_ = GetBounds();
|
||||||
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
|
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
|
||||||
|
|
|
@ -3526,6 +3526,29 @@ describe('BrowserWindow module', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO(dsanders11): Enable once maximize event works on Linux again on CI
|
||||||
|
ifdescribe(process.platform !== 'linux')('BrowserWindow.maximize()', () => {
|
||||||
|
afterEach(closeAllWindows);
|
||||||
|
// TODO(dsanders11): Disabled on macOS, see https://github.com/electron/electron/issues/32947
|
||||||
|
ifit(process.platform !== 'darwin')('should show the window if it is not currently shown', async () => {
|
||||||
|
const w = new BrowserWindow({ show: false });
|
||||||
|
const hidden = emittedOnce(w, 'hide');
|
||||||
|
const shown = emittedOnce(w, 'show');
|
||||||
|
const maximize = emittedOnce(w, 'maximize');
|
||||||
|
expect(w.isVisible()).to.be.false('visible');
|
||||||
|
w.maximize();
|
||||||
|
await maximize;
|
||||||
|
expect(w.isVisible()).to.be.true('visible');
|
||||||
|
// Even if the window is already maximized
|
||||||
|
w.hide();
|
||||||
|
await hidden;
|
||||||
|
expect(w.isVisible()).to.be.false('visible');
|
||||||
|
w.maximize();
|
||||||
|
await shown; // Ensure a 'show' event happens when it becomes visible
|
||||||
|
expect(w.isVisible()).to.be.true('visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('BrowserWindow.unmaximize()', () => {
|
describe('BrowserWindow.unmaximize()', () => {
|
||||||
afterEach(closeAllWindows);
|
afterEach(closeAllWindows);
|
||||||
it('should restore the previous window position', () => {
|
it('should restore the previous window position', () => {
|
||||||
|
|
Loading…
Reference in a new issue