[PATCH] randr: Fix logic in RRPointerToNearestCrtc

David Ung davidu at nvidia.com
Mon Jul 28 12:40:44 PDT 2014


>> RRPointerToNearestCrtc is suppose to snap to the nearest Crtc,
>> but the code is buggy.  Correct the calculation of delta x/y
>> values and choose the closest Crtc.
>
> This comment isn't terribly descriptive of the problems it's
> solving. There are two -- one where the dx/dy values end up off-by-one
> and another where it's simply forgetting to actually set the 'best' value.

but its more that dx/dy off-by-one.

previously best_dx/dy is always positive, if x > scan_width, 
when you call SetCursorPosition, the cursor's x position is gonna be even further away from the crtc's right edge.


how about this updated commit msg

RRPointerToNearestCrtc is suppose to snap to the nearest Crtc,
but best_x and best_y is always positive, hence when calling 
SetCursorPosition it will make the cursor even further away.
Correct delta x/y to allow negative values and also use
 "width/height -1" in the calculation.  Also choose the closest Crtc
by setting the "best" value.


>
>> +        dist = abs(dx) + abs(dy);
>
> You don't need abs here; dx and dy are always positive.

reason above.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


More information about the xorg-devel mailing list