From 753fecbe9fa3fb3e9ffd4d089bfae20e799aa0a7 Mon Sep 17 00:00:00 2001 From: Yu Leng Date: Wed, 12 Nov 2025 23:18:14 +0800 Subject: [PATCH] Update PowerDisplay hotkey and add module launch support Updated `JSON_KEY_ACTIVATION_SHORTCUT` to use lowercase for consistency. Added `isShown` flag to `m_activation_hotkey` to indicate visibility, setting it in relevant scenarios. Added support for launching the PowerDisplay module via an IPC message in `LaunchPage.xaml.cs`. Improved robustness by adding a `default` case to handle unexpected `ModuleType` values in the switch statement. --- .../powerdisplay/PowerDisplayModuleInterface/dllmain.cpp | 5 ++++- .../Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml.cs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/powerdisplay/PowerDisplayModuleInterface/dllmain.cpp b/src/modules/powerdisplay/PowerDisplayModuleInterface/dllmain.cpp index 10397eaf8c..dd0c5e17fb 100644 --- a/src/modules/powerdisplay/PowerDisplayModuleInterface/dllmain.cpp +++ b/src/modules/powerdisplay/PowerDisplayModuleInterface/dllmain.cpp @@ -40,7 +40,7 @@ namespace const wchar_t JSON_KEY_PROPERTIES[] = L"properties"; const wchar_t JSON_KEY_ENABLED[] = L"enabled"; const wchar_t JSON_KEY_HOTKEY_ENABLED[] = L"hotkey_enabled"; - const wchar_t JSON_KEY_ACTIVATION_SHORTCUT[] = L"ActivationShortcut"; + const wchar_t JSON_KEY_ACTIVATION_SHORTCUT[] = L"activation_shortcut"; const wchar_t JSON_KEY_WIN[] = L"win"; const wchar_t JSON_KEY_ALT[] = L"alt"; const wchar_t JSON_KEY_CTRL[] = L"ctrl"; @@ -107,6 +107,7 @@ private: m_activation_hotkey.shift = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_SHIFT); m_activation_hotkey.ctrl = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_CTRL); m_activation_hotkey.key = static_cast(jsonHotkeyObject.GetNamedNumber(JSON_KEY_CODE)); + m_activation_hotkey.isShown = true; Logger::trace(L"Parsed activation hotkey: Win={} Ctrl={} Alt={} Shift={} Key={}", m_activation_hotkey.win, m_activation_hotkey.ctrl, m_activation_hotkey.alt, m_activation_hotkey.shift, m_activation_hotkey.key); @@ -114,12 +115,14 @@ private: else { Logger::info("ActivationShortcut not found in settings, using default Win+Alt+M"); + m_activation_hotkey.isShown = true; } } } catch (...) { Logger::error("Failed to parse PowerDisplay activation shortcut, using default Win+Alt+M"); + m_activation_hotkey.isShown = true; } } } diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml.cs index aad7dcf215..8305c31318 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/Flyout/LaunchPage.xaml.cs @@ -141,6 +141,10 @@ namespace Microsoft.PowerToys.Settings.UI.Flyout break; + case ModuleType.PowerDisplay: // Launch PowerDisplay + Views.ShellPage.SendDefaultIPCMessage("{\"action\":{\"PowerDisplay\":{\"action_name\":\"Launch\", \"value\":\"\"}}}"); + break; + default: moduleRun = false; break;