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

feat: add app.isHidden API for macOS #32155

Merged
merged 5 commits into from Mar 30, 2022

Conversation

mitchchn
Copy link
Contributor

@mitchchn mitchchn commented Dec 11, 2021

Description of Change

Refs #30485.

Added an API to check if the app is hidden on macOS. This is a distinct state from the app windows being hidden, and can be used to implement unique behaviour on activation. It is also useful in conjunction with NSWindow.canHide, which I will introduce in a follow-up MR if there are no objections.

Checklist

Release Notes

Notes: Added app.isHidden() to check if the app is hidden (e.g. with Command-H) on macOS.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Dec 11, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Dec 18, 2021
@codebytere codebytere added api-review/requested 🗳 semver/minor backwards-compatible functionality labels Jan 3, 2022
@codebytere codebytere requested a review from a team January 3, 2022 10:22
@jkleinsc
Copy link
Contributor

jkleinsc commented Jan 5, 2022

API LGTM

@mitchchn
Copy link
Contributor Author

It looks like CI timed out but I'm unable to re-run it. There shouldn't be any test failures.

@nornagon
Copy link
Member

@mitchchn
Copy link
Contributor Author

@nornagon the reason I didn't add a getter is because there is no setter (unless app.hidden = true hides the app, which feels wrong to me?) and also out of analogy with BrowserWindow.isVisible() which does not have a getter. I can add one if you still think it should be there.

Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

Looks like newly added tests are failing

@nornagon
Copy link
Member

@mitchchn I don't feel strongly enough about it to block this, so API LGTM.

Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

API LGTM

docs/api/app.md Outdated Show resolved Hide resolved
@mitchchn
Copy link
Contributor Author

mitchchn commented Mar 3, 2022

Looks like newly added tests are failing

@jkleinsc hiding and unhiding is async. To reliably wait on these events in the test suite I would need to expose "hide" and "unhide" events on app for macOS (https://developer.apple.com/documentation/appkit/nsapplication/1428562-didhidenotification). How would we feel about that? These events may be useful to users and good complements to the app.show(), app.hide() and app.isHIdden() APIs.

@jkleinsc
Copy link
Contributor

jkleinsc commented Mar 3, 2022

@mitchchn you can use the waitUntil spec helper:

      await expect(
        waitUntil(() => app.isHidden() === true)
      ).to.eventually.be.fulfilled();

@mitchchn mitchchn force-pushed the mitch/macos-hide-api branch 2 times, most recently from 01c707f to fc1c9b5 Compare March 3, 2022 15:37
mitchchn and others added 2 commits March 3, 2022 12:06
Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
@mitchchn mitchchn requested a review from jkleinsc March 3, 2022 17:08
Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

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

API LGTM

@nornagon nornagon self-assigned this Mar 7, 2022
Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

The documentation for this feature needs to specify that the return value is a boolean so that the typescript generator can properly label this function's return value.

docs/api/app.md Outdated Show resolved Hide resolved
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
@nornagon nornagon removed their assignment Mar 9, 2022
Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

The new test should use the ifdescribe helper

spec-main/api-app-spec.ts Outdated Show resolved Hide resolved
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
@mitchchn
Copy link
Contributor Author

@jkleinsc: thanks for your review feedback. Is there anything left for me to do here? It looks like CI is timing out, not failing on my test, but if that's not the case I can investigate.

@jkleinsc jkleinsc merged commit a929622 into electron:main Mar 30, 2022
@release-clerk
Copy link

release-clerk bot commented Mar 30, 2022

Release Notes Persisted

Added app.isHidden() to check if the app is hidden (e.g. with Command-H) on macOS.

@trop
Copy link
Contributor

trop bot commented Mar 30, 2022

I was unable to backport this PR to "18-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented Mar 30, 2022

I was unable to backport this PR to "19-x-y" cleanly;
you will need to perform this backport manually.

bavulapati pushed a commit to bavulapati/electron that referenced this pull request Apr 29, 2022
* feat: add app.isHidden API

* Update docs/api/app.md

Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>

* fixed isHidden tests

* Update docs/api/app.md

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>

* Update spec-main/api-app-spec.ts

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>

Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
* feat: add app.isHidden API

* Update docs/api/app.md

Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>

* fixed isHidden tests

* Update docs/api/app.md

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>

* Update spec-main/api-app-spec.ts

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>

Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review/requested 🗳 semver/minor backwards-compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants