mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 06:45:59 +01:00
allow repeating multiple binds
modified: src/managers/KeybindManager.cpp modified: src/managers/KeybindManager.hpp
This commit is contained in:
parent
d679d20029
commit
bbf17b515a
2 changed files with 16 additions and 14 deletions
|
@ -132,7 +132,7 @@ CKeybindManager::CKeybindManager() {
|
||||||
|
|
||||||
static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) {
|
static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) {
|
||||||
// clear cuz realloc'd
|
// clear cuz realloc'd
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybinds.clear();
|
||||||
m_vPressedSpecialBinds.clear();
|
m_vPressedSpecialBinds.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ CKeybindManager::~CKeybindManager() {
|
||||||
void CKeybindManager::addKeybind(SKeybind kb) {
|
void CKeybindManager::addKeybind(SKeybind kb) {
|
||||||
m_lKeybinds.push_back(kb);
|
m_lKeybinds.push_back(kb);
|
||||||
|
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybinds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::removeKeybind(uint32_t mod, const SParsedKey& key) {
|
void CKeybindManager::removeKeybind(uint32_t mod, const SParsedKey& key) {
|
||||||
|
@ -158,7 +158,7 @@ void CKeybindManager::removeKeybind(uint32_t mod, const SParsedKey& key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybinds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CKeybindManager::stringToModMask(std::string mods) {
|
uint32_t CKeybindManager::stringToModMask(std::string mods) {
|
||||||
|
@ -402,7 +402,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
|
||||||
if (m_pActiveKeybindEventSource) {
|
if (m_pActiveKeybindEventSource) {
|
||||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||||
m_pActiveKeybindEventSource = nullptr;
|
m_pActiveKeybindEventSource = nullptr;
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybinds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool suppressEvent = false;
|
bool suppressEvent = false;
|
||||||
|
@ -456,7 +456,7 @@ bool CKeybindManager::onAxisEvent(const IPointer::SAxisEvent& e) {
|
||||||
if (m_pActiveKeybindEventSource) {
|
if (m_pActiveKeybindEventSource) {
|
||||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||||
m_pActiveKeybindEventSource = nullptr;
|
m_pActiveKeybindEventSource = nullptr;
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybinds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@ -499,7 +499,7 @@ bool CKeybindManager::onMouseEvent(const IPointer::SButtonEvent& e) {
|
||||||
if (m_pActiveKeybindEventSource) {
|
if (m_pActiveKeybindEventSource) {
|
||||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||||
m_pActiveKeybindEventSource = nullptr;
|
m_pActiveKeybindEventSource = nullptr;
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybinds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||||
|
@ -552,15 +552,17 @@ void CKeybindManager::onSwitchOffEvent(const std::string& switchName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int repeatKeyHandler(void* data) {
|
int repeatKeyHandler(void* data) {
|
||||||
SKeybind** ppActiveKeybind = (SKeybind**)data;
|
std::vector<SKeybind*>* ppActiveKeybinds = (std::vector<SKeybind*>*)data;
|
||||||
|
|
||||||
if (!*ppActiveKeybind || g_pSeatManager->keyboard.expired())
|
if (ppActiveKeybinds->size() == 0 || g_pSeatManager->keyboard.expired())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find((*ppActiveKeybind)->handler);
|
for (SKeybind* k : *ppActiveKeybinds) {
|
||||||
|
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(k->handler);
|
||||||
|
|
||||||
Debug::log(LOG, "Keybind repeat triggered, calling dispatcher.");
|
Debug::log(LOG, "Keybind repeat triggered, calling dispatcher.");
|
||||||
DISPATCHER->second((*ppActiveKeybind)->arg);
|
DISPATCHER->second(k->arg);
|
||||||
|
}
|
||||||
|
|
||||||
wl_event_source_timer_update(g_pKeybindManager->m_pActiveKeybindEventSource, 1000 / g_pSeatManager->keyboard->repeatRate);
|
wl_event_source_timer_update(g_pKeybindManager->m_pActiveKeybindEventSource, 1000 / g_pSeatManager->keyboard->repeatRate);
|
||||||
|
|
||||||
|
@ -732,8 +734,8 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k.repeat) {
|
if (k.repeat) {
|
||||||
m_pActiveKeybind = &k;
|
m_pActiveKeybinds.push_back(&k);
|
||||||
m_pActiveKeybindEventSource = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, repeatKeyHandler, &m_pActiveKeybind);
|
m_pActiveKeybindEventSource = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, repeatKeyHandler, &m_pActiveKeybinds);
|
||||||
|
|
||||||
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
|
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ class CKeybindManager {
|
||||||
|
|
||||||
inline static std::string m_szCurrentSelectedSubmap = "";
|
inline static std::string m_szCurrentSelectedSubmap = "";
|
||||||
|
|
||||||
SKeybind* m_pActiveKeybind = nullptr;
|
std::vector<SKeybind*> m_pActiveKeybinds;
|
||||||
|
|
||||||
uint32_t m_uTimeLastMs = 0;
|
uint32_t m_uTimeLastMs = 0;
|
||||||
uint32_t m_uLastCode = 0;
|
uint32_t m_uLastCode = 0;
|
||||||
|
|
Loading…
Reference in a new issue