mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: support suspend/resume on Windows (#24282)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -24,11 +24,11 @@ app.on('ready', () => {
|
||||
|
||||
The `powerMonitor` module emits the following events:
|
||||
|
||||
### Event: 'suspend'
|
||||
### Event: 'suspend' _Linux_ _Windows_
|
||||
|
||||
Emitted when the system is suspending.
|
||||
|
||||
### Event: 'resume'
|
||||
### Event: 'resume' _Linux_ _Windows_
|
||||
|
||||
Emitted when system is resuming.
|
||||
|
||||
|
||||
@@ -63,6 +63,12 @@ LRESULT CALLBACK PowerMonitor::WndProc(HWND hwnd,
|
||||
} else if (wparam == WTS_SESSION_UNLOCK) {
|
||||
Emit("unlock-screen");
|
||||
}
|
||||
} else if (message == WM_POWERBROADCAST) {
|
||||
if (wparam == PBT_APMRESUMEAUTOMATIC) {
|
||||
Emit("resume");
|
||||
} else if (wparam == PBT_APMSUSPEND) {
|
||||
Emit("suspend");
|
||||
}
|
||||
}
|
||||
return ::DefWindowProc(hwnd, message, wparam, lparam);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user