folio: Fix delegate drop placement not accounting for view padding

This is exacerbated now that we have device-specific view margins (to
deal with notches and the like), which caused the drag and drop
positions to be wildly inaccurate.
This commit is contained in:
Devin Lin 2026-01-13 21:57:13 -05:00
parent f8fc2afa10
commit 81232b3ed7

View file

@ -407,12 +407,12 @@ void DragState::onDelegateDragPositionOverPageViewChanged()
if (m_dropDelegate && m_dropDelegate->type() == FolioDelegate::Widget) {
// for widgets, we use their top left position to determine where they are placed (since they are larger than one cell)
row = (delegateY - pageVerticalMargin) / m_state->pageCellHeight();
column = (delegateX - pageHorizontalMargin) / m_state->pageCellWidth();
row = (delegateY - pageVerticalMargin - m_state->viewTopPadding()) / m_state->pageCellHeight();
column = (delegateX - pageHorizontalMargin - m_state->viewLeftPadding()) / m_state->pageCellWidth();
} else {
// otherwise, we base it on the pointer position
row = (y - pageVerticalMargin) / m_state->pageCellHeight();
column = (x - pageHorizontalMargin) / m_state->pageCellWidth();
row = (y - pageVerticalMargin - m_state->viewTopPadding()) / m_state->pageCellHeight();
column = (x - pageHorizontalMargin - m_state->viewLeftPadding()) / m_state->pageCellWidth();
}
// ensure it's in bounds