diff --git a/src/modules/fancyzones/dll/dllmain.cpp b/src/modules/fancyzones/dll/dllmain.cpp index 1358c5ed1c..d2889ad1a3 100644 --- a/src/modules/fancyzones/dll/dllmain.cpp +++ b/src/modules/fancyzones/dll/dllmain.cpp @@ -144,6 +144,7 @@ private: } m_app->Destroy(); m_app = nullptr; + m_settings->ResetCallback(); } } diff --git a/src/modules/fancyzones/lib/Settings.cpp b/src/modules/fancyzones/lib/Settings.cpp index f1bd179fa8..e7a8cb8691 100644 --- a/src/modules/fancyzones/lib/Settings.cpp +++ b/src/modules/fancyzones/lib/Settings.cpp @@ -15,6 +15,7 @@ public: } IFACEMETHODIMP_(void) SetCallback(IFancyZonesCallback* callback) { m_callback = callback; } + IFACEMETHODIMP_(void) ResetCallback() { m_callback = nullptr; } IFACEMETHODIMP_(bool) GetConfig(_Out_ PWSTR buffer, _Out_ int *buffer_sizeg) noexcept; IFACEMETHODIMP_(void) SetConfig(PCWSTR config) noexcept; IFACEMETHODIMP_(void) CallCustomAction(PCWSTR action) noexcept; diff --git a/src/modules/fancyzones/lib/Settings.h b/src/modules/fancyzones/lib/Settings.h index f57f541559..d004e5713f 100644 --- a/src/modules/fancyzones/lib/Settings.h +++ b/src/modules/fancyzones/lib/Settings.h @@ -24,6 +24,7 @@ struct Settings interface __declspec(uuid("{BA4E77C4-6F44-4C5D-93D3-CBDE880495C2}")) IFancyZonesSettings : public IUnknown { IFACEMETHOD_(void, SetCallback)(interface IFancyZonesCallback* callback) = 0; + IFACEMETHOD_(void, ResetCallback)() = 0; IFACEMETHOD_(bool, GetConfig)(_Out_ PWSTR buffer, _Out_ int *buffer_size) = 0; IFACEMETHOD_(void, SetConfig)(PCWSTR serializedPowerToysSettingsJson) = 0; IFACEMETHOD_(void, CallCustomAction)(PCWSTR action) = 0; diff --git a/src/modules/shortcut_guide/shortcut_guide.cpp b/src/modules/shortcut_guide/shortcut_guide.cpp index 7936aca899..0c70a7e5ae 100644 --- a/src/modules/shortcut_guide/shortcut_guide.cpp +++ b/src/modules/shortcut_guide/shortcut_guide.cpp @@ -66,31 +66,40 @@ void OverlayWindow::set_config(const wchar_t* config) { try { + // save configuration PowerToysSettings::PowerToyValues _values = PowerToysSettings::PowerToyValues::from_json_string(config); - if (const auto press_delay_time = _values.get_int_value(pressTime.name)) - { - pressTime.value = *press_delay_time; - if (target_state) - { - target_state->set_delay(*press_delay_time); - } - } - if (const auto overlay_opacity = _values.get_int_value(overlayOpacity.name)) - { - overlayOpacity.value = *overlay_opacity; - if (winkey_popup) - { - winkey_popup->apply_overlay_opacity(((float)overlayOpacity.value) / 100.0f); - } - } - if (auto val = _values.get_string_value(theme.name)) - { - theme.value = std::move(*val); - winkey_popup->set_theme(theme.value); - } _values.save_to_settings_file(); Trace::SettingsChanged(pressTime.value, overlayOpacity.value, theme.value); + + // apply new settings if powertoy is enabled + if (_enabled) + { + if (const auto press_delay_time = _values.get_int_value(pressTime.name)) + { + pressTime.value = *press_delay_time; + if (target_state) + { + target_state->set_delay(*press_delay_time); + } + } + if (const auto overlay_opacity = _values.get_int_value(overlayOpacity.name)) + { + overlayOpacity.value = *overlay_opacity; + if (winkey_popup) + { + winkey_popup->apply_overlay_opacity(((float)overlayOpacity.value) / 100.0f); + } + } + if (auto val = _values.get_string_value(theme.name)) + { + theme.value = std::move(*val); + if (winkey_popup) + { + winkey_popup->set_theme(theme.value); + } + } + } } catch (...) {