diff --git a/lib/widget/tip.cpp b/lib/widget/tip.cpp index 8d344045fe8..564300b8edf 100644 --- a/lib/widget/tip.cpp +++ b/lib/widget/tip.cpp @@ -161,11 +161,11 @@ static void refreshTip(std::shared_ptr mouseOverWidget) height += displayCache.wzTip.back().belowBase(); } auto x = clip(mouseOverWidget->screenPosX() + mouseOverWidget->width() / 2, 0, screenWidth - width - 1); - auto y = std::max(mouseOverWidget->screenPosY() + mouseOverWidget->height() + TIP_VGAP, 0); - if (y + height >= (int)screenHeight) + auto y = std::min(mouseOverWidget->screenPosY() - height - TIP_VGAP, (int)screenHeight); + if (y < 0) { - /* Position the tip above the button */ - y = mouseOverWidget->screenPosY() - height - TIP_VGAP; + /* Position the tip below the button */ + y = std::max(mouseOverWidget->screenPosY() + mouseOverWidget->height() + TIP_VGAP, 0); } tipRect = WzRect(x - 1, y - 1, width + 2, height + 2);