Skip to content

Commit

Permalink
Option for handling scroll over window decoration
Browse files Browse the repository at this point in the history
  • Loading branch information
dranull committed Dec 17, 2023
1 parent c0d9dcc commit 3b66ecc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void CConfigManager::setDefaultVars() {
configValues["general:no_cursor_warps"].intValue = 0;
configValues["general:no_focus_fallback"].intValue = 0;
configValues["general:resize_on_border"].intValue = 0;
configValues["general:scroll_on_decoration"].intValue = 1;
configValues["general:extend_border_grab_area"].intValue = 15;
configValues["general:hover_icon_on_border"].intValue = 1;
configValues["general:layout"].strValue = "dwindle";
Expand Down
23 changes: 23 additions & 0 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {

void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
static auto* const PSCROLLFACTOR = &g_pConfigManager->getConfigValuePtr("input:touchpad:scroll_factor")->floatValue;
static auto* const PSCROLLONDECO = &g_pConfigManager->getConfigValuePtr("general:scroll_on_decoration")->intValue;
static auto* const PGROUPBARSCROLLING = &g_pConfigManager->getConfigValuePtr("group:groupbar:scrolling")->intValue;

auto factor = (*PSCROLLFACTOR <= 0.f || e->source != WLR_AXIS_SOURCE_FINGER ? 1.f : *PSCROLLFACTOR);
Expand Down Expand Up @@ -720,6 +721,28 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
}
}

if (*PSCROLLONDECO != 1 && pWindow) {
const auto BOX = pWindow->getWindowMainSurfaceBox();

if (!BOX.containsPoint(MOUSECOORDS) && !pWindow->hasPopupAt(MOUSECOORDS)) {
if (*PSCROLLONDECO == 0)
return;

const auto NEWMOUSEX = std::clamp(MOUSECOORDS.x, BOX.x, BOX.x + BOX.w - 1);
const auto NEWMOUSEY = std::clamp(MOUSECOORDS.y, BOX.y, BOX.y + BOX.h - 1);

timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);

wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, NEWMOUSEX, NEWMOUSEY);
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, now.tv_sec * 1000 + now.tv_nsec / 10000000, NEWMOUSEX - BOX.x, NEWMOUSEY - BOX.y);
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);
wlr_seat_pointer_notify_frame(g_pCompositor->m_sSeat.seat);
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MOUSECOORDS.x, MOUSECOORDS.y);
return;
}
}

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);
}

Expand Down

0 comments on commit 3b66ecc

Please sign in to comment.