Fix std::clamp() max bound in TipWindow::pointAt()

This commit is contained in:
David Capello 2022-08-23 11:39:51 -03:00
parent 1f75d5444d
commit 7ca6f53eb6
1 changed files with 4 additions and 4 deletions

View File

@ -218,16 +218,16 @@ bool TipWindow::pointAt(int arrowAlign, const gfx::Rect& target, const ui::Displ
if (get_multiple_displays()) { if (get_multiple_displays()) {
const gfx::Rect waBounds = nativeParentWindow->screen()->workarea(); const gfx::Rect waBounds = nativeParentWindow->screen()->workarea();
gfx::Point pt = nativeParentWindow->pointToScreen(gfx::Point(x, y)); gfx::Point pt = nativeParentWindow->pointToScreen(gfx::Point(x, y));
pt.x = std::clamp(pt.x, waBounds.x, waBounds.x2() - w); pt.x = std::clamp(pt.x, waBounds.x, std::max(waBounds.x, waBounds.x2() - w));
pt.y = std::clamp(pt.y, waBounds.y, waBounds.y2() - h); pt.y = std::clamp(pt.y, waBounds.y, std::max(waBounds.y, waBounds.y2() - h));
pt = nativeParentWindow->pointFromScreen(pt); pt = nativeParentWindow->pointFromScreen(pt);
x = pt.x; x = pt.x;
y = pt.y; y = pt.y;
} }
else { else {
const gfx::Rect displayBounds = display->bounds(); const gfx::Rect displayBounds = display->bounds();
x = std::clamp(x, displayBounds.x, displayBounds.x2() - w); x = std::clamp(x, displayBounds.x, std::max(displayBounds.x, displayBounds.x2() - w));
y = std::clamp(y, displayBounds.y, displayBounds.y2() - h); y = std::clamp(y, displayBounds.y, std::max(displayBounds.y, displayBounds.y2() - h));
} }
if (m_target.intersects(gfx::Rect(x, y, w, h))) { if (m_target.intersects(gfx::Rect(x, y, w, h))) {