-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: window focus for second instance on macOS #98279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably obsolete now that we went back to Electron 7, but feel free to create this PR again from the electron-8.x
branch.
Feedback: if we drop our internal patch, we need to check any user of BrowserWindow.focus()
to use app.focus
instead, otherwise we cause regressions, no?
Converted to draft until E8 update.
Do you mean other consumers of vscode build flavor ? There is an explicit mention about it in the internal release notes. |
I was not clear: my understanding is that we will drop this patch we have for the old behaviour since we can now use |
Is there any case other than the second instance launch where we rely on If the app is already in focus and we just want to switch focus between windows then |
@deepak1556 well, we would have to check case by case, but for example hitting a debug breakpoint I think also triggers this in debug land? |
1c5c5dd
to
5524c85
Compare
@@ -105,6 +105,9 @@ export class LaunchMainService implements ILaunchMainService { | |||
|
|||
const waitMarkerFileURI = args.wait && args.waitMarkerFilePath ? URI.file(args.waitMarkerFilePath) : undefined; | |||
|
|||
// Force focus the app before requesting window focus | |||
app.focus({ steal: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always let the app take focus when launching second instance, previously it was only covering a single case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what does that mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this fix the behavior is,
code-insiders abc/
-> will get focus
code-insiders .
-> will not get focus
which is a regression from how it behaved with E7
@deepak1556 I think to make progress on this PR you will have to go through all the calls to window focus and then come up with a proposal if this new flag is needed or not. This includes:
Does that make sense? |
Continues in #102011 |
Since
8.3.0
the correct way to steal focus has been changed, since we no longer carry the patch in the internal build https://domoreexp.visualstudio.com/Teamspace/_git/electron-build?path=%2Fpatches%2Fcustomization%2Felectron%2Ffeat_allow_app_to_steal_focus_on_macos.patch&version=GBrelease%2F7-2-x&_a=contentsref electron/electron#23574