[POWERCFG] Use the IS_PWR_* macros (#8386)

This commit is contained in:
Hermès Bélusca-Maïto
2025-09-07 22:03:08 +02:00
parent 103c81849f
commit 0f105936cb
3 changed files with 18 additions and 16 deletions

View File

@@ -135,9 +135,9 @@ GetPowerActionFromPolicy(
else else
{ {
poAction = Policy->Action; poAction = Policy->Action;
if ((poAction == PowerActionHibernate) && !(spc->SystemS4 && spc->HiberFilePresent)) if ((poAction == PowerActionHibernate) && !IS_PWR_HIBERNATE_ALLOWED(spc))
poAction = PowerActionSleep; poAction = PowerActionSleep;
if ((poAction == PowerActionSleep) && !(spc->SystemS1 || spc->SystemS2 || spc->SystemS3)) if ((poAction == PowerActionSleep) && !IS_PWR_SUSPEND_ALLOWED(spc))
{ {
if (bIsLid) if (bIsLid)
poAction = PowerActionNone; poAction = PowerActionNone;
@@ -282,7 +282,7 @@ Adv_InitDialog(
HWND hList2; HWND hList2;
HWND hList3; HWND hList3;
BOOLEAN bSuspend = FALSE; BOOLEAN bSuspend;
BOOLEAN bHibernate; BOOLEAN bHibernate;
BOOLEAN bShutdown; BOOLEAN bShutdown;
BOOL bEnabled; BOOL bEnabled;
@@ -308,11 +308,9 @@ Adv_InitDialog(
GetPwrCapabilities(&spc); GetPwrCapabilities(&spc);
if (spc.SystemS1 || spc.SystemS2 || spc.SystemS3) bSuspend = IS_PWR_SUSPEND_ALLOWED(&spc);
bSuspend=TRUE; bHibernate = IS_PWR_HIBERNATE_ALLOWED(&spc);
bShutdown = IS_PWR_POWEROFF_ALLOWED(&spc);
bHibernate = spc.HiberFilePresent;
bShutdown = spc.SystemS5;
hList1 = GetDlgItem(hwndDlg, IDC_LIDCLOSE); hList1 = GetDlgItem(hwndDlg, IDC_LIDCLOSE);
SendMessage(hList1, CB_RESETCONTENT, 0, 0); SendMessage(hList1, CB_RESETCONTENT, 0, 0);

View File

@@ -131,6 +131,8 @@ Applet1(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, AdvancedDlgProc); InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, AdvancedDlgProc);
if (spc.SystemS4) if (spc.SystemS4)
{ {
/* ACPI S4 state is supported, display the "Hibernate" page
* where we can enable or disable the hibernation file */
InitPropSheetPage(&psh, IDD_PROPPAGEHIBERNATE, HibernateDlgProc); InitPropSheetPage(&psh, IDD_PROPPAGEHIBERNATE, HibernateDlgProc);
} }

View File

@@ -208,25 +208,27 @@ Pos_InitData(
SYSTEM_POWER_CAPABILITIES spc; SYSTEM_POWER_CAPABILITIES spc;
if (!GetPwrCapabilities(&spc)) if (!GetPwrCapabilities(&spc))
{
return FALSE; return FALSE;
}
ShowWindow(GetDlgItem(hwndDlg, IDC_STANDBY), ShowWindow(GetDlgItem(hwndDlg, IDC_STANDBY),
(spc.SystemS1 || spc.SystemS2 || spc.SystemS3) ? SW_SHOW : SW_HIDE); IS_PWR_SUSPEND_ALLOWED(&spc) ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_STANDBYACLIST), ShowWindow(GetDlgItem(hwndDlg, IDC_STANDBYACLIST),
(spc.SystemS1 || spc.SystemS2 || spc.SystemS3) ? SW_SHOW : SW_HIDE); IS_PWR_SUSPEND_ALLOWED(&spc) ? SW_SHOW : SW_HIDE);
if (spc.SystemBatteriesPresent) if (spc.SystemBatteriesPresent)
{
ShowWindow(GetDlgItem(hwndDlg, IDC_STANDBYDCLIST), ShowWindow(GetDlgItem(hwndDlg, IDC_STANDBYDCLIST),
(spc.SystemS1 || spc.SystemS2 || spc.SystemS3) ? SW_SHOW : SW_HIDE); IS_PWR_SUSPEND_ALLOWED(&spc) ? SW_SHOW : SW_HIDE);
}
ShowWindow(GetDlgItem(hwndDlg, IDC_HIBERNATE), ShowWindow(GetDlgItem(hwndDlg, IDC_HIBERNATE),
(spc.HiberFilePresent) ? SW_SHOW : SW_HIDE); IS_PWR_HIBERNATE_ALLOWED(&spc) ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_HIBERNATEACLIST), ShowWindow(GetDlgItem(hwndDlg, IDC_HIBERNATEACLIST),
(spc.HiberFilePresent) ? SW_SHOW : SW_HIDE); IS_PWR_HIBERNATE_ALLOWED(&spc) ? SW_SHOW : SW_HIDE);
if (spc.SystemBatteriesPresent) if (spc.SystemBatteriesPresent)
{
ShowWindow(GetDlgItem(hwndDlg, IDC_HIBERNATEDCLIST), ShowWindow(GetDlgItem(hwndDlg, IDC_HIBERNATEDCLIST),
(spc.HiberFilePresent) ? SW_SHOW : SW_HIDE); IS_PWR_HIBERNATE_ALLOWED(&spc) ? SW_SHOW : SW_HIDE);
}
return TRUE; return TRUE;
} }