From ba39b56096c3cc0f25b56b86440705b903e57ea6 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 23 Aug 2022 11:39:51 -0300 Subject: [PATCH] Fix std::clamp() max bound in TipWindow::pointAt() --- src/ui/tooltips.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/tooltips.cpp b/src/ui/tooltips.cpp index 294e3a116..dcb3fe758 100644 --- a/src/ui/tooltips.cpp +++ b/src/ui/tooltips.cpp @@ -218,16 +218,16 @@ bool TipWindow::pointAt(int arrowAlign, const gfx::Rect& target, const ui::Displ if (get_multiple_displays()) { const gfx::Rect waBounds = nativeParentWindow->screen()->workarea(); gfx::Point pt = nativeParentWindow->pointToScreen(gfx::Point(x, y)); - pt.x = std::clamp(pt.x, waBounds.x, waBounds.x2() - w); - pt.y = std::clamp(pt.y, waBounds.y, waBounds.y2() - h); + pt.x = std::clamp(pt.x, waBounds.x, std::max(waBounds.x, waBounds.x2() - w)); + pt.y = std::clamp(pt.y, waBounds.y, std::max(waBounds.y, waBounds.y2() - h)); pt = nativeParentWindow->pointFromScreen(pt); x = pt.x; y = pt.y; } else { const gfx::Rect displayBounds = display->bounds(); - x = std::clamp(x, displayBounds.x, displayBounds.x2() - w); - y = std::clamp(y, displayBounds.y, displayBounds.y2() - h); + x = std::clamp(x, displayBounds.x, std::max(displayBounds.x, displayBounds.x2() - w)); + y = std::clamp(y, displayBounds.y, std::max(displayBounds.y, displayBounds.y2() - h)); } if (m_target.intersects(gfx::Rect(x, y, w, h))) {