Skip to content

Commit 6369748

Browse files
authored
feat: support suspend/resume on Windows (electron#24251)
1 parent abf2e9c commit 6369748

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docs/api/power-monitor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Process: [Main](../glossary.md#main-process)
88

99
The `powerMonitor` module emits the following events:
1010

11-
### Event: 'suspend'
11+
### Event: 'suspend' _Linux_ _Windows_
1212

1313
Emitted when the system is suspending.
1414

15-
### Event: 'resume'
15+
### Event: 'resume' _Linux_ _Windows_
1616

1717
Emitted when system is resuming.
1818

shell/browser/api/electron_api_power_monitor_win.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ LRESULT CALLBACK PowerMonitor::WndProc(HWND hwnd,
7373
Emit("unlock-screen");
7474
}
7575
}
76+
} else if (message == WM_POWERBROADCAST) {
77+
if (wparam == PBT_APMRESUMEAUTOMATIC) {
78+
Emit("resume");
79+
} else if (wparam == PBT_APMSUSPEND) {
80+
Emit("suspend");
81+
}
7682
}
7783
return ::DefWindowProc(hwnd, message, wparam, lparam);
7884
}

0 commit comments

Comments
 (0)