You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: BrowserWindow.maximize Does Not Show Window on macOS #32947
@dsanders11 I think this fix is not complete. From the docs:
Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already
With your change, the window will still not be visible but rather put behind the "key" (active) window. I would expect that the window is put above the active window and thus becomes visible.
With your change, the window will still not be visible but rather put behind the "key" (active) window. I would expect that the window is put above the active window and thus becomes visible.
The associated PR here simply calls through to window.showInactive(), so any incorrect behavior as described would be as a result of that method.
That said, I can't reproduce this. In my testing it puts the second, unfocused window in front in z-order. Here's the fiddle I'm using to test, on macOS 12.4 and Electron v20.0.0-alpha.1. The second (unshown) window is maximized after 8 seconds. In my tests, it always put above the active window, but does not take focus (as expected).
If you have a reproduce case, happy to take a look. But I'd suspect any buggy behavior will be in window.showInactive().
@dsanders11 yeah, I am also trying out in a Fiddle and I do not see the behaviour of VSCode, but I suspect this is due to how the issue reproduces in VS Code: users have reported that this issue reproduces when they launch VS Code from a terminal while VS Code is already running, so this also involves VS Code being inactive as application and another instance of VS Code trying to bring the first instance to front. To clarify:
one instance of VS Code is running with a window active and focused
user switches to OS terminal, VS Code is no longer active and focused
user types code folder path to open a new window on the folder
this launches a separate VS Code process for a very short moment that talks to the existing running instance
then it terminates after having send a payload to the first instance
the first instance opens a second window
this second window is initially show: false and then window.maximize
previously this would not show the window as inactive, but with your change it does
we check on window.isVisible to decide if we need to call window.show or not
now window.isVisible returns true even though the second window is behind the first window
To clarify: in VS Code we have a condition that sets show: false when the window to open is either maximized or fullscreen. We do that because otherwise there is an ugly transition from normal window bounds to maximized or fullscreen that we want to prevent. As such, in those cases we simply call window.maximize first and then window.show. To be honest, I would love to drop this hack and just have a way to pass maximized: true or fullscreen: true right when creating the window so that we can remove this code on our end, I will file an issue on that maybe.
Activity
Sankingraitus commentedon Feb 26, 2022
@Global-internet
bpasero commentedon May 27, 2022
@dsanders11 I think this fix is not complete. From the docs:
With your change, the window will still not be visible but rather put behind the "key" (active) window. I would expect that the window is put above the active window and thus becomes visible.
dsanders11 commentedon May 28, 2022
The associated PR here simply calls through to
window.showInactive(), so any incorrect behavior as described would be as a result of that method.That said, I can't reproduce this. In my testing it puts the second, unfocused window in front in z-order. Here's the fiddle I'm using to test, on macOS 12.4 and Electron v20.0.0-alpha.1. The second (unshown) window is maximized after 8 seconds. In my tests, it always put above the active window, but does not take focus (as expected).
If you have a reproduce case, happy to take a look. But I'd suspect any buggy behavior will be in
window.showInactive().bpasero commentedon May 28, 2022
@dsanders11 yeah, I am also trying out in a Fiddle and I do not see the behaviour of VSCode, but I suspect this is due to how the issue reproduces in VS Code: users have reported that this issue reproduces when they launch VS Code from a terminal while VS Code is already running, so this also involves VS Code being inactive as application and another instance of VS Code trying to bring the first instance to front. To clarify:
code folder pathto open a new window on the foldershow: falseand thenwindow.maximizewindow.isVisibleto decide if we need to callwindow.showor notwindow.isVisiblereturnstrueeven though the second window is behind the first windowTo clarify: in VS Code we have a condition that sets
show: falsewhen the window to open is either maximized or fullscreen. We do that because otherwise there is an ugly transition from normal window bounds to maximized or fullscreen that we want to prevent. As such, in those cases we simply callwindow.maximizefirst and thenwindow.show. To be honest, I would love to drop this hack and just have a way to passmaximized: trueorfullscreen: trueright when creating the window so that we can remove this code on our end, I will file an issue on that maybe.bpasero commentedon May 28, 2022
Opened: #34368