Bug 417162

Summary: Incorrect tooltip position when shown on the edge of second screen
Product: [Applications] filelight Reporter: teemu.patana
Component: generalAssignee: Martin Sandsmark <martin.sandsmark>
Status: RESOLVED FIXED    
Severity: normal CC: claudius.ellsel, justin.zobel, nate
Priority: NOR    
Version: 19.12   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Patch

Description teemu.patana 2020-02-04 19:33:09 UTC
Created attachment 125672 [details]
Patch

Tooltip position doesn't consider screen's position when it's going over the edge of the second screen.

Figuring out how to use phabricator for a simple task like this seemed quite complicated so I'll just add the patch as an attachment.
Comment 1 teemu.patana 2020-02-05 19:15:14 UTC
Comment on attachment 125672 [details]
Patch

diff --git a/src/radialMap/widgetEvents.cpp b/src/radialMap/widgetEvents.cpp
index e2c7a6c..d7178b2 100644
--- a/src/radialMap/widgetEvents.cpp
+++ b/src/radialMap/widgetEvents.cpp
@@ -160,10 +160,10 @@ void RadialMap::Widget::mouseMoveEvent(QMouseEvent *e)
     // Same content as before
     if (m_focus == oldFocus) {
         if (tooltipRect.right() > screenRect.right()) {
-            tooltipPosition.setX(screenRect.width() - m_tooltip.width());
+            tooltipPosition.setX(screenRect.x() + screenRect.width() - m_tooltip.width());
         }
         if (tooltipRect.bottom() > screenRect.bottom()) {
-            tooltipPosition.setY(screenRect.height() - m_tooltip.height());
+            tooltipPosition.setY(screenRect.y() + screenRect.height() - m_tooltip.height());
         }
         m_tooltip.move(tooltipPosition);
         return;
@@ -235,10 +235,10 @@ void RadialMap::Widget::mouseMoveEvent(QMouseEvent *e)
     // Make sure we're visible on screen
     tooltipRect.setSize(QSize(tooltipWidth, tooltipHeight));
     if (tooltipRect.right() > screenRect.right()) {
-        tooltipPosition.setX(screenRect.width() - m_tooltip.width());
+        tooltipPosition.setX(screenRect.x() + screenRect.width() - m_tooltip.width());
     }
     if (tooltipRect.bottom() > screenRect.bottom()) {
-        tooltipPosition.setY(screenRect.height() - m_tooltip.height());
+        tooltipPosition.setY(screenRect.y() + screenRect.height() - m_tooltip.height());
     }
     m_tooltip.move(tooltipPosition);
Comment 2 teemu.patana 2020-02-05 19:18:17 UTC
Thought I'd edit the attachment as a normal patch file without commit messages, seems like it didn't go as I planned, my bad.
Comment 3 Justin Zobel 2020-11-12 23:50:47 UTC
Many thanks for the patch, can you please submit it to https://invent.kde.org/utilities/filelight/-/merge_requests so it can be reviewed, thanks.
Comment 5 Harald Sitter 2021-01-05 11:18:30 UTC
Git commit 70795c19dbd1aae5cde3ce7fc870ad8ca4de8ac3 by Harald Sitter, on behalf of Teemu Patana.
Committed on 05/01/2021 at 10:38.
Pushed by sitter into branch 'master'.

Fix tooltip positioning in RadialMap

The tooltip position was incorrect when shown on the edge of second screen.

M  +4    -4    src/radialMap/widgetEvents.cpp

https://invent.kde.org/utilities/filelight/commit/70795c19dbd1aae5cde3ce7fc870ad8ca4de8ac3
Comment 6 Claudius Ellsel 2021-01-16 17:37:08 UTC
Since there are no screenshots of the problem, I don't know exactly what this does. I think I have noted unexpected tooltop behavior in other KDE applications as well, though. Basically when the tooltip is near the screen edge (the one where two screens meet), it will be displayed on the other screen instead of the current screen the application is on.

So it might be worth to look whether other applications require similar fixes (or whether it is possible to unify their behavior somehow).