mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 14:29:48 +01:00
input: Option for handling off-window axis events (#4177)
This commit is contained in:
parent
277f2bb76a
commit
a06272ae55
2 changed files with 20 additions and 0 deletions
|
@ -440,6 +440,7 @@ CConfigManager::CConfigManager() {
|
|||
m_pConfig->addConfigValue("input:follow_mouse", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("input:mouse_refocus", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("input:special_fallthrough", Hyprlang::INT{0});
|
||||
m_pConfig->addConfigValue("input:off_window_axis_events", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("input:sensitivity", {0.f});
|
||||
m_pConfig->addConfigValue("input:accel_profile", {STRVAL_EMPTY});
|
||||
m_pConfig->addConfigValue("input:kb_file", {STRVAL_EMPTY});
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue