diff options
| author | JS Deck <jsdeckerido@gmail.com> | 2025-09-20 12:57:39 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-20 17:57:39 +0200 |
| commit | 838439080a9feaac3386d694dc7f8463e41c51df (patch) | |
| tree | 11492db963560ea2016b089356fab0f61dca3b6a /src | |
| parent | 6a88f2e8800d4540ecbbb0d5b3d7f85a05387300 (diff) | |
vkeyboard: update cached mods before IME; add share_states = 2 config option (#11720)
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigDescriptions.hpp | 6 | ||||
| -rw-r--r-- | src/config/ConfigManager.cpp | 2 | ||||
| -rw-r--r-- | src/devices/IKeyboard.cpp | 5 | ||||
| -rw-r--r-- | src/devices/IKeyboard.hpp | 4 | ||||
| -rw-r--r-- | src/devices/VirtualKeyboard.cpp | 7 | ||||
| -rw-r--r-- | src/managers/input/InputManager.cpp | 14 |
6 files changed, 28 insertions, 10 deletions
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index f2d384b2..a3a6e1b0 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -683,9 +683,9 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = { SConfigOptionDescription{ .value = "input:virtualkeyboard:share_states", - .description = "Unify key down states and modifier states with other keyboards", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{false}, + .description = "Unify key down states and modifier states with other keyboards. 0 -> no, 1 -> yes, 2 -> yes unless IME client", + .type = CONFIG_OPTION_INT, + .data = SConfigOptionDescription::SRangeData{2, 0, 2}, }, SConfigOptionDescription{ .value = "input:virtualkeyboard:release_pressed_on_close", diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index bf94152d..db0dd596 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -690,7 +690,7 @@ CConfigManager::CConfigManager() { registerConfigVar("input:touchdevice:transform", Hyprlang::INT{-1}); registerConfigVar("input:touchdevice:output", {"[[Auto]]"}); registerConfigVar("input:touchdevice:enabled", Hyprlang::INT{1}); - registerConfigVar("input:virtualkeyboard:share_states", Hyprlang::INT{0}); + registerConfigVar("input:virtualkeyboard:share_states", Hyprlang::INT{2}); registerConfigVar("input:virtualkeyboard:release_pressed_on_close", Hyprlang::INT{0}); registerConfigVar("input:tablet:transform", Hyprlang::INT{0}); registerConfigVar("input:tablet:output", {STRVAL_EMPTY}); diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index 7e6320e2..20292176 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -447,3 +447,8 @@ bool IKeyboard::getPressed(uint32_t key) { bool IKeyboard::shareStates() { return m_shareStates; } + +void IKeyboard::setShareStatesAuto(bool shareStates) { + if (m_shareStatesAuto) + m_shareStates = shareStates; +} diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp index eb213254..6f34063a 100644 --- a/src/devices/IKeyboard.hpp +++ b/src/devices/IKeyboard.hpp @@ -79,6 +79,7 @@ class IKeyboard : public IHID { void updateKeymapFD(); bool getPressed(uint32_t key); bool shareStates(); + void setShareStatesAuto(bool shareStates); bool m_active = false; bool m_enabled = true; @@ -131,5 +132,6 @@ class IKeyboard : public IHID { protected: bool updatePressed(uint32_t key, bool pressed); - bool m_shareStates = true; + bool m_shareStates = true; + bool m_shareStatesAuto = true; }; diff --git a/src/devices/VirtualKeyboard.cpp b/src/devices/VirtualKeyboard.cpp index 97b7626a..2951f36a 100644 --- a/src/devices/VirtualKeyboard.cpp +++ b/src/devices/VirtualKeyboard.cpp @@ -44,8 +44,11 @@ CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : m_key m_keyboardEvents.keymap.emit(event); }); - m_deviceName = keeb_->m_name; - m_shareStates = g_pConfigManager->getDeviceInt(m_deviceName, "share_states", "input:virtualkeyboard:share_states"); + m_deviceName = keeb_->m_name; + + const auto SHARESTATES = g_pConfigManager->getDeviceInt(m_deviceName, "share_states", "input:virtualkeyboard:share_states"); + m_shareStates = SHARESTATES != 0; + m_shareStatesAuto = SHARESTATES == 2; } bool CVirtualKeyboard::isVirtual() { diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index ea164842..fa7efb6a 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1479,6 +1479,7 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) { auto MODS = pKeyboard->m_modifiersState; const auto ALLMODS = shareModsFromAllKBs(MODS.depressed); MODS.depressed = ALLMODS; + m_lastMods = MODS.depressed; const auto IME = m_relay.m_inputMethod.lock(); @@ -1488,7 +1489,6 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) { } else { g_pSeatManager->setKeyboard(pKeyboard); g_pSeatManager->sendKeyboardMods(MODS.depressed, MODS.latched, MODS.locked, MODS.group); - m_lastMods = MODS.depressed; } updateKeyboardsLeds(pKeyboard); @@ -1506,12 +1506,20 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) { } bool CInputManager::shouldIgnoreVirtualKeyboard(SP<IKeyboard> pKeyboard) { + if (!pKeyboard) + return true; + if (!pKeyboard->isVirtual()) return false; - auto client = pKeyboard->getClient(); + const auto CLIENT = pKeyboard->getClient(); + + const auto DISALLOWACTION = CLIENT && !m_relay.m_inputMethod.expired() && m_relay.m_inputMethod->grabClient() == CLIENT; + + if (DISALLOWACTION) + pKeyboard->setShareStatesAuto(false); - return !pKeyboard || (client && !m_relay.m_inputMethod.expired() && m_relay.m_inputMethod->grabClient() == client); + return DISALLOWACTION; } void CInputManager::refocus(std::optional<Vector2D> overridePos) { |
