summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2022-07-21 19:40:15 +0200
committerGitHub <noreply@github.com>2022-07-21 19:40:15 +0200
commita011c28227d3f2832ccf55ca2f6362b76700fe1b (patch)
treefbd6eadcba1647f83eeb7731b8a88878ff8c699e /src/managers
parentf512bf6b5a5c003560e421a0ccf4c1adb19148f5 (diff)
parentd5ccca4fdbdf53eec011210f4bbbdb20049aa12e (diff)
Merge pull request #265 from xDarksome/main
Scroll workspaces with Super+MouseWheel
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/KeybindManager.cpp41
-rw-r--r--src/managers/KeybindManager.hpp3
-rw-r--r--src/managers/input/InputManager.cpp10
-rw-r--r--src/managers/input/InputManager.hpp1
4 files changed, 42 insertions, 13 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 74cecc45..3f723565 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -95,17 +95,17 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
m_dPressedKeycodes.push_back(KEYCODE);
m_dPressedKeysyms.push_back(keysym);
- found = g_pKeybindManager->handleKeybinds(MODS, keysym, 0, true, e->time_msec) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, "", keysym, 0, true, e->time_msec) || found;
- found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, true, e->time_msec) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, "", 0, KEYCODE, true, e->time_msec) || found;
} else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
m_dPressedKeycodes.erase(std::remove(m_dPressedKeycodes.begin(), m_dPressedKeycodes.end(), KEYCODE));
m_dPressedKeysyms.erase(std::remove(m_dPressedKeysyms.begin(), m_dPressedKeysyms.end(), keysym));
- found = g_pKeybindManager->handleKeybinds(MODS, keysym, 0, false, e->time_msec) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, "", keysym, 0, false, e->time_msec) || found;
- found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, false, e->time_msec) || found;
+ found = g_pKeybindManager->handleKeybinds(MODS, "", 0, KEYCODE, false, e->time_msec) || found;
shadowKeybinds();
}
@@ -113,10 +113,25 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
return !found;
}
-bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode, bool pressed, uint32_t time) {
+bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
+ const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
+
+ bool found = false;
+ if (e->source == WLR_AXIS_SOURCE_WHEEL && e->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
+ if (e->delta < 0) {
+ found = g_pKeybindManager->handleKeybinds(MODS, "mouse_down", 0, 0, true, 0);
+ } else {
+ found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0, true, 0);
+ }
+ }
+
+ return !found;
+}
+
+bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& key, const xkb_keysym_t& keysym, const int& keycode, bool pressed, uint32_t time) {
bool found = false;
- if (handleInternalKeybinds(key))
+ if (handleInternalKeybinds(keysym))
return true;
if (g_pCompositor->m_sSeat.exclusiveClient)
@@ -132,12 +147,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 || (!pressed && !k.release) || k.shadowed)
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!
@@ -146,13 +163,13 @@ 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;
}
if (pressed && k.release) {
// suppress down event
- m_kHeldBack = key;
+ m_kHeldBack = keysym;
return true;
}
@@ -163,7 +180,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, %d)", modmask, key, keysym);
DISPATCHER->second(k.arg);
}
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 62568fc0..4fa314a9 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -25,6 +25,7 @@ public:
CKeybindManager();
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
+ bool onAxisEvent(wlr_pointer_axis_event*);
void addKeybind(SKeybind);
void removeKeybind(uint32_t, const std::string&);
@@ -42,7 +43,7 @@ private:
xkb_keysym_t m_kHeldBack = 0;
- bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&, bool, uint32_t);
+ bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&, bool, uint32_t);
void shadowKeybinds();
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index c922421c..e1f2e98f 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -381,6 +381,16 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
m_ecbClickBehavior = CLICKMODE_DEFAULT;
}
+void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
+ bool passEvent = g_pKeybindManager->onAxisEvent(e);
+
+ wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
+
+ if (passEvent) {
+ 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() {
return Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y);
}
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 107d891f..da821dfc 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -17,6 +17,7 @@ public:
void onMouseMoved(wlr_pointer_motion_event*);
void onMouseWarp(wlr_pointer_motion_absolute_event*);
void onMouseButton(wlr_pointer_button_event*);
+ void onMouseWheel(wlr_pointer_axis_event*);
void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
void onKeyboardMod(void*, SKeyboard*);