summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-08-18 17:50:32 +0200
committervaxerski <vaxry@vaxry.net>2022-08-18 17:50:32 +0200
commit9b62328b22fbd1ca20ac96cca0fcf21906d42aa6 (patch)
tree2826b07a200608996769da014d0ee7c0471afe11 /src
parentc1a64a2b9dfcee3453f6e938ed62117a676994b0 (diff)
minor changes to the activelayout event
Diffstat (limited to 'src')
-rw-r--r--src/debug/HyprCtl.cpp4
-rw-r--r--src/managers/input/InputManager.cpp33
-rw-r--r--src/managers/input/InputManager.hpp2
3 files changed, 27 insertions, 12 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 133508f0..2f5660df 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -321,7 +321,7 @@ R"#( {
escapeJSONStrings(k.currentRules.variant).c_str(),
escapeJSONStrings(k.currentRules.options).c_str(),
escapeJSONStrings(KM).c_str(),
- (&k == g_pInputManager->m_pActiveKeyboard ? "true" : "false")
+ (k.active ? "true" : "false")
);
}
@@ -388,7 +388,7 @@ R"#( {
for (auto& k : g_pInputManager->m_lKeyboards) {
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
- result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.keyboard->name, k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str(), (&k == g_pInputManager->m_pActiveKeyboard ? "yes" : "no"));
+ result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.keyboard->name, k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str(), (k.active ? "yes" : "no"));
}
result += "\n\nTablets:\n";
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index b002864d..f8899f62 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -444,13 +444,12 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
const auto PKEYBOARD = (SKeyboard*)owner;
- if (PKEYBOARD == m_pActiveKeyboard)
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
}, PNEWKEYBOARD, "Keyboard");
- if (m_pActiveKeyboard)
- m_pActiveKeyboard->active = false;
+ disableAllKeyboards(false);
+
m_pActiveKeyboard = PNEWKEYBOARD;
PNEWKEYBOARD->active = true;
@@ -477,9 +476,15 @@ void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
+
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+
+ }, PNEWKEYBOARD, "Keyboard");
+
+ disableAllKeyboards(true);
- if (m_pActiveKeyboard)
- m_pActiveKeyboard->active = false;
m_pActiveKeyboard = PNEWKEYBOARD;
PNEWKEYBOARD->active = true;
@@ -594,8 +599,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
xkb_keymap_unref(KEYMAP);
xkb_context_unref(CONTEXT);
- if (pKeyboard == m_pActiveKeyboard)
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," +getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
}
@@ -756,8 +760,7 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
pKeyboard->activeLayout = PWLRKB->modifiers.group;
- if (pKeyboard == m_pActiveKeyboard)
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
}
}
@@ -930,3 +933,13 @@ std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
return "none";
}
+
+void CInputManager::disableAllKeyboards(bool virt) {
+
+ for (auto& k : m_lKeyboards) {
+ if (k.isVirtual != virt)
+ continue;
+
+ k.active = false;
+ }
+} \ No newline at end of file
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 2db6c5a9..9ced0e8d 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -107,6 +107,8 @@ private:
void processMouseDownNormal(wlr_pointer_button_event* e);
void processMouseDownKill(wlr_pointer_button_event* e);
+ void disableAllKeyboards(bool virt = false);
+
uint32_t m_uiCapabilities = 0;
void mouseMoveUnified(uint32_t, bool refocus = false);