Skip to content

Commit

Permalink
feat: support suspend/resume on Windows (electron#24251)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored and sentialx committed Jul 11, 2020
1 parent 016c2b1 commit 37edfa7
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Process: [Main](../glossary.md#main-process)

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
Original file line number Diff line number Diff line change
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 37edfa7

Please sign in to comment.