Skip to content

Commit

Permalink
feat: support suspend/resume on Windows (#24283)
Browse files Browse the repository at this point in the history
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Jun 29, 2020
1 parent c1842ab commit 7607227
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/api/power-monitor.md
Expand Up @@ -24,11 +24,11 @@ app.whenReady().then(() => {

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.

Expand Down
6 changes: 6 additions & 0 deletions shell/browser/api/electron_api_power_monitor_win.cc
Expand Up @@ -73,6 +73,12 @@ LRESULT CALLBACK PowerMonitor::WndProc(HWND hwnd,
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);
}
Expand Down

0 comments on commit 7607227

Please sign in to comment.