Repository navigation
Fix showing a minimized main window - #11646
Merged
Merged
Conversation
jgutman
approved these changes
Jul 21, 2022
kevinushey
added a commit
that referenced
this pull request
Aug 26, 2026
The previous revision made the visible case a no-op, which dropped the z-order raise the callback exists to perform: AppCommand documents the intent as "we still want the main window to be as visible as possible, so bring it up behind the current window", and the Qt implementation restacked with SetWindowPos(..., SWP_NOACTIVATE). A main window buried under a browser or terminal would stay buried when a background command ran from a satellite. moveTop() on the main window followed by moveTop() on the active one restores that raise without touching focus. It is a non-activating restack on every platform Electron implements it for -- SetWindowPos(HWND_TOP, SWP_NOACTIVATE) on Windows, _NET_RESTACK_WINDOW on X11, orderWindow:NSWindowAbove on macOS -- and a no-op on Wayland, which matches the Qt version's platform coverage. showInactive() also does not de-miniaturize a window: on macOS it is orderFrontRegardless, which Apple documents as pure ordering, "without changing either the key window or the main window". The minimized case #11646 fixed now goes through restore() -- [window_ deminiaturize:nil] -- which is what raiseAndActivateWindow() in utils.ts already does. Addresses #18635
kevinushey
added a commit
that referenced
this pull request
Aug 27, 2026
…te (#18642) * don't bounce OS focus when surfacing the main window behind a satellite The bringMainFrameBehindActive desktop callback means "make the main window visible, but leave focus alone" -- GWT routes every cross-window event whose focus mode is MODE_AUXILIARY through it, including the SendToConsoleEvent fired when code is run from a popped-out source window with "focus console after executing code" turned off. The Electron implementation got there by focusing the main window and then handing focus back to the active one. Window managers with focus-stealing prevention refuse the second half of that bounce, so focus is left on the main window and the caret lands in the console -- exactly what the preference asks RStudio not to do. The Qt implementation this replaced used SetWindowPos with SWP_NOACTIVATE and was a deliberate no-op outside Windows. A main window that is already on screen now needs nothing done to it at all, and a hidden or minimized one is surfaced with showInactive() so focus is never touched. The minimized case that #11646 fixed is preserved. Addresses #18635 * restack the main window instead of leaving it alone when it is visible The previous revision made the visible case a no-op, which dropped the z-order raise the callback exists to perform: AppCommand documents the intent as "we still want the main window to be as visible as possible, so bring it up behind the current window", and the Qt implementation restacked with SetWindowPos(..., SWP_NOACTIVATE). A main window buried under a browser or terminal would stay buried when a background command ran from a satellite. moveTop() on the main window followed by moveTop() on the active one restores that raise without touching focus. It is a non-activating restack on every platform Electron implements it for -- SetWindowPos(HWND_TOP, SWP_NOACTIVATE) on Windows, _NET_RESTACK_WINDOW on X11, orderWindow:NSWindowAbove on macOS -- and a no-op on Wayland, which matches the Qt version's platform coverage. showInactive() also does not de-miniaturize a window: on macOS it is orderFrontRegardless, which Apple documents as pure ordering, "without changing either the key window or the main window". The minimized case #11646 fixed now goes through restore() -- [window_ deminiaturize:nil] -- which is what raiseAndActivateWindow() in utils.ts already does. Addresses #18635 * re-add the NEWS entry for #18635 Lost in the merge of main: #18644 rewrote the Autumn Hawkbit entries and resolving the conflict by taking main's NEWS.md wholesale dropped this branch's entry instead of re-adding it. * hand focus back when de-miniaturizing had to activate the main window restore() is an activating call on every platform where it is the only way back onto the screen -- ExecuteSystemMenuCommand(SC_RESTORE) on Windows, deminiaturize: on macOS -- so the minimized branch moved OS focus to the main window and, unlike the pre-Electron-port code, never handed it back. Combined with the moveTop pair that follows, the satellite ended up visually on top while keystrokes went to the console. Try showInactive() first: on Windows it is SW_SHOWNOACTIVATE, which de-miniaturizes without activating. It is pure ordering on macOS and a no-op for an already-mapped window on X11, so restore() is still needed there, and focus is returned to the active window afterwards. Only the minimized path does this; the case #18635 is about never reaches it. Addresses #18635
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
There was an issue showing a minimized window when Jon tested this initially. #11407
Approach
show()will raise and focus the window. The secondary window is then focused to bring it back to the top. I triedshowInactive()which seems to imply that it will raise but not focus the window but it always focused the window for me on Mac.Automated Tests
None
QA Notes
None
Checklist
NEWS.md