diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-01 16:41:17 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-05-01 16:41:17 +0100 |
| commit | 8bcccf9f0f0f69986e315d4288dfdbf119dd19db (patch) | |
| tree | eebb6714fc1e41a0df2784ed22752f0efe2bbdc1 /src/managers/input/InputManager.cpp | |
| parent | 4ed6b69b68a544a81cec583a1ad8aff218f7db5d (diff) | |
ime-v2: move to new impl
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index ca1597b1..7d14719f 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -10,6 +10,7 @@ #include "../../protocols/PointerConstraints.hpp" #include "../../protocols/IdleNotify.hpp" #include "../../protocols/SessionLock.hpp" +#include "../../protocols/InputMethodV2.hpp" CInputManager::CInputManager() { m_sListeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) { @@ -1207,6 +1208,8 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar if (!pKeyboard->enabled) return; + const bool DISALLOWACTION = pKeyboard->isVirtual && shouldIgnoreVirtualKeyboard(pKeyboard); + const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", e}}; EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP); @@ -1216,17 +1219,16 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar g_pKeybindManager->dpms("on"); } - bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); + bool passEvent = DISALLOWACTION || g_pKeybindManager->onKeyEvent(e, pKeyboard); PROTO::idle->onActivity(); if (passEvent) { + const auto IME = m_sIMERelay.m_pIME.lock(); - const auto PIMEGRAB = m_sIMERelay.getIMEKeyboardGrab(pKeyboard); - - if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) { - wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard)); - wlr_input_method_keyboard_grab_v2_send_key(PIMEGRAB->pWlrKbGrab, e->time_msec, e->keycode, e->state); + if (IME && IME->hasGrab() && !DISALLOWACTION) { + IME->setKeyboard(wlr_keyboard_from_input_device(pKeyboard->keyboard)); + IME->sendKey(e->time_msec, e->keycode, e->state); } else { wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state); @@ -1240,16 +1242,18 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { if (!pKeyboard->enabled) return; - const auto PIMEGRAB = m_sIMERelay.getIMEKeyboardGrab(pKeyboard); + const bool DISALLOWACTION = pKeyboard->isVirtual && shouldIgnoreVirtualKeyboard(pKeyboard); const auto ALLMODS = accumulateModsFromAllKBs(); auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers; MODS.depressed = ALLMODS; - if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) { - wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard)); - wlr_input_method_keyboard_grab_v2_send_modifiers(PIMEGRAB->pWlrKbGrab, &MODS); + const auto IME = m_sIMERelay.m_pIME.lock(); + + if (IME && IME->hasGrab() && !DISALLOWACTION) { + IME->setKeyboard(wlr_keyboard_from_input_device(pKeyboard->keyboard)); + IME->sendMods(MODS.depressed, MODS.latched, MODS.locked, MODS.group); } else { wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS); @@ -1273,8 +1277,7 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { bool CInputManager::shouldIgnoreVirtualKeyboard(SKeyboard* pKeyboard) { return !pKeyboard || - (m_sIMERelay.m_pKeyboardGrab && - wl_resource_get_client(m_sIMERelay.m_pKeyboardGrab->pWlrKbGrab->resource) == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource)); + (!m_sIMERelay.m_pIME.expired() && m_sIMERelay.m_pIME.lock()->grabClient() == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource)); } void CInputManager::refocus() { |
