feat: support suspend/resume on Windows (#24282)

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2020-06-29 09:07:21 -07:00
committed by GitHub
parent f70161856c
commit 6d3e56d70f
2 changed files with 8 additions and 2 deletions

View File

@@ -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.

View File

@@ -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);
}