Bug 348637

Summary: Infinite moving picture - possible patch
Product: [Applications] gwenview Reporter: Błażej Szczygieł <mumei6102>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: minor CC: justin.zobel, myriam, nate
Priority: NOR    
Version First Reported In: 5.0.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Patch for infinite moving picture (Qt5 bug workaround)

Description Błażej Szczygieł 2015-06-03 14:05:03 UTC
Mouse when moving picture out of imageview doesn't wraps like in KDE4. This is very useful.

Reproducible: Always

Steps to Reproduce:
Move the image by mouse out of image view.

Actual Results:  
Mouse doesn't wrap.

Expected Results:  
Mouse wraps like in KDE4.

Patch tested on Arch Linux, Qt 5.4.2:

--- abstractimageview.cpp.orig  2015-06-03 16:00:49.241659454 +0200
+++ abstractimageview.cpp       2015-06-03 16:00:55.708326391 +0200
@@ -306,7 +306,6 @@
     QPointF mousePos = event->pos();
     QPointF newScrollPos = d->mScrollPos + d->mLastDragPos - mousePos;
 
-#if 0 // commented out due to mouse pointer warping around, bug in Qt?
     // Wrap mouse pos
     qreal maxWidth = boundingRect().width();
     qreal maxHeight = boundingRect().height();
@@ -315,22 +314,28 @@
     // The mouse get placed 1 pixel before/after the margin to avoid getting
     // considered as needing to wrap the other way in next mouseMoveEvent
     // (because we don't check the move vector)
+    bool setCursorPos = false;
     const int margin = 5;
     if (mousePos.x() <= margin) {
         mousePos.setX(maxWidth - margin - 1);
+        setCursorPos = true;
     } else if (mousePos.x() >= maxWidth - margin) {
         mousePos.setX(margin + 1);
+        setCursorPos = true;
     }
     if (mousePos.y() <= margin) {
         mousePos.setY(maxHeight - margin - 1);
+        setCursorPos = true;
     } else if (mousePos.y() >= maxHeight - margin) {
         mousePos.setY(margin + 1);
+        setCursorPos = true;
     }
 
-    // Set mouse pos (Hackish translation to screen coords!)
-    QPointF screenDelta = event->screenPos() - event->pos();
-    QCursor::setPos((mousePos + screenDelta).toPoint());
-#endif
+    if (setCursorPos) {
+        // Set mouse pos (Hackish translation to screen coords!)
+        QPointF screenDelta = event->screenPos() - event->pos();
+        QCursor::setPos((mousePos + screenDelta).toPoint());
+    }
 
     d->mLastDragPos = mousePos;
     d->setScrollPos(newScrollPos);
Comment 1 Błażej Szczygieł 2015-06-03 14:16:37 UTC
Created attachment 92975 [details]
Patch for infinite moving picture (Qt5 bug workaround)

Patch tested on Arch Linux, Qt 5.4.2
Comment 2 Nate Graham 2017-09-09 01:53:19 UTC
Thanks for the patch! Unfortunately, as you have surely noticed, it has been ignored for 2 years. :( Patches in bugzilla tickets tend to get lost, so I encourage you to upload it to http://phabricator.kde.org/, which is the KDE patch submission infrastructure (among other things).
Comment 3 Justin Zobel 2020-11-10 03:58:36 UTC
If you're still interested in submitting this patch, please see https://invent.kde.org/graphics/gwenview/-/merge_requests, thanks.
Comment 4 Nate Graham 2020-11-11 00:47:16 UTC
I tried applying this patch, but it seems like the feature in question no longer makes sense as you can't drag the image in the image view to switch images anymore. Furthermore, doing this breaks dragging the image out of the image view and into another app. So I don't think we'll be doing this, sorry. :)