diff --git a/v3/pkg/application/application_windows.go b/v3/pkg/application/application_windows.go index e24c0d154..7253d7cbc 100644 --- a/v3/pkg/application/application_windows.go +++ b/v3/pkg/application/application_windows.go @@ -139,6 +139,20 @@ func (m *windowsApp) wndProc(hwnd w32.HWND, msg uint32, wParam, lParam uintptr) } } return 0 + case w32.WM_POWERBROADCAST: + switch wParam { + case w32.PBT_APMPOWERSTATUSCHANGE: + applicationEvents <- uint(events.Windows.APMPowerStatusChange) + case w32.PBT_APMSUSPEND: + applicationEvents <- uint(events.Windows.APMSuspend) + case w32.PBT_APMRESUMEAUTOMATIC: + applicationEvents <- uint(events.Windows.APMResumeAutomatic) + case w32.PBT_APMRESUMESUSPEND: + applicationEvents <- uint(events.Windows.APMResumeSuspend) + case w32.PBT_POWERSETTINGCHANGE: + applicationEvents <- uint(events.Windows.APMPowerSettingChange) + } + return 0 } if window, ok := m.windowMap[hwnd]; ok { diff --git a/v3/pkg/events/events.go b/v3/pkg/events/events.go index 23c0cf7b5..5e97f358c 100644 --- a/v3/pkg/events/events.go +++ b/v3/pkg/events/events.go @@ -264,11 +264,21 @@ func newMacEvents() macEvents { var Windows = newWindowsEvents() type windowsEvents struct { - SystemThemeChanged ApplicationEventType + SystemThemeChanged ApplicationEventType + APMPowerStatusChange ApplicationEventType + APMSuspend ApplicationEventType + APMResumeAutomatic ApplicationEventType + APMResumeSuspend ApplicationEventType + APMPowerSettingChange ApplicationEventType } func newWindowsEvents() windowsEvents { return windowsEvents{ - SystemThemeChanged: 1146, + SystemThemeChanged: 1146, + APMPowerStatusChange: 1147, + APMSuspend: 1148, + APMResumeAutomatic: 1149, + APMResumeSuspend: 1150, + APMPowerSettingChange: 1151, } } diff --git a/v3/pkg/events/events.txt b/v3/pkg/events/events.txt index ae0338627..e1ddfb262 100644 --- a/v3/pkg/events/events.txt +++ b/v3/pkg/events/events.txt @@ -120,4 +120,9 @@ mac:WebViewDidCommitNavigation mac:WindowFileDraggingEntered mac:WindowFileDraggingPerformed mac:WindowFileDraggingExited -windows:SystemThemeChanged \ No newline at end of file +windows:SystemThemeChanged +windows:APMPowerStatusChange +windows:APMSuspend +windows:APMResumeAutomatic +windows:APMResumeSuspend +windows:APMPowerSettingChange