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

View File

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