[Shortcut Guide] Support delayed display of shortcuts except for taskbar shortcuts (#21762)

* Implement the delayed rendering

* Impelement settings UI

* Rename

* Set the minimum of ShortcutGuide_PressTimeForTaskbarIconShortcuts to 100ms

* Separate the animations of the global windows shortcuts and the taskbar icon shortcuts

* Amend

* Handle the case when the shortcut guide is not activated by win key long press

* Remove .vscode

* Keep the user's original setting of the win key press time

* Revert the default press time to 900 ms

* Restore default as 900
This commit is contained in:
Okami Wong
2022-11-18 22:22:40 +08:00
committed by GitHub
parent 6767ff736b
commit 89330986f4
11 changed files with 424 additions and 275 deletions

View File

@@ -171,7 +171,7 @@ public:
virtual UINT milliseconds_win_key_must_be_pressed() override
{
return m_millisecondsWinKeyShouldBePressed;
return std::min(m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts, m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts);
}
private:
@@ -185,9 +185,11 @@ private:
HotkeyEx m_hotkey;
// If the module should be activated through the legacy pressing windows key behavior.
const UINT DEFAULT_MILLISECONDS_WIN_KEY_SHOULD_BE_PRESSED = 900;
const UINT DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS = 900;
const UINT DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS = 900;
bool m_shouldReactToPressedWinKey = false;
UINT m_millisecondsWinKeyShouldBePressed = DEFAULT_MILLISECONDS_WIN_KEY_SHOULD_BE_PRESSED;
UINT m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS;
UINT m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS;
HANDLE exitEvent;
@@ -280,7 +282,8 @@ private:
void ParseSettings(PowerToysSettings::PowerToyValues& settings)
{
m_shouldReactToPressedWinKey = false;
m_millisecondsWinKeyShouldBePressed = DEFAULT_MILLISECONDS_WIN_KEY_SHOULD_BE_PRESSED;
m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS;
m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS;
auto settingsObject = settings.get_raw_json();
if (settingsObject.GetView().Size())
@@ -322,8 +325,10 @@ private:
// Parse Legacy windows key press behavior settings
auto jsonUseLegacyWinKeyBehaviorObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"use_legacy_press_win_key_behavior");
m_shouldReactToPressedWinKey = (bool)jsonUseLegacyWinKeyBehaviorObject.GetNamedBoolean(L"value");
auto jsonPressTimeObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"press_time");
m_millisecondsWinKeyShouldBePressed = (UINT)jsonPressTimeObject.GetNamedNumber(L"value");
auto jsonPressTimeForGlobalWindowsShortcutsObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"press_time");
auto jsonPressTimeForTaskbarIconShortcutsObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"press_time_for_taskbar_icon_shortcuts");
m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = (UINT)jsonPressTimeForGlobalWindowsShortcutsObject.GetNamedNumber(L"value");
m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = (UINT)jsonPressTimeForTaskbarIconShortcutsObject.GetNamedNumber(L"value");
}
catch (...)
{