summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorDarksome <dev@darkso.me>2022-07-15 21:54:05 +0300
committerDarksome <dev@darkso.me>2022-07-15 21:54:05 +0300
commit1eceae811f54a87c3c7de1d10202842db78c3f69 (patch)
treec637091afd03d90ee81c2536bea01b082c38d4c4 /src/managers
parent5388b54442614cb0d3d445f101e7cd86bf64c125 (diff)
Try mouse wheel configuration
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/KeybindManager.cpp17
-rw-r--r--src/managers/KeybindManager.hpp2
-rw-r--r--src/managers/input/InputManager.cpp23
3 files changed, 22 insertions, 20 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 60e4cdd6..4e00818e 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -82,10 +82,10 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) {
return modMask;
}
-bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode) {
+bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& key, const xkb_keysym_t& keysym, const int& keycode) {
bool found = false;
- if (handleInternalKeybinds(key))
+ if (handleInternalKeybinds(keysym))
return true;
if (g_pCompositor->m_sSeat.exclusiveClient)
@@ -95,13 +95,14 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap)
continue;
-
- if (k.keycode != -1) {
+ if (!key.empty()) {
+ if (key != k.key)
+ continue;
+ } else if (k.keycode != -1) {
if (keycode != k.keycode)
continue;
-
} else {
- if (key == 0)
+ if (keysym == 0)
continue; // this is a keycode check run
// oMg such performance hit!!11!
@@ -110,7 +111,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
// small TODO: fix 0-9 keys and other modified ones with shift
- if (key != KBKEY && key != KBKEYUPPER)
+ if (keysym != KBKEY && keysym != KBKEYUPPER)
continue;
}
@@ -121,7 +122,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
} else {
// call the dispatcher
- Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %d)", modmask, key);
+ Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %s)", modmask, key);
DISPATCHER->second(k.arg);
}
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 08a1cba3..049568a6 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -20,7 +20,7 @@ class CKeybindManager {
public:
CKeybindManager();
- bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&);
+ bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&);
void addKeybind(SKeybind);
void removeKeybind(uint32_t, const std::string&);
uint32_t stringToModMask(std::string);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 5f1b1a3a..55890abc 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -376,21 +376,20 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
}
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
- const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
+ const auto MODS = accumulateModsFromAllKBs();
- if (wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)g_pConfigManager->getInt("general:main_mod_internal") &&
- e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
-
+ bool found = false;
+ if (e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
if (e->delta < 0) {
- g_pKeybindManager->m_mDispatchers["workspace"]("-1");
+ found = g_pKeybindManager->handleKeybinds(MODS, "mouse_down", 0, 0);
} else {
- g_pKeybindManager->m_mDispatchers["workspace"]("m+1");
+ found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0);
}
-
- return;
}
- wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, e->delta, e->delta_discrete, e->source);
+ if (!found) {
+ wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, e->delta, e->delta_discrete, e->source);
+ }
}
Vector2D CInputManager::getMouseCoordsInternal() {
@@ -631,10 +630,12 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
bool found = false;
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+ static const std::string empty = "";
+
for (int i = 0; i < syms; ++i)
- found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, empty, keysyms[i], 0) || found;
- found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, empty, 0, KEYCODE) || found;
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
// hee hee
}