From ed44db25e38f52803357e1135a932d4011a50faf Mon Sep 17 00:00:00 2001 From: Seraphima Zykova Date: Tue, 18 Jul 2023 12:54:43 +0200 Subject: [PATCH] [FancyZones]"Switch between windows in the current zone" works after disabling fix (#27416) * update hotkeys on setting change * next tab hotkey --- .../fancyzones/FancyZonesLib/FancyZones.cpp | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp index 820a53ef54..84e0d373b4 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp @@ -64,7 +64,7 @@ struct FancyZones : public winrt::implements disableModuleCallbackFunction) noexcept : - SettingsObserver({ SettingId::EditorHotkey, SettingId::PrevTabHotkey, SettingId::NextTabHotkey, SettingId::SpanZonesAcrossMonitors }), + SettingsObserver({ SettingId::EditorHotkey, SettingId::WindowSwitching, SettingId::PrevTabHotkey, SettingId::NextTabHotkey, SettingId::SpanZonesAcrossMonitors }), m_hinstance(hinstance), m_draggingState([this]() { PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL); @@ -218,23 +218,9 @@ FancyZones::Run() noexcept return; } - if (!RegisterHotKey(m_window, static_cast(HotkeyId::Editor), FancyZonesSettings::settings().editorHotkey.get_modifiers(), FancyZonesSettings::settings().editorHotkey.get_code())) - { - Logger::error(L"Failed to register hotkey: {}", get_last_error_or_default(GetLastError())); - } - - if (FancyZonesSettings::settings().windowSwitching) - { - if (!RegisterHotKey(m_window, static_cast(HotkeyId::NextTab), FancyZonesSettings::settings().nextTabHotkey.get_modifiers(), FancyZonesSettings::settings().nextTabHotkey.get_code())) - { - Logger::error(L"Failed to register hotkey: {}", get_last_error_or_default(GetLastError())); - } - - if (!RegisterHotKey(m_window, static_cast(HotkeyId::PrevTab), FancyZonesSettings::settings().prevTabHotkey.get_modifiers(), FancyZonesSettings::settings().prevTabHotkey.get_code())) - { - Logger::error(L"Failed to register hotkey: {}", get_last_error_or_default(GetLastError())); - } - } + UpdateHotkey(static_cast(HotkeyId::Editor), FancyZonesSettings::settings().editorHotkey, true); + UpdateHotkey(static_cast(HotkeyId::PrevTab), FancyZonesSettings::settings().prevTabHotkey, FancyZonesSettings::settings().windowSwitching); + UpdateHotkey(static_cast(HotkeyId::NextTab), FancyZonesSettings::settings().nextTabHotkey, FancyZonesSettings::settings().windowSwitching); // Initialize COM. Needed for WMI monitor identifying HRESULT comInitHres = CoInitializeEx(0, COINIT_MULTITHREADED); @@ -1172,6 +1158,12 @@ void FancyZones::SettingsUpdate(SettingId id) UpdateHotkey(static_cast(HotkeyId::Editor), FancyZonesSettings::settings().editorHotkey, true); } break; + case SettingId::WindowSwitching: + { + UpdateHotkey(static_cast(HotkeyId::PrevTab), FancyZonesSettings::settings().prevTabHotkey, FancyZonesSettings::settings().windowSwitching); + UpdateHotkey(static_cast(HotkeyId::NextTab), FancyZonesSettings::settings().nextTabHotkey, FancyZonesSettings::settings().windowSwitching); + } + break; case SettingId::PrevTabHotkey: { UpdateHotkey(static_cast(HotkeyId::PrevTab), FancyZonesSettings::settings().prevTabHotkey, FancyZonesSettings::settings().windowSwitching);