feat: add query-session-end and improve session-end events on Windows (#44598)
* feat: add query-session-end event for Windows * fix: remove debug line * feat: notify with reason on session-end * docs: add comments and return params * docs: add same docs to the BrowserWindow * fix: add shutdown reason if lParam == 0 * docs: remove 'force' word * docs: revert multithreading.md change * docs: add reasons documentation, reason variable renamed to reasons * docs: improve 'shutdown' reason wording * docs: reword with 'can be' * fix: pass reasons by reference * fix: use newer approach which expose reasons value directly on Event object * docs: add escaping * style: linter fixes * fix: project now should compile * fix: EmitWithoutEvent method added, EmitWithEvent moved to private again * docs: typo fix Co-authored-by: Sam Maddock <samuel.maddock@gmail.com> * docs: dedicated WindowSessionEndEvent type created * docs: better wording for session-end event description Co-authored-by: Will Anderson <will@itsananderson.com> --------- Co-authored-by: Sam Maddock <samuel.maddock@gmail.com> Co-authored-by: Will Anderson <will@itsananderson.com>
This commit is contained in:
parent
0285592d61
commit
c5ea177b3d
11 changed files with 135 additions and 12 deletions
|
@ -144,10 +144,24 @@ _**Note**: There is a subtle difference between the behaviors of `window.onbefor
|
|||
Emitted when the window is closed. After you have received this event you should
|
||||
remove the reference to the window and avoid using it any more.
|
||||
|
||||
#### Event: 'query-session-end' _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` [WindowSessionEndEvent][window-session-end-event]
|
||||
|
||||
Emitted when a session is about to end due to a shutdown, machine restart, or user log-off.
|
||||
Calling `event.preventDefault()` can delay the system shutdown, though it’s generally best
|
||||
to respect the user’s choice to end the session. However, you may choose to use it if
|
||||
ending the session puts the user at risk of losing data.
|
||||
|
||||
#### Event: 'session-end' _Windows_
|
||||
|
||||
Emitted when window session is going to end due to force shutdown or machine restart
|
||||
or session log off.
|
||||
Returns:
|
||||
|
||||
* `event` [WindowSessionEndEvent][window-session-end-event]
|
||||
|
||||
Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Once this event fires, there is no way to prevent the session from ending.
|
||||
|
||||
#### Event: 'blur'
|
||||
|
||||
|
@ -1429,3 +1443,4 @@ On Linux, the `symbolColor` is automatically calculated to have minimum accessib
|
|||
[vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc
|
||||
[window-levels]: https://developer.apple.com/documentation/appkit/nswindow/level
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
[window-session-end-event]:../api/structures/window-session-end-event.md
|
||||
|
|
|
@ -207,10 +207,24 @@ _**Note**: There is a subtle difference between the behaviors of `window.onbefor
|
|||
Emitted when the window is closed. After you have received this event you should
|
||||
remove the reference to the window and avoid using it any more.
|
||||
|
||||
#### Event: 'query-session-end' _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` [WindowSessionEndEvent][window-session-end-event]
|
||||
|
||||
Emitted when a session is about to end due to a shutdown, machine restart, or user log-off.
|
||||
Calling `event.preventDefault()` can delay the system shutdown, though it’s generally best
|
||||
to respect the user’s choice to end the session. However, you may choose to use it if
|
||||
ending the session puts the user at risk of losing data.
|
||||
|
||||
#### Event: 'session-end' _Windows_
|
||||
|
||||
Emitted when window session is going to end due to force shutdown or machine restart
|
||||
or session log off.
|
||||
Returns:
|
||||
|
||||
* `event` [WindowSessionEndEvent][window-session-end-event]
|
||||
|
||||
Emitted when a session is about to end due to a shutdown, machine restart, or user log-off. Once this event fires, there is no way to prevent the session from ending.
|
||||
|
||||
#### Event: 'unresponsive'
|
||||
|
||||
|
@ -1672,3 +1686,4 @@ On Linux, the `symbolColor` is automatically calculated to have minimum accessib
|
|||
[vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc
|
||||
[window-levels]: https://developer.apple.com/documentation/appkit/nswindow/level
|
||||
[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter
|
||||
[window-session-end-event]:../api/structures/window-session-end-event.md
|
||||
|
|
7
docs/api/structures/window-session-end-event.md
Normal file
7
docs/api/structures/window-session-end-event.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# WindowSessionEndEvent Object extends `Event`
|
||||
|
||||
* `reasons` string[] - List of reasons for shutdown. Can be 'shutdown', 'close-app', 'critical', or 'logoff'.
|
||||
|
||||
Unfortunately, Windows does not offer a way to differentiate between a shutdown and a reboot, meaning the 'shutdown'
|
||||
reason is triggered in both scenarios. For more details on the `WM_ENDSESSION` message and its associated reasons,
|
||||
refer to the [MSDN documentation](https://learn.microsoft.com/en-us/windows/win32/shutdown/wm-endsession).
|
Loading…
Add table
Add a link
Reference in a new issue