[Completer] Fix popup going offscreen by clamping in screen coordinates

The position clamping in applyPopupWidth() was comparing popup->pos()
(parent coordinates) against screen->availableGeometry() (screen
coordinates).  When the parent widget is not at the screen origin the
clamping computed a position in the wrong coordinate space, placing the
popup offscreen.  Convert to global coordinates first, clamp, then map
back to parent coordinates.
This commit is contained in:
Lukas Brübach 2026-08-17 03:44:44 +02:00
parent 674e32988b
commit bb4c489327

View file

@ -169,9 +169,12 @@ void CardCompleterStyler::applyPopupWidth()
popup->resize(minWidth, popup->height());
if (!available.isEmpty()) {
QPoint pos = popup->pos();
pos.setX(qBound(available.left(), pos.x(), qMax(available.left(), available.right() - popup->width() + 1)));
popup->move(pos);
// Clamp in screen coordinates, then map back to parent coordinates.
QPoint globalPos = popup->mapToGlobal(QPoint(0, 0));
int clampedGlobalX =
qBound(available.left(), globalPos.x(), qMax(available.left(), available.right() - popup->width() + 1));
QPoint parentPos = popup->mapFromGlobal(QPoint(clampedGlobalX, globalPos.y()));
popup->move(parentPos);
}
}
}