diff --git a/src/events/Devices.cpp b/src/events/Devices.cpp index 7a47df77..09f7d2ab 100644 --- a/src/events/Devices.cpp +++ b/src/events/Devices.cpp @@ -49,9 +49,8 @@ void Events::listener_mouseButton(wl_listener* listener, void* data) { } void Events::listener_mouseAxis(wl_listener* listener, void* data) { - const auto E = (wlr_pointer_axis_event*)data; - - wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, E->time_msec, E->orientation, E->delta, E->delta_discrete, E->source); + g_pInputManager->onMouseWheel((wlr_pointer_axis_event*)data); + } void Events::listener_requestMouse(wl_listener* listener, void* data) { 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*);