Skip to content

feat: add force option to app.focus() - #22612

Merged
codebytere merged 2 commits into
masterfrom
add-force-focus
Mar 11, 2020
Merged

codebytere merged 2 commits into
masterfrom
add-force-focus

Conversation

@codebytere

@codebytere codebytere commented Mar 9, 2020 •

Copy link
Copy Markdown
Member

Description of Change

Closes #22554.

Adds a new optional force parameter to app.focus(), which allows for apps to make themselves active even if other apps are active.

cc @MarshallOfSound @nornagon @ckerr

Checklist

Release Notes

Notes: Add a new force parameter to app.focus() on macOS to allow apps to forcefully take focus.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Mar 9, 2020
Comment thread docs/api/app.md Resolved
@codebytere
codebytere force-pushed the add-force-focus branch 2 times, most recently from 3619d7f to a707f66 Compare March 9, 2020 18:27
Comment thread docs/api/app.md Resolved
Comment thread docs/api/app.md Resolved
Comment thread shell/browser/browser_win.cc Resolved
Comment thread shell/browser/browser_mac.mm Resolved
Comment thread shell/browser/browser.h Resolved
@codebytere
codebytere force-pushed the add-force-focus branch 2 times, most recently from 5578605 to 375d6ff Compare March 9, 2020 19:09
Comment thread docs/api/app.md Resolved
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Mar 10, 2020

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

@codebytere
codebytere merged commit b724fbc into master Mar 11, 2020
@release-clerk

release-clerk Bot commented Mar 11, 2020

Copy link
Copy Markdown

Release Notes Persisted

Add a new force parameter to app.focus() on macOS to allow apps to forcefully take focus.

@trop

trop Bot commented May 7, 2020

Copy link
Copy Markdown
Contributor

@ckerr has manually backported this PR to "9-x-y", please check out #23447

codebytere added a commit that referenced this pull request May 7, 2020
@sofianguy

Copy link
Copy Markdown
Contributor

this was approved by the Releases WG on 5/6. removing pending-vote label

@trop

trop Bot commented May 13, 2020

Copy link
Copy Markdown
Contributor

@ckerr has manually backported this PR to "8-x-y", please check out #23574

@Goldiserv

Goldiserv commented Aug 25, 2022 •

Copy link
Copy Markdown

I had this issue after opening a separate chrome/firefox browser instance.

Solution's a bit hacky but works for me:

ipcMain.handle('focus', () => {
      // mainWindow?.moveTop(); // doesn't work
      mainWindow?.setAlwaysOnTop(true);
      mainWindow?.setAlwaysOnTop(false);
      mainWindow?.focus();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app.focus() not working

6 participants