ping? ________________________________________ From: David Ung [[email protected]] Sent: Thursday, July 17, 2014 5:19 PM To: [email protected] Cc: David Ung Subject: [PATCH] randr: Fix logic in RRPointerToNearestCrtc
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. Signed-off-by: David Ung <[email protected]> --- randr/rrpointer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/randr/rrpointer.c b/randr/rrpointer.c index eb6b677..ab8f9a0 100644 --- a/randr/rrpointer.c +++ b/randr/rrpointer.c @@ -77,21 +77,22 @@ RRPointerToNearestCrtc(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y, if (x < crtc->x) dx = crtc->x - x; - else if (x > crtc->x + scan_width) - dx = x - (crtc->x + scan_width); + else if (x > crtc->x + scan_width - 1) + dx = crtc->x + (scan_width - 1) - x; else dx = 0; if (y < crtc->y) dy = crtc->y - y; - else if (y > crtc->y + scan_height) - dy = y - (crtc->y + scan_height); + else if (y > crtc->y + scan_height - 1) + dy = crtc->y + (scan_height - 1) - y; else dy = 0; - dist = dx + dy; + dist = abs(dx) + abs(dy); if (!nearest || dist < best) { nearest = crtc; best_dx = dx; best_dy = dy; + best = dist; } } if (best_dx || best_dy) -- 1.7.9.5 ----------------------------------------------------------------------------------- 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. ----------------------------------------------------------------------------------- _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
