aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authordranull <[email protected]>2024-04-08 22:35:21 +0000
committerGitHub <[email protected]>2024-04-08 23:35:21 +0100
commita06272ae552a3f6bdcb9c63c20fe25b05e5579d1 (patch)
tree03806455a470e7c6eadadd79aa9c10f83c4a844b /src/managers/input/InputManager.cpp
parent277f2bb76ace017e54c3bd8ea1a754e77350455a (diff)
downloadHyprland-a06272ae552a3f6bdcb9c63c20fe25b05e5579d1.tar.gz
Hyprland-a06272ae552a3f6bdcb9c63c20fe25b05e5579d1.zip
input: Option for handling off-window axis events (#4177)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 84ac00b5..c003b08f 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -680,6 +680,7 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
}
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
+ static auto POFFWINDOWAXIS = CConfigValue<Hyprlang::INT>("input:off_window_axis_events");
static auto PINPUTSCROLLFACTOR = CConfigValue<Hyprlang::FLOAT>("input:scroll_factor");
static auto PTOUCHPADSCROLLFACTOR = CConfigValue<Hyprlang::FLOAT>("input:touchpad:scroll_factor");
@@ -701,6 +702,24 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
if (PWINDOW && PWINDOW->checkInputOnDecos(INPUT_TYPE_AXIS, MOUSECOORDS, e))
return;
+
+ if (PWINDOW && *POFFWINDOWAXIS != 1) {
+ const auto BOX = PWINDOW->getWindowMainSurfaceBox();
+
+ if (!BOX.containsPoint(MOUSECOORDS) && !PWINDOW->hasPopupAt(MOUSECOORDS)) {
+ if (*POFFWINDOWAXIS == 0)
+ return;
+
+ const auto TEMPCURX = std::clamp(MOUSECOORDS.x, BOX.x, BOX.x + BOX.w - 1);
+ const auto TEMPCURY = std::clamp(MOUSECOORDS.y, BOX.y, BOX.y + BOX.h - 1);
+
+ if (*POFFWINDOWAXIS == 3)
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, TEMPCURX, TEMPCURY);
+
+ wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, TEMPCURX - BOX.x, TEMPCURY - BOX.y);
+ wlr_seat_pointer_notify_frame(g_pCompositor->m_sSeat.seat);
+ }
+ }
}
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source,