Repository navigation
fix: on macOS show BrowserWindow on maximize if not currently shown - #32949
Conversation
0c6ba08 to
26a88ff
Compare
|
Release Notes Persisted
|
|
I was unable to backport this PR to "17-x-y" cleanly; |
|
I was unable to backport this PR to "18-x-y" cleanly; |
|
I was unable to backport this PR to "15-x-y" cleanly; |
|
I was unable to backport this PR to "16-x-y" cleanly; |
|
Fyi this is a somewhat breaking change and results in issues for VSCode. VSCode explicitly sets |
|
As a workaround, the current thinking is to also check for //cc @deepak1556 |
|
@bpasero, sorry it caused some problems for VSCode.
Despite the name, I'm assuming this is the relevant VSCode code, post-workaround?
If the intention is for the window to be focused, then I'd argue that isn't a workaround, but a more correct implementation. The original check for I would also argue that the previous code in VSCode was already buggy. On platforms other than macOS, the behavior of I think a possibly better way to accomplish the end goal there would be to set a one-time event listener for the 'maximize' event and take action once that fires, and don't bother with the conditional checks. The tests in Electron for Here's what I'm thinking: if (isFullscreenOrMaximized) {
mark('code/willMaximizeCodeWindow');
// to reduce flicker from the default window size to maximize, we only focus after maximize
this._win.once('maximize', () => {
this._win.focus();
mark('code/didMaximizeCodeWindow');
});
this._win.maximize();
if (this.windowState.mode === WindowMode.Fullscreen) {
this.setFullScreen(true);
}
}Might want to throw in a backstop to remove the event listener after a timeout in case the event doesn't fire for some reason, to prevent weird behavior if the window is later maximized. Unfortunately there are a lot of bugs around |
|
@dsanders11 has manually backported this PR to "19-x-y", please check out #34365 |
|
Just an FYI, @bpasero, noticed as a result of your comment that due to a process edge case this wasn't in |
|
@dsanders11 thanks for chiming in ❤️ . To clarify, the code we run with here is not new, we have been using it probably ever since we adopted Electron 7y ago. As I indicated before, it is an ugly workaround for not being able to set a window to be maximised or fullscreen when creating it to reduce flicker for the transition (more details in #34368). The only change that I pushed now was to throw in an additional Maybe we are just lucky that we did not hear issues on other platforms around window focus. The fact that I now got 5 issues in 3 weeks on macOS given this recent breakage makes me quite confident that on other platforms we are actually doing fine, so I am hesitant to make any further changes here without understanding the consequences. I think your change is not wrong, but I think to make the experience consistent across platforms, Irrespective, maybe the best change to do here is to simply always call |
There's a good chance that the documentation is inaccurate, and this PR was written to the documentation. 🙂 With some quick testing it looks like both Windows and Linux are focusing the window when it is shown via
I can't think of a negative side effect off the top of my head. |
|
👍 I suggest to just |
Description of Change
Fixes #32947.
Checklist
npm testpassesRelease Notes
Notes: Fixed behavior of BrowserWindow.maximize on macOS for not shown windows