From 5fd7755b8d499533ef14fe557d81c61c5ac3d92f Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 7 Nov 2024 13:34:14 +0800 Subject: [PATCH] clang format --- src/config/ConfigManager.cpp | 6 ++-- src/debug/HyprCtl.cpp | 6 ++-- src/managers/KeybindManager.cpp | 56 ++++++++++++++++----------------- src/managers/KeybindManager.hpp | 2 +- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 2f1fd42c..3b05275b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -2265,9 +2265,9 @@ std::optional CConfigManager::handleBind(const std::string& command return "Invalid catchall, catchall keybinds are only allowed in submaps."; } - g_pKeybindManager->addKeybind(SKeybind{ - parsedKey.key, KEYSYMS, parsedKey.keycode, parsedKey.catchAll, MOD, MODS, HANDLER, COMMAND, locked, m_szCurrentSubmap, DESCRIPTION, release, - repeat, longPress, mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit}); + g_pKeybindManager->addKeybind(SKeybind{parsedKey.key, KEYSYMS, parsedKey.keycode, parsedKey.catchAll, MOD, MODS, HANDLER, + COMMAND, locked, m_szCurrentSubmap, DESCRIPTION, release, repeat, longPress, + mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit}); } return {}; diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 29438dc8..ee16e9ca 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -852,9 +852,9 @@ std::string bindsRequest(eHyprCtlOutputFormat format, std::string request) { "dispatcher": "{}", "arg": "{}" }},)#", - kb.locked ? "true" : "false", kb.mouse ? "true" : "false", kb.release ? "true" : "false", kb.repeat ? "true" : "false", kb.longPress ? "true" : "false", kb.nonConsuming ? "true" : "false", - kb.hasDescription ? "true" : "false", kb.modmask, escapeJSONStrings(kb.submap), escapeJSONStrings(kb.key), kb.keycode, kb.catchAll ? "true" : "false", - escapeJSONStrings(kb.description), escapeJSONStrings(kb.handler), escapeJSONStrings(kb.arg)); + kb.locked ? "true" : "false", kb.mouse ? "true" : "false", kb.release ? "true" : "false", kb.repeat ? "true" : "false", kb.longPress ? "true" : "false", + kb.nonConsuming ? "true" : "false", kb.hasDescription ? "true" : "false", kb.modmask, escapeJSONStrings(kb.submap), escapeJSONStrings(kb.key), kb.keycode, + kb.catchAll ? "true" : "false", escapeJSONStrings(kb.description), escapeJSONStrings(kb.handler), escapeJSONStrings(kb.arg)); } trimTrailingComma(ret); ret += "]"; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 22be31b2..01246b25 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -131,26 +131,25 @@ CKeybindManager::CKeybindManager() { m_tScrollTimer.reset(); - m_pLongPressTimer = makeShared( - std::nullopt, - [this](SP self, void* data) { - SKeybind** ppActiveKeybind = (SKeybind**)m_pActiveKeybind; + m_pLongPressTimer = makeShared( + std::nullopt, + [this](SP self, void* data) { + SKeybind** ppActiveKeybind = (SKeybind**)m_pActiveKeybind; - if (!m_pActiveKeybind) - return 0; + if (!m_pActiveKeybind) + return 0; - // if (!*ppActiveKeybind || g_pSeatManager->keyboard.expired()) - // return 0; + // if (!*ppActiveKeybind || g_pSeatManager->keyboard.expired()) + // return 0; - // const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find((*ppActiveKeybind)->handler); + // const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find((*ppActiveKeybind)->handler); - // Debug::log(LOG, "Keybind long press triggered, calling dispatcher."); - // DISPATCHER->second((*ppActiveKeybind)->arg); - }, - nullptr - ); + // Debug::log(LOG, "Keybind long press triggered, calling dispatcher."); + // DISPATCHER->second((*ppActiveKeybind)->arg); + }, + nullptr); - g_pEventLoopManager->addTimer(m_pLongPressTimer); + g_pEventLoopManager->addTimer(m_pLongPressTimer); static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) { // clear cuz realloc'd @@ -162,10 +161,10 @@ CKeybindManager::CKeybindManager() { CKeybindManager::~CKeybindManager() { if (m_pXKBTranslationState) xkb_state_unref(m_pXKBTranslationState); - if (m_pLongPressTimer && g_pEventLoopManager) { - g_pEventLoopManager->removeTimer(m_pLongPressTimer); - m_pLongPressTimer.reset(); - } + if (m_pLongPressTimer && g_pEventLoopManager) { + g_pEventLoopManager->removeTimer(m_pLongPressTimer); + m_pLongPressTimer.reset(); + } } void CKeybindManager::addKeybind(SKeybind kb) { @@ -594,7 +593,6 @@ int repeatKeyHandler(void* data) { } int longPressHandler(SP self, void* data) { - return 0; } @@ -713,16 +711,16 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP continue; } - if (k.longPress) { - m_pActiveKeybind = &k; - - const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock(); + if (k.longPress) { + m_pActiveKeybind = &k; - m_pLongPressTimer->updateTimeout(std::chrono::milliseconds(PACTIVEKEEB->repeatDelay)); - // m_pLastLongPressKeybind = &k; + const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock(); - // continue; - } + m_pLongPressTimer->updateTimeout(std::chrono::milliseconds(PACTIVEKEEB->repeatDelay)); + // m_pLastLongPressKeybind = &k; + + // continue; + } if (!pressed) { // Require mods to be matching when the key was first pressed. @@ -771,7 +769,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP found = true; // don't process keybinds on submap change. break; } - } + } if (k.repeat) { m_pActiveKeybind = &k; diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 2c788590..fcd5d572 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -122,7 +122,7 @@ class CKeybindManager { inline static std::string m_szCurrentSelectedSubmap = ""; SKeybind* m_pActiveKeybind = nullptr; - SP m_pLongPressTimer; + SP m_pLongPressTimer; uint32_t m_uTimeLastMs = 0; uint32_t m_uLastCode = 0;