Skip to content

Commit

Permalink
[Runner]remove hotkeyEx when disabling a module (#15944)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimecbernardo committed Feb 2, 2022
1 parent bed7f2a commit dbde5e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/runner/general_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,23 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
{
continue;
}
const bool module_inst_enabled = modules().at(name)->is_enabled();
PowertoyModule& powertoy = modules().at(name);
const bool module_inst_enabled = powertoy->is_enabled();
const bool target_enabled = value.GetBoolean();
if (module_inst_enabled == target_enabled)
{
continue;
}
if (target_enabled)
{
modules().at(name)->enable();
powertoy->enable();
}
else
{
modules().at(name)->disable();
powertoy->disable();
}
// Sync the hotkey state with the module state, so it can be removed for disabled modules.
powertoy.UpdateHotkeyEx();
}
}

Expand Down Expand Up @@ -221,6 +224,7 @@ void start_enabled_powertoys()
if (!powertoys_to_disable.contains(name))
{
powertoy->enable();
powertoy.UpdateHotkeyEx();
}
}
}
3 changes: 2 additions & 1 deletion src/runner/powertoy_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ void PowertoyModule::UpdateHotkeyEx()
{
CentralizedHotkeys::UnregisterHotkeysForModule(pt_module->get_key());
auto container = pt_module->GetHotkeyEx();
if (container.has_value())
if (container.has_value() && pt_module->is_enabled())
{
auto hotkey = container.value();
auto modulePtr = pt_module.get();
auto action = [modulePtr](WORD modifiersMask, WORD vkCode) {
Logger::trace(L"{} hotkey Ex is invoked from Centralized keyboard hook", modulePtr->get_key());
modulePtr->OnHotkeyEx();
};

Expand Down

0 comments on commit dbde5e3

Please sign in to comment.