From 5ed34607511bead8e810f5c6ec8432db00546f06 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 25 Aug 2020 05:09:36 +0900 Subject: [PATCH] fix: register for connected standby changes (#25076) --- shell/browser/api/electron_api_power_monitor_win.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shell/browser/api/electron_api_power_monitor_win.cc b/shell/browser/api/electron_api_power_monitor_win.cc index 97c1cca21683..27d85684cf99 100644 --- a/shell/browser/api/electron_api_power_monitor_win.cc +++ b/shell/browser/api/electron_api_power_monitor_win.cc @@ -8,6 +8,7 @@ #include #include "base/win/windows_types.h" +#include "base/win/windows_version.h" #include "base/win/wrapped_window_proc.h" #include "ui/base/win/shell.h" #include "ui/gfx/win/hwnd_util.h" @@ -40,6 +41,13 @@ void PowerMonitor::InitPlatformSpecificMonitors() { // Tel windows we want to be notified with session events WTSRegisterSessionNotification(window_, NOTIFY_FOR_THIS_SESSION); + + // For Windows 8 and later, a new "connected standy" mode has been added and + // we must explicitly register for its notifications. + if (base::win::GetVersion() >= base::win::Version::WIN8) { + RegisterSuspendResumeNotification(static_cast(window_), + DEVICE_NOTIFY_WINDOW_HANDLE); + } } LRESULT CALLBACK PowerMonitor::WndProcStatic(HWND hwnd,