[utilities/kate] addons/git-blame: Ensure blame tooltip stays within screen bounds on x axis

Leo Ruggeri <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit a92975268e07a96443f995b1cd53225d1358a02a by Leo Ruggeri.
Committed on 25/07/2026 at 14:46.
Pushed by waqar into branch 'master'.

Ensure blame tooltip stays within screen bounds on x axis

M  +8    -0    addons/git-blame/gitblametooltip.cpp

https://invent.kde.org/utilities/kate/-/commit/a92975268e07a96443f995b1cd53225d1358a02a

diff --git a/addons/git-blame/gitblametooltip.cpp b/addons/git-blame/gitblametooltip.cpp
index 948d3b90b5..22c1bf0e50 100644
--- a/addons/git-blame/gitblametooltip.cpp
+++ b/addons/git-blame/gitblametooltip.cpp
@@ -317,6 +317,14 @@ public:
             p.ry() -= lineHeight + this->height();
         }
 
+        const int screenLeft = screenSize.x();
+        const int screenRight = screenLeft + screenSize.width();
+
+        constexpr int xMargin = 10;
+        const int xMin = screenLeft + xMargin;
+        const int xMax = std::max(xMin, screenRight - width() - xMargin);
+        p.setX(std::clamp(p.x(), xMin, xMax)); // Ensure tooltip stays within the screen bounds on the x axis
+
         this->move(p);
 
         show();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.