5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-06 16:49:12 +08:00

[v3 windows] Add APM Events

This commit is contained in:
Lea Anthony 2023-04-29 20:33:33 +10:00 committed by Misite Bao
parent f08ae2fc62
commit 402b743553
3 changed files with 32 additions and 3 deletions

View File

@ -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 {

View File

@ -265,10 +265,20 @@ var Windows = newWindowsEvents()
type windowsEvents struct {
SystemThemeChanged ApplicationEventType
APMPowerStatusChange ApplicationEventType
APMSuspend ApplicationEventType
APMResumeAutomatic ApplicationEventType
APMResumeSuspend ApplicationEventType
APMPowerSettingChange ApplicationEventType
}
func newWindowsEvents() windowsEvents {
return windowsEvents{
SystemThemeChanged: 1146,
APMPowerStatusChange: 1147,
APMSuspend: 1148,
APMResumeAutomatic: 1149,
APMResumeSuspend: 1150,
APMPowerSettingChange: 1151,
}
}

View File

@ -121,3 +121,8 @@ mac:WindowFileDraggingEntered
mac:WindowFileDraggingPerformed
mac:WindowFileDraggingExited
windows:SystemThemeChanged
windows:APMPowerStatusChange
windows:APMSuspend
windows:APMResumeAutomatic
windows:APMResumeSuspend
windows:APMPowerSettingChange