From 8f62f6d4b0dbf18f1857e13831638a7d3615aeee Mon Sep 17 00:00:00 2001 From: Darksome Date: Mon, 20 Jun 2022 22:47:28 +0300 Subject: Add workspace switching with mouse wheel --- src/managers/input/InputManager.cpp | 18 ++++++++++++++++++ src/managers/input/InputManager.hpp | 1 + 2 files changed, 19 insertions(+) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 003535f7..fefc4047 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -230,6 +230,24 @@ void CInputManager::onMouseButton(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); + + 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) { + + if (e->delta > 0) { + g_pKeybindManager->m_mDispatchers["workspace"]("-1"); + } else { + g_pKeybindManager->m_mDispatchers["workspace"]("+1"); + } + + return; + } + + 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 18d9857e..7a3601bc 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -11,6 +11,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*); -- cgit v1.2.3 From 776ca3baf269059e8c13ba8b625645215e71f78c Mon Sep 17 00:00:00 2001 From: Darksome Date: Fri, 24 Jun 2022 18:57:14 +0300 Subject: Change workspace wheel scrolling direction --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index fefc4047..826354f1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -236,7 +236,7 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) { 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) { - if (e->delta > 0) { + if (e->delta < 0) { g_pKeybindManager->m_mDispatchers["workspace"]("-1"); } else { g_pKeybindManager->m_mDispatchers["workspace"]("+1"); -- cgit v1.2.3 From cb8a6f881b11e9a269fd5f7aa64eafe2beda0b0d Mon Sep 17 00:00:00 2001 From: Darksome Date: Sat, 2 Jul 2022 19:55:35 +0300 Subject: Disallow scrolling into empty workspaces --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 94d4b8c8..92a06a4c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -360,7 +360,7 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) { if (e->delta < 0) { g_pKeybindManager->m_mDispatchers["workspace"]("-1"); } else { - g_pKeybindManager->m_mDispatchers["workspace"]("+1"); + g_pKeybindManager->m_mDispatchers["workspace"]("m+1"); } return; -- cgit v1.2.3 From 1eceae811f54a87c3c7de1d10202842db78c3f69 Mon Sep 17 00:00:00 2001 From: Darksome Date: Fri, 15 Jul 2022 21:54:05 +0300 Subject: Try mouse wheel configuration --- src/managers/KeybindManager.cpp | 17 +++++++++-------- src/managers/KeybindManager.hpp | 2 +- src/managers/input/InputManager.cpp | 23 ++++++++++++----------- 3 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src/managers') 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 } -- cgit v1.2.3 From ce9efb7ae38acb84d72035e6b4a772a6fe5e9319 Mon Sep 17 00:00:00 2001 From: Darksome Date: Sat, 16 Jul 2022 15:28:17 +0300 Subject: Impl changeworkspace(e+{n}) --- src/managers/input/InputManager.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/managers') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 55890abc..c7fcfb7a 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -630,12 +630,10 @@ 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, empty, keysyms[i], 0) || found; + found = g_pKeybindManager->handleKeybinds(MODS, "", keysyms[i], 0) || found; - found = g_pKeybindManager->handleKeybinds(MODS, empty, 0, KEYCODE) || found; + found = g_pKeybindManager->handleKeybinds(MODS, "", 0, KEYCODE) || found; } else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) { // hee hee } -- cgit v1.2.3 From 08319dd1f5185e1938df86a0a0a61f06b30026f4 Mon Sep 17 00:00:00 2001 From: Darksome Date: Sat, 16 Jul 2022 15:34:13 +0300 Subject: Fix handleKeybinds debug log --- src/managers/KeybindManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 4e00818e..3aecc3b6 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -122,7 +122,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& 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, %s)", modmask, key); + Debug::log(LOG, "Keybind triggered, calling dispatcher (%d, %s, %d)", modmask, key, keysym); DISPATCHER->second(k.arg); } -- cgit v1.2.3 From ce508f1cdc5b504c16792eddb8b0a04b5dbba4d7 Mon Sep 17 00:00:00 2001 From: Darksome Date: Thu, 21 Jul 2022 19:48:34 +0300 Subject: Fix merge --- src/managers/KeybindManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index cf820611..7fb4f2bd 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -169,7 +169,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string& if (pressed && k.release) { // suppress down event - m_kHeldBack = key; + m_kHeldBack = keysym; return true; } -- cgit v1.2.3 From d5ccca4fdbdf53eec011210f4bbbdb20049aa12e Mon Sep 17 00:00:00 2001 From: Darksome Date: Thu, 21 Jul 2022 20:31:38 +0300 Subject: Consider scroll as a 'pressed' key --- src/managers/KeybindManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7fb4f2bd..3f723565 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -119,9 +119,9 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) { 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, false, 0); + found = g_pKeybindManager->handleKeybinds(MODS, "mouse_down", 0, 0, true, 0); } else { - found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0, false, 0); + found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0, true, 0); } } -- cgit v1.2.3