summaryrefslogtreecommitdiff
path: root/src/managers/input
diff options
context:
space:
mode:
authorxDarksome <dev@darkso.me>2022-06-26 19:20:20 +0300
committerGitHub <noreply@github.com>2022-06-26 19:20:20 +0300
commit504f76112aec3625f2d67f9289a48a01bc90cb50 (patch)
treef3a4c5176a2d8f1954a7632b542f829e994c8529 /src/managers/input
parentbe460ea9547691eb136bf8b600b67b778af47e3f (diff)
parentf1a5cb4979f312f56967888c2b1b6d2aa535bb9e (diff)
Merge branch 'hyprwm:main' into main
Diffstat (limited to 'src/managers/input')
-rw-r--r--src/managers/input/InputManager.cpp28
-rw-r--r--src/managers/input/InputManager.hpp3
-rw-r--r--src/managers/input/Tablets.cpp2
3 files changed, 28 insertions, 5 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 131be576..4019a188 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -14,12 +14,16 @@ void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
wlr_cursor_move(g_pCompositor->m_sWLRCursor, &e->pointer->base, DELTA.x * sensitivity, DELTA.y * sensitivity);
mouseMoveUnified(e->time_msec);
+
+ m_tmrLastCursorMovement.reset();
}
void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, &e->pointer->base, e->x, e->y);
mouseMoveUnified(e->time_msec);
+
+ m_tmrLastCursorMovement.reset();
}
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
@@ -205,6 +209,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
+ m_tmrLastCursorMovement.reset();
+
const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
if (!PKEYBOARD) { // ???
@@ -289,7 +295,7 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
m_pActiveKeyboard->active = false;
m_pActiveKeyboard = PNEWKEYBOARD;
- setKeyboardLayout();
+ applyConfigToKeyboard(PNEWKEYBOARD);
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, keyboard->keyboard);
@@ -311,6 +317,11 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
+ if (RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) {
+ Debug::log(LOG, "Not applying config to keyboard, it did not change.");
+ return;
+ }
+
xkb_rule_names rules = {
.rules = RULES.c_str(),
.model = MODEL.c_str(),
@@ -318,6 +329,8 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
.variant = VARIANT.c_str(),
.options = OPTIONS.c_str()};
+ pKeyboard->currentRules = rules;
+
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!CONTEXT) {
@@ -325,12 +338,17 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
return;
}
- const auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
+
+ auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
if (!KEYMAP) {
Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
- xkb_context_unref(CONTEXT);
- return;
+ memset(&rules, 0, sizeof(rules));
+
+ pKeyboard->currentRules = rules;
+
+ KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
}
wlr_keyboard_set_keymap(pKeyboard->keyboard->keyboard, KEYMAP);
@@ -401,6 +419,8 @@ void CInputManager::newMouse(wlr_input_device* mouse) {
g_pCompositor->m_sSeat.mouse = PMOUSE;
+ m_tmrLastCursorMovement.reset();
+
Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse);
}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index ef3a4eb4..06e6cb07 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -4,6 +4,7 @@
#include <list>
#include "../../helpers/WLClasses.hpp"
#include "../../Window.hpp"
+#include "../../helpers/Timer.hpp"
class CInputManager {
public:
@@ -53,6 +54,8 @@ public:
SKeyboard* m_pActiveKeyboard = nullptr;
+ CTimer m_tmrLastCursorMovement;
+
private:
uint32_t m_uiCapabilities = 0;
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index c33f021c..4285d06b 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -226,4 +226,4 @@ void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool moti
if (PTOOL->pSurface)
wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2);
}
-} \ No newline at end of file
+}