Bug 325799

Summary: Zoom With Mouse Tracking Does Not Start At the Correct Zoom Location
Product: [Plasma] kwin Reporter: C Schell <kdebugs>
Component: effects-variousAssignee: KWin default assignee <kwin-bugs-null>
Severity: normal    
Priority: NOR    
Version: 4.11.2   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 4.11.3
Attachments: Patch to correction initialize cursorPos at start of zoom
git format-patch

Description C Schell 2013-10-09 04:11:45 UTC
When mouse tracking is enabled, zoom initially zooms into the location where the mouse cursor last was when an active zoom was zoomed all the way out.   The zoom then may jump to the current location of the mouse cursor quickly with a brief stutter, or it may stay at the old erroneous location until the mouse is moved.

The cause is that cursorPoint (the point zoomed to) is not set until mouse polling is enabled and ZoomEffect::slotMouseChanged is called. 

A simple fix is to add 
cursorPoint = effects->cursorPos();
to the ZoomEffect::zoomIn(double to) method.  This method sets prevPoint for MouseTrackingDisabled but does not set cursorPoint which is required when mouse tracking is enabled.

Bug observed in Proportional and Centered modes.  Proposed fix tested in Proportional, Centered, and Push modes.  Never used unpatched Push mode to watch for bug but it should be affected too since is uses cursorPoint.  Bug is most obvious in proportional mode.

Platform is SolydK linux distribution.

Reproducible: Always

Steps to Reproduce:
1.Enable Mouse Tracking in Proportional mode
2.Zoom in on one corner of the screen, move mouse a little, zoom out (while cursor is still in the same corner).
3.Move mouse cursor to opposite corner when zoomed all the way out then zoom in while cursor is stationary in that corner of the screen.  Watch screen jump from previous corner to current one.
(Track balls make it easy to not move the mouse, with enough tries you can get it to zoom entirely to the old location and not hop to the new one until the mouse is moved.)
Actual Results:  
Zoom initially zooms to location where cursor was when last zoomed out, then jumps to the correct current cursor location.

Expected Results:  
Zoom should initially zoom to current cursor location.

Patch to fix the bug.

--- kde-workspace-4.11.2.orig/kwin/effects/zoom/zoom.cpp
+++ kde-workspace-4.11.2/kwin/effects/zoom/zoom.cpp
@@ -387,6 +387,7 @@ void ZoomEffect::zoomIn(double to)
         polling = true;
+    cursorPoint = effects->cursorPos();
     if (mouseTracking == MouseTrackingDisabled)
         prevPoint = effects->cursorPos();
Comment 1 C Schell 2013-10-09 04:14:24 UTC
Created attachment 82734 [details]
Patch to correction initialize cursorPos at start of zoom
Comment 2 Thomas Lübking 2013-10-09 17:55:35 UTC
Do you have commit rights?
Otherwise please re-use cursorPoint for prevPoint below and attach a "git format-patch"
Comment 3 C Schell 2013-10-10 03:28:41 UTC
I don't have commit rights, signed up just to post this bug.  The diff was generated by a commit to a deb source package.  Never worked with git so I'll have to figure out how to give you what you asked for.  If it's something you can easily do please feel free.
Comment 4 C Schell 2013-10-10 04:56:19 UTC
Created attachment 82758 [details]
git format-patch
Comment 5 C Schell 2013-10-10 04:59:27 UTC
(In reply to comment #2)
> Do you have commit rights?
> Otherwise please re-use cursorPoint for prevPoint below and attach a "git
> format-patch"

Ok, I made the suggested change and added a "git format-patch" against tags/v4.11.2.
Let me know if I've done something wrong.
Comment 6 Martin Flöser 2013-10-10 05:41:06 UTC
Git commit 4bbe80a68768b0714be7e6decdfa5880b8347723 by Martin Gräßlin, on behalf of C Schell.
Committed on 10/10/2013 at 04:50.
Pushed by graesslin into branch 'KDE/4.11'.

Fix zoom effect cursor position on initial zoom in.
FIXED-IN: 4.11.3

M  +2    -1    kwin/effects/zoom/zoom.cpp

Comment 7 Martin Flöser 2013-10-10 05:47:25 UTC
Thanks a lot and congratulations to your first patch to KDE :-)
Comment 8 C Schell 2013-10-10 06:17:20 UTC
(In reply to comment #7)
> Thanks a lot and congratulations to your first patch to KDE :-)

You're welcome.  And thanks for the quick commit and all the work you and the other devs do on KDE and Kwin.