MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / ProcessOurHotKey

Method ProcessOurHotKey

src/WorkerImplement.cpp:290–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290void WorkerImplement::ProcessOurHotKey(Message_Hotkey&& keyData) {
291
292 auto hk = keyData.hk;
293 const auto& key = keyData.hotkey;
294
295 if (keyData.delayed_from != 0 && keyData.delayed_from <= m_lastHotKeyTime) {
296 LOG_ANY("skip hotkey {} possible was double press", key.ToString());
297 return;
298 }
299 m_lastHotKeyTime = GetTickCount64();
300
301 GETCONF;
302
303 m_clear_alfter_selected = hk == hk_RevertSelelected;
304
305 if (IsNeedSavedWords(hk) && !m_cycleList.HasAnySymbol()) {
306 bool found = false;
307 for (const auto& [hk2, key2] : cfg->All_hot_keys()) {
308 if (!IsNeedSavedWords(hk2) && key.Compare(key2)) {
309 // Есть точно такой же хот-кей, не требующий сохраненных слов, используем его.
310 hk = hk2;
311 found = true;
312 break;
313 }
314 }
315 if (!found) {
316 LOG_ANY(L"skip hotkey {} because no saved word", (int)hk);
317 return;
318 }
319 }
320
321 if (key.GetKeyup()) {
322 // дадим событию up время на обработку в ОС, так как для нас, она уже поднята
323 // (т.е. мы ее не поднимаем и она может конфликтовать с тем, что мы собираемся ввести)
324 LOG_ANY(L"pause for #up key");
325 Sleep(5);
326 }
327
328 if (!IsNeedSavedWords(hk) && !Utils::is_in(hk, hk_EmulateCapsLock, hk_EmulateScrollLock)) {
329 ClearAllWords();
330 }
331
332 m_lastRevertRequest = hk;
333
334 LOG_ANY("Hotkey start {}({})", HotKeyTypeName(hk), (int)hk);
335
336 if (!g_enabled.IsEnabled() && hk != hk_ToggleEnabled) {
337 LOG_ANY("Skip hk because disabled");
338 return;
339 }
340
341 Fix_AltOrWin(keyData.cur_keys_down);
342
343 if (hk == hk_ToggleEnabled) {
344 try_toggle_enable();
345 return;
346 }
347

Callers 1

WorkerIntMethod · 0.80

Calls 15

IsNeedSavedWordsFunction · 0.85
is_inFunction · 0.85
HotKeyTypeNameFunction · 0.85
try_toggle_enableFunction · 0.85
show_main_windFunction · 0.85
TestFlagFunction · 0.85
ResetFlagFunction · 0.85
LOG_WARNFunction · 0.85
WorkerFunction · 0.85
HasAnySymbolMethod · 0.80
All_hot_keysMethod · 0.80
CompareMethod · 0.80

Tested by

no test coverage detected