Skip to content

Commit 8f0add9

Browse files
authored
Merge 515f256 into 935c6fc
2 parents 935c6fc + 515f256 commit 8f0add9

File tree

1 file changed

+56
-19
lines changed

1 file changed

+56
-19
lines changed

Src/StartMenu/StartMenuDLL/MenuContainer.cpp

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7709,29 +7709,63 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
77097709

77107710
s_bHasUpdates=(!bRemote || GetSettingBool(L"RemoteShutdown")) && GetSettingBool(L"CheckWinUpdates") && CheckForUpdates();
77117711

7712-
SYSTEM_POWER_CAPABILITIES powerCaps;
7713-
GetPwrCapabilities(&powerCaps);
77147712

7715-
bool bHibernate=false;
7716-
if (powerCaps.HiberFilePresent)
7713+
s_bHasUpdates = (!bRemote || GetSettingBool(L"RemoteShutdown")) && GetSettingBool(L"CheckWinUpdates") && CheckForUpdates();
7714+
7715+
// Check control panel options for power buttons
7716+
bool bHibernate = true, bSleep = true, bLock = true;
77177717
{
7718-
bHibernate=true;
7719-
/* disabled for now, use group policy to hide Hibernate
7720-
// disable hibernate if hybrid sleep (fast s4) is enabled
7721-
SYSTEM_POWER_STATUS status;
7722-
if (GetSystemPowerStatus(&status) && (status.ACLineStatus==0 || status.ACLineStatus==1))
7718+
CRegKey regKeyButtons;
7719+
if (regKeyButtons.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FlyoutMenuSettings", KEY_READ) == ERROR_SUCCESS)
77237720
{
7724-
GUID *pScheme;
7725-
if (PowerGetActiveScheme(NULL,&pScheme)==ERROR_SUCCESS)
7726-
{
7727-
DWORD index;
7728-
if ((status.ACLineStatus==1?PowerReadACValueIndex:PowerReadDCValueIndex)(NULL,pScheme,&GUID_SLEEP_SUBGROUP,&GUID_HIBERNATE_FASTS4_POLICY,&index)==ERROR_SUCCESS && index)
7729-
bHibernate=false;
7730-
LocalFree(pScheme);
7731-
}
7732-
}*/
7721+
DWORD dwValue = 1;
7722+
if (regKeyButtons.QueryDWORDValue(L"ShowHibernateOption", dwValue) == ERROR_SUCCESS)
7723+
if (dwValue == 0)
7724+
bHibernate = false;
7725+
7726+
if (regKeyButtons.QueryDWORDValue(L"ShowLockOption", dwValue) == ERROR_SUCCESS)
7727+
if (dwValue == 0)
7728+
bLock = false;
7729+
7730+
if (regKeyButtons.QueryDWORDValue(L"ShowSleepOption", dwValue) == ERROR_SUCCESS)
7731+
if (dwValue == 0)
7732+
bSleep = false;
7733+
}
7734+
}
7735+
7736+
if (bHibernate || bSleep)
7737+
{
7738+
SYSTEM_POWER_CAPABILITIES powerCaps;
7739+
GetPwrCapabilities(&powerCaps);
7740+
7741+
// no sleep capabilities, turn off the sleep option
7742+
if (!powerCaps.SystemS1 && !powerCaps.SystemS2 && !powerCaps.SystemS3 && !powerCaps.AoAc)
7743+
{
7744+
bSleep = false;
7745+
}
7746+
7747+
// no hibernate capabilities, turn off hibernate option
7748+
if (!powerCaps.HiberFilePresent)
7749+
{
7750+
bHibernate = false;
7751+
/* disabled for now, use group policy to hide Hibernate
7752+
// disable hibernate if hybrid sleep (fast s4) is enabled
7753+
SYSTEM_POWER_STATUS status;
7754+
if (GetSystemPowerStatus(&status) && (status.ACLineStatus==0 || status.ACLineStatus==1))
7755+
{
7756+
GUID *pScheme;
7757+
if (PowerGetActiveScheme(NULL,&pScheme)==ERROR_SUCCESS)
7758+
{
7759+
DWORD index;
7760+
if ((status.ACLineStatus==1?PowerReadACValueIndex:PowerReadDCValueIndex)(NULL,pScheme,&GUID_SLEEP_SUBGROUP,&GUID_HIBERNATE_FASTS4_POLICY,&index)==ERROR_SUCCESS && index)
7761+
bHibernate=false;
7762+
LocalFree(pScheme);
7763+
}
7764+
}*/
7765+
}
77337766
}
77347767

7768+
77357769
for (int i=0;i<_countof(g_StdOptions);i++)
77367770
{
77377771
switch (g_StdOptions[i].id)
@@ -7939,8 +7973,11 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
79397973
g_StdOptions[i].options=MENU_ENABLED|MENU_EXPANDED;
79407974
}
79417975
break;
7976+
case MENU_LOCK:
7977+
g_StdOptions[i].options = bLock ? MENU_ENABLED | MENU_EXPANDED:0;
7978+
break;
79427979
case MENU_SLEEP:
7943-
g_StdOptions[i].options=(!s_bNoClose && (powerCaps.SystemS1 || powerCaps.SystemS2 || powerCaps.SystemS3 || powerCaps.AoAc))?MENU_ENABLED|MENU_EXPANDED:0;
7980+
g_StdOptions[i].options=(!s_bNoClose && bSleep)?MENU_ENABLED|MENU_EXPANDED:0;
79447981
break;
79457982
case MENU_HIBERNATE:
79467983
g_StdOptions[i].options=(!s_bNoClose && bHibernate)?MENU_ENABLED|MENU_EXPANDED:0;

0 commit comments

Comments
 (0)