Skip to content
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

feat: support suspend/resume on Windows #24283

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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