summaryrefslogtreecommitdiff
path: root/src/managers/input
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-08-16 16:10:20 +0200
committervaxerski <vaxry@vaxry.net>2022-08-16 16:10:20 +0200
commit6e2467cc24f8afb70a4aaad3841a7c41fbc568b5 (patch)
tree2869fe6b3ff52a35c09593f446d5bd8a09c68692 /src/managers/input
parent454d0d3f9f6b8f68a6bb59463ae3227f7ddce691 (diff)
fix active keymap in hyprctl devices
Diffstat (limited to 'src/managers/input')
-rw-r--r--src/managers/input/InputManager.cpp19
-rw-r--r--src/managers/input/InputManager.hpp1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index c60b85bf..c552910c 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -887,3 +887,22 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
return finalMask;
}
+
+std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
+ const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
+ const auto KEYMAP = WLRKB->keymap;
+ const auto STATE = WLRKB->xkb_state;
+ const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP);
+
+ for (auto i = 0; i < LAYOUTSNUM; ++i) {
+ if (xkb_state_layout_index_is_active(STATE, i, XKB_STATE_LAYOUT_EFFECTIVE)) {
+ const auto LAYOUTNAME = xkb_keymap_layout_get_name(KEYMAP, i);
+
+ if (LAYOUTNAME)
+ return std::string(LAYOUTNAME);
+ return "error";
+ }
+ }
+
+ return "none";
+}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index b9e04d23..6f472521 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -35,6 +35,7 @@ public:
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
void recheckConstraint(SMouse*);
void unconstrainMouse();
+ std::string getActiveLayoutForKeyboard(SKeyboard*);
Vector2D getMouseCoordsInternal();
void refocus();