Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

deepak1556
Copy link
Contributor

@deepak1556 deepak1556 requested a review from bpasero May 20, 2020 23:13
@deepak1556 deepak1556 self-assigned this May 20, 2020
@deepak1556 deepak1556 added this to the May 2020 milestone May 20, 2020
Copy link
Member

@bpasero bpasero left a 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?

@deepak1556 deepak1556 marked this pull request as draft May 27, 2020 12:06
@deepak1556
Copy link
Contributor Author

deepak1556 commented May 27, 2020

Converted to draft until E8 update.

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?

Do you mean other consumers of vscode build flavor ?

There is an explicit mention about it in the internal release notes.

@bpasero
Copy link
Member

bpasero commented May 27, 2020

@deepak1556

Do you mean other consumers of vscode build flavor ?

I was not clear: my understanding is that we will drop this patch we have for the old behaviour since we can now use app.focus({ steal: true });, but if we do that, any place where we call BrowserWindow.focus() today, we need to also call app.focus({ steal: true }); right?

@deepak1556
Copy link
Contributor Author

Is there any case other than the second instance launch where we rely on Browserwindow.focus to bring the app into focus ? This hack is only needed for such use case.

If the app is already in focus and we just want to switch focus between windows then BrowserWIndow.focus is sufficient.

@bpasero
Copy link
Member

bpasero commented May 28, 2020

@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?

@deepak1556 deepak1556 marked this pull request as ready for review June 24, 2020 07:20
@@ -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 });
Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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 deepak1556 modified the milestones: May 2020, June 2020 Jun 24, 2020
@bpasero
Copy link
Member

bpasero commented Jun 24, 2020

@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:

  • any direct calls to BrowserWindow#focus()
  • any calls to electron-main/window.ts#focus()
  • any calls to IElectronService#focusWindow()

Does that make sense?

@kieferrm kieferrm modified the milestones: June 2020, July 2020 Jul 6, 2020
@bpasero
Copy link
Member

bpasero commented Jul 21, 2020

Continues in #102011

@bpasero bpasero closed this Jul 21, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2020
@deepak1556 deepak1556 deleted the robo/fix_app_focus branch September 7, 2020 23:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants