-
Notifications
You must be signed in to change notification settings - Fork 15.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: make window.flashFrame(bool) flash continuously on macOS #41391
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
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.
Interested in other thoughts on this but although I understand the goal for alignment I don't think that will be reached and this change feels more break-y than align-y. The docs don't explicitly state that it continues infinitely until stopped although I guess you could claim it's implied.
I'm interested in the behavior on linux as that would help guide whether this change is more acceptable to me 🤔
@MarshallOfSound yes based on the docs (specifically the code example) and the semantics around how they are called it sure appears that there is a call with true to start and a call with false to stop. So if that is not the case, then I suppose those should be updated. But even then the bool argument is odd and still part of the public API. I do not have a linux or windows environment to test with, but I dug in and I think I found the windows and linux implementation: electron/shell/browser/native_window_views.cc Lines 1089 to 1103 in 267c079
I think the linux case (and windows case partially) delegates to the chromium ostensibly with I found another X11 FlashFrame implementation https://chromium.googlesource.com/chromium/src/+/ae9485d020b2834ecb0a0439c76914d3386af405/ui/platform_window/x11/x11_window.cc#448 which seems to set X11's WMHints urgency flag. I found this https://tronche.com/gui/x/xlib/ICC/client-to-window-manager/wm-hints.html which states:
Digging further I also found this comment element-hq/element-desktop#715 (comment) unclear if that is correct. |
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.
This is kind of a breaking change, but I think the behavior parity worths it, and if an app is affected they can easily switch to use the dock.bounce
API.
/cc @electron/wg-api
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.
API LGTM
I think this is a good change as long as we document it in breaking-changes.md
@erickzhao do you want me to update breaking-changes.md? I could, but I don't know if the maintainers do that. If so, what section would I put it in? 30? 29, since this was tagged with semver-minor? Any specific verbiage you are looking for? |
Hey @yuzawa-san, this is labeled as a |
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.
API LGTM
Let's mark this as a breaking change though in the doc, no backport
@yuzawa-san can you add an entry under Planned Breaking API Changes (31.0) |
This brings the behavior to parity with Windows and Linux. Prior behavior: The first `flashFrame(true)` bounces the dock icon only once (using the [NSInformationalRequest](https://developer.apple.com/documentation/appkit/nsrequestuserattentiontype/nsinformationalrequest) level) and `flashFrame(false)` does nothing. New behavior: Flash continuously until `flashFrame(false)` is called. This uses the [NSCriticalRequest](https://developer.apple.com/documentation/appkit/nsrequestuserattentiontype/nscriticalrequest) level instead. To explicitly use `NSInformationalRequest` to cause a single dock icon bounce, it is still possible to use [`dock.bounce('informational')`](https://www.electronjs.org/docs/latest/api/dock#dockbouncetype-macos).
de714b0
to
2c30509
Compare
@jkleinsc @MarshallOfSound I have updated the breaking changes document. |
Merging as CI failure unrelated to PR change. |
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
Description of Change
I was developing a cross-platform (Windows, macOS) application and found that the Windows behavior was consistent with the semantics of
flashFrame(bool)
. i.e. the first callflashFrame(true)
will start and it will continue until you callflashFrame(false)
. However, the macOS implementation is not at parity with this. The firstflashFrame(true)
call will indeed flash, but only once (given the NSInformationalRequest level). The solution to have it flash continuously until you stop it would be to change it to NSCriticalRequest). If somebody did want to explicitly use NSInformationalRequest they can still usedock.bounce('informational')
. The main objective here is to bring the macOS into parity with the Windows, so that a developer would need to only call flashFrame in a platform independent manner. Currently, I was doing:I did not find any unit tests for this piece of code and I do not know how to assert on the userAttentionRequest given ther underlying API does not expose a way to read the state.
If you feel any docs need updating let me know and I can update them.
Checklist
npm test
passesRelease Notes
Notes: made window.flashFrame(bool) flash continuously on macOS